Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13527

Re: Teaching kids to program (in Java)

From Joshua Cranmer <Pidgeot18@verizon.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Teaching kids to program (in Java)
Date 2012-04-13 10:55 -0500
Organization A noiseless patient Spider
Message-ID <jm9i9u$253$1@dont-email.me> (permalink)
References (1 earlier) <jm7290$53c$1@dont-email.me> <4f87624e$0$287$14726298@news.sunsite.dk> <UpydndS--INlZBrSnZ2dnUVZ8jadnZ2d@giganews.com> <jm98ch$3ad$1@speranza.aioe.org> <b_SdnRCLp-2HrhXSnZ2dnUVZ8k6dnZ2d@giganews.com>

Show all headers | View raw


On 4/13/2012 9:07 AM, Leif Roar Moldskred wrote:
> You'll never see a mathematican refer to the 0th element of an array
> or vector. Zero-based arrays most certainly are an idiosyncrasy of
> programming languages -- which sometimes, such as for C, makes
> sense. For a programming language that does arrays right, look to Ada.

I see lots of references to things like x_0 in mathematics. It really 
comes down to "is 0 the first natural number or is 1 the first natural 
number?" Edgar Dijkstra (I believe) once laid out his opinion of array 
indexing and arrived at the conclusion that 0 <= i < n is the most 
natural way to do for-loop-iteration, so array indexing should start at 
0 and not 1. The argumentation, IIRC, boils down roughly as follows:
1. [start, start + length) is the most natural bound
2. Length should be a simple expression, i.e., n
3. Using (<=, <) as your pair of comparison most clearly indicates the 
use of [a, b) notation
4. Thus, start <= i < start + n is the appropriate notation.
5. When the start is the beginning of the array, start + n should just be n
6. So start should be 0, and we get 0 <= i < n

There are occasionally places where 1-based indexing makes more sense 
(array-based heap notations are a particularly well-known example), but 
I'm not sure that giving programmers the ability to choose array bounds 
is the best option.

Also, FWIW, the convention of 1 being the "first" number isn't totally 
universal: the Mayans started from 0. And they were arguably the best 
mathematicians of their time.

>> I don't believe it is reasonable to accuse any programming language of being
>> "too crufty to make for a good introductory language" if the only problem
>> which has been pointed out boils down to ignorance regarding how to use that
>> programming language.  No programming language, no matter how appropriate it
>> might be as an introductory language, enables you to write any code without
>> first learning how to do it.

So we should start by teaching everyone APL, right? :-)

The problem is that discussing a basic Hello World in Java requires, at 
a minimum, handwaving the public class HelloWorld, the public static 
void main, System.out.println, and the entire compilation procedure. If 
you don't handwave, you have to give a lengthy amount of time to 
explaining how object-oriented programming works before you can begin 
discussing programming. You also very quickly get to bugaboos with 
explicit typing, doing I/O (reading from stdin is surprisingly 
complicated in Java), collections (generics is complicated enough for 
seasoned programmers; for those just starting a few weeks ago, it's an 
imposing cliff).

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Teaching kids to program (in Java) Mark <i@dontgetlotsofspamanymore.invalid> - 2012-04-12 09:12 +0100
  Re: Teaching kids to program (in Java) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-04-12 08:28 +0000
  Re: Teaching kids to program (in Java) Roedy Green <see_website@mindprod.com.invalid> - 2012-04-12 04:36 -0700
    Re: Teaching kids to program (in Java) David Lamb <dalamb@cs.queensu.ca> - 2012-04-12 09:47 -0400
    Re: Teaching kids to program (in Java) Lew <noone@lewscanon.com> - 2012-04-12 07:42 -0700
      Re: Teaching kids to program (in Java) Roedy Green <see_website@mindprod.com.invalid> - 2012-04-12 19:41 -0700
      Re: Teaching kids to program (in Java) Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-13 21:22 -0300
    Re: Teaching kids to program (in Java) Mark <i@dontgetlotsofspamanymore.invalid> - 2012-04-16 13:53 +0100
  Re: Teaching kids to program (in Java) David Lamb <dalamb@cs.queensu.ca> - 2012-04-12 13:09 -0400
    Re: Teaching kids to program (in Java) David Lamb <dalamb@cs.queensu.ca> - 2012-04-12 13:28 -0400
    Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-12 19:16 -0400
      Re: Teaching kids to program (in Java) David Lamb <dalamb@cs.queensu.ca> - 2012-04-12 20:36 -0400
        Re: Teaching kids to program (in Java) Roedy Green <see_website@mindprod.com.invalid> - 2012-04-12 19:55 -0700
      Re: Teaching kids to program (in Java) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-04-13 05:03 -0500
        Re: Teaching kids to program (in Java) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-04-13 10:14 +0000
          Re: Teaching kids to program (in Java) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-04-13 09:27 -0500
            Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-13 20:42 -0400
              Re: Teaching kids to program (in Java) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-04-14 02:08 +0000
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-05 20:13 -0400
                Re: Teaching kids to program (in Java) Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-06 12:06 +0000
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-06 11:38 -0400
        Re: Teaching kids to program (in Java) Rui Maciel <rui.maciel@gmail.com> - 2012-04-13 14:06 +0100
          Re: Teaching kids to program (in Java) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-04-13 09:07 -0500
            Re: Teaching kids to program (in Java) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-04-13 09:53 -0500
            Re: Teaching kids to program (in Java) Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-04-13 10:55 -0500
          Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-13 08:39 -0700
            Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-13 20:47 -0400
              Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-15 20:05 -0700
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-17 22:11 -0400
                Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-17 19:57 -0700
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-18 19:20 -0400
                Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-18 18:03 -0700
                Re: Teaching kids to program (in Java) Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-19 20:15 -0300
                Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-19 20:08 -0700
                Re: Teaching kids to program (in Java) Lew <lewbloch@gmail.com> - 2012-04-20 12:43 -0700
                Re: Teaching kids to program (in Java) Patricia Shanahan <pats@acm.org> - 2012-04-20 12:58 -0700
                Re: Teaching kids to program (in Java) Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-04-20 15:20 -0500
                Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-04-20 13:30 -0700
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-05 20:23 -0400
                Re: Teaching kids to program (in Java) Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-06 12:22 +0000
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-06 11:36 -0400
                Re: Teaching kids to program (in Java) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-05-06 17:10 +0000
                Re: Teaching kids to program (in Java) Gene Wirchenko <genew@ocis.net> - 2012-05-07 09:43 -0700
                Re: Teaching kids to program (in Java) Martin Gregorie <martin@address-in-sig.invalid> - 2012-05-07 18:17 +0000
                Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-05-05 20:18 -0400
          Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-13 20:44 -0400
        Re: Teaching kids to program (in Java) Arne Vajhøj <arne@vajhoej.dk> - 2012-04-13 20:38 -0400
        Re: Teaching kids to program (in Java) Gunter Herrmann <notformail0106@earthlink.net> - 2012-04-16 15:32 -0400
    Re: Teaching kids to program (in Java) Roedy Green <see_website@mindprod.com.invalid> - 2012-04-12 19:44 -0700
  Re: Teaching kids to program (in Java) Patricia Shanahan <pats@acm.org> - 2012-04-13 17:59 -0700

csiph-web