Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming Education

Zuckerberg To Teach 10 Million Kids 0-Based Counting 295

theodp writes "'Why do programmers start counting at zero?' wondered Mike Hoye, questioning the conventional programming wisdom. Code.org will soon introduce the practice to a hoped-for audience of 10 million schoolchildren as part of Computer Science Education Week's Hour of Code. In a tutorial created by engineers from Microsoft, Google, Twitter and Facebook that's intended to introduce programming to kids as young as six years old, an otherwise breezy lesson featuring look-ma-no-typing Blockly and characters out of Angry Birds and Plants vs. Zombies, a Mark Zuckerberg video introducing the concept of Repeat Loops includes an out-of-place JavaScript example that shows kids it's as easy as 0-1-2-3 to generate 4 lines of lyrics from Happy Birthday to You by using zero-based numbering with a For-loop and ternary If statement. Accompanying videos by Bill Gates on If Statements and basketball star Chris Bosh on Repeat Until Blocks show the Code.org tutorial is still a work-in-progress. That's no big deal, since CSEdWeek has pushed back the delivery date for final Hour of Code tutorials from its prior little-time-for-testing due date to Dec. 9th, the first day of a five-day period during which teachers are expected to deliver the lessons to 10 million students."
This discussion has been archived. No new comments can be posted.

Zuckerberg To Teach 10 Million Kids 0-Based Counting

Comments Filter:
  • They don't. (Score:5, Informative)

    by skywire ( 469351 ) * on Friday November 15, 2013 @08:48AM (#45432095)

    Iterating through offsets beginning with zero is simply not counting. The writer is confused.

    • by wonkey_monkey ( 2592601 ) on Friday November 15, 2013 @09:09AM (#45432263) Homepage

      This press conference is over.

    • by ackthpt ( 218170 )

      Iterating through offsets beginning with zero is simply not counting. The writer is confused.

      I knew I was destined to be a programmer when I was introduced to Integers in elementary school. The siren song of beginning counting somewhere other than 1 entranced me.

    • Counting is an algorithm, like long division or the use of logarithmic tables--in this case an algorithm for assessing the exact numerosity of a set of objects. It consists of reciting a memorized stretch of blank verse ("one, two, three, four, five, ...") while uniquely pairing each foot in the poem with an object in the spotlight of attention, without skipping an object or landing on one twice. Then, when no object remains unnoticed, you announce the last foot you arrived at in the poem as the numerosity

    • There are plenty of software documentation sets, tutorials, etc, like this one [stack.nl] (selected at random), that have Step 0, Step 1, etc. I think it's an attempt to be clever, in that offsets start with zero, and this is documentation about computer stuff, being read by developers. But items in a list, intended to be read by humans, shouldn't be represented by offsets, but numbered with counting numbers [mathsisfun.com], that is, starting at 1.
      • by jc42 ( 318812 )

        There are plenty of software documentation sets, tutorials, etc, like this one [stack.nl] (selected at random), that have Step 0, Step 1, etc.

        And that example illustrates the usual reason for starting with step 0: The "zero" step is determining your initial state before you start doing anything. In this case, it's determining whether you should bother going on to step 1, which is pretty common. It's also common to use step 0 to list the material needed by the task.

        Probably the most common real-world example is cooking recipes, which typically start with a list of ingredients. That "step" is typically not numbered, but sometimes the actual "

    • Re:They don't. (Score:4, Informative)

      by CastrTroy ( 595695 ) on Friday November 15, 2013 @09:28AM (#45432475)
      Speaking of iterating, I almost never need to write a loop that uses an integer index. All the programming languages I use have a "For each" construct that works with just about anything you'd want to iterate over. No more worrying about off-by-one bugs, and other such associated problems. I have trouble recalling the last time I actually used the For(i =0.... syntax.
      • Bill Gates still uses BASIC and Mark Zuckerberg uses its bastard offspring (Python). You have to excuse them for not knowing about any data structure other than the integer-indexed array.

        • Python is one of those languages GP was talking about.
          • Yeah, Also, VB.Net, the only version of "BASIC" still worth talking about also supports "For Each". I'm sure there's still people using the older versions of BASIC, but I don't think it's like COBOL, which is equally bad, but sticks around because there's so much mission critical code written in it.
            • VB.Net is a simple symbol substitution away from being c# though. It changed its syntax in subtle little ways between VB 6 and VB.net to do so. It's fairly trivial to write a parser that converts VB.net to C#(the other way is a tinge more complicated). I don't think it's fair to call it a true descendent of BASIC.

    • by Jane Q. Public ( 1010737 ) on Friday November 15, 2013 @09:41AM (#45432601)
      We don't start counting at 0. Our compilers do.
      • I start counting at zero. "I have zero bottles of Mt. Dew, it is time to go to the store."

        Kids naturally start counting at zero. "I have zero breakfast from my parents today, I'll be fed for zero dollars at school." "I'll learn zero about ... today...".

        If the lowest counting number you know is one, then you have a real problem. "I don't know how to count how little Mt. Dew I have, I don't know what I'll dew ..."

        • by fatphil ( 181876 )
          > I start counting at zero. "I have zero bottles of Mt. Dew, it is time to go to the store."

          In that instance, you're counting down the number of bottles left. And zero is the value at which you *stop* counting.
    • by gweihir ( 88907 )

      Probably not only the writer. Seems all the well-known "IT" personalities on the list never understood that little fact.

      Of course counting starts at 1 and of course offsets start at 0. But you have to know what an offset actually is to understand that.

  • We don't (Score:5, Insightful)

    by Anonymous Coward on Friday November 15, 2013 @08:51AM (#45432119)

    Why do programmers start counting at zero?

    We don't. We start indexing at zero (in some languages), because that's usually the offset of the first useful location in an array (ie, addr + 0).

    • Re: (Score:2, Informative)

      by Anonymous Coward

      Exactly. The element count of an array where only index [0] is populated is still 1.

    • Also, Real Programmers(TM) use Fortran where array indices start at 1 by default, though you can also define your own way.
      • Ada also begins iterating at 1. It's SAFER that way.
        • Re:We don't (Score:4, Insightful)

          by T.E.D. ( 34228 ) on Friday November 15, 2013 @09:22AM (#45432407)

          No. Ada begins iterating wherever you tell it to. You can index your arrays from -100 to 0 if you like.

          Its a more useful language that way.

          It is quite true though that the 0-based thing is entirely an artifact of C (and of course languages that cribbed its syntax). Thinking that's a feature of programming is a sure sign of a inexperienced programmer.

          • Re:We don't (Score:5, Informative)

            by vux984 ( 928602 ) on Friday November 15, 2013 @12:34PM (#45434781)

            It is quite true though that the 0-based thing is entirely an artifact of C (and of course languages that cribbed its syntax).

            Its not an "artifact of C" its an artifact of reality.

            If you allocate 10 bytes at address X, then:

            the first one is going to be at address X, the second one is address X+1, etc.

            The x[y] syntax then reduces to address x + y

            And so x[0] is the byte at x, x[1] is the byte at x+1, etc.

            Now you could 1 base the indexes, where x[1] resolves to address of x, but the implementation of that is:

            x + 1 - 1, and x[y] in general becomes x + y - 1

            That's an extra subtraction instruction on every single array access.

            For larger datatypes it becomes:

            x + y*sizeof(type) for zero based and
            x + (y-1)*sizeof(type) for one based arrays

            That's going to be true for any language, and the question is posed to every language designer: either the programmer counts from zero, or every array access in the language has a subtraction added to it.

            For C, which is designed to be a bare bones close to the hardware language the decision was a nobrainer, but even for higher level languages its always a choice between a performance hit, or using zero based indexing.

            Another wrinkle is that if you use 1 based indexing, then x[0] is undefined.

            Another wrinkle is that if you use 1 based indexing then the maximum length of an array was reduced by 1.

            No. Ada begins iterating wherever you tell it to. You can index your arrays from -100 to 0 if you like.

            I don't deny that it's useful, but Ada does that by effectively adjusting all the indexes to zero based behind the scenes.

            "Thinking that's a feature of programming is a sure sign of a inexperienced programmer."

            No, only an inexperienced programmer would not understand that zero based indexing is the 'natural' indexing, and that anything else requires extra processing.

        • Ada also begins iterating at 1. It's SAFER that way.

          In C++ I can define a container with an operator[] that starts wherever I want it to.

          Why does nobody do it? Because we use proper iterators when we want to iterate a collection of data.

    • Re:We don't (Score:4, Insightful)

      by aaribaud ( 585182 ) on Friday November 15, 2013 @09:04AM (#45432219)
      I beg to differ on two accounts:
      • A. Maybe you don't, but that does not apply to "programmers", only to an imaginary set of "programmers" which you consider yourself a member of.
      • B. Iterating is not necessarily entirely different from counting.

      After all, the whole calculus thing stems from the latin for "small stone", which was the way to count livestock, by enumerating them. Start with no stone in hand; pick one stone per animal when you lead them some place; drop one stone per animal when you take the animals back; make sure you have no stone left, none missing either when all animals have passed. IOW... count from zero up, and then back to zero. :)

      • Zero, one, two. I have three stones.

        That makes no sense. Or we have to re-record every sesame street episode of The Count.

        Four, ah ah ah. I have 5 things. Five? You just said four, where did you get 5?

        No, if this is for kids it needs to stop now.

        • Zero, one, two. I have three stones. That makes no sense.

          That's because you're mistaking the states and transitions. The right description is "I have zero stone. I pick a stone. I have one stone. I pick a stone. I have two stones. I pick a stone. I have three stones and there a no stones left to pick". IOW, you see the three transition, or actions, of counting "one", "two" and "three", but you map these actions to the first three states (thus ending on the third state) instead of placing them between the four states (thus ending on the fourth one).

    • Why do programmers start counting at zero?

      We don't. We start indexing at zero (in some languages), because that's usually the offset of the first useful location in an array (ie, addr + 0).

      Yeah, yeah, yeah, and testing against zero is usually computationally cheaper in hardware. You're right, but you're wrecking an ancient jest.

      Female programmers can only count to nine without taking their shoes off, but male programmers can count to ten by just unzipping.

      That chestnut's as traditional as "why do programme

    • by alexhs ( 877055 )

      Reading the comments, many people are confused.

      If this can help people doing less off-by-one errors ;) : cardinal vs ordinal vs nominal [mathsisfun.com].

      Depending on the language, an element in an array is referenced by either its ordinal value (1st element, 2nd element), or the cardinal value corresponding to an offset, that is, a difference counted in elements between the start of the array (1st element) and the considered element (0 position between requested element and start element, 1 position between requested elemen

    • by sootman ( 158191 )

      There are two kinds of programmers:
      1) Those who start an index at 1
      1) Those who start an index at 0

  • Why do programmers start counting at zero?

    I expect that this is going to annoy a lot of Fortran "programmers".

  • Sesame Street: Feist sings 1,2,3,4 [youtube.com]. Not 0,1,2,3. :-)

  • by sootman ( 158191 ) on Friday November 15, 2013 @09:00AM (#45432187) Homepage Journal

    So, is that (dec) ten million kids or (dec) two million?

  • Copyrights! (Score:5, Insightful)

    by sootman ( 158191 ) on Friday November 15, 2013 @09:03AM (#45432209) Homepage Journal

    Careful there, Z -- that might count as a "public performance" of Happy Birthday. I know you're rich, but the payment for and audience of 10 million might be kinda high.

    • Not to mention if it's in a loop. Good lord, Zuckerberg could go broke!

    • Careful there, Z -- that might count as a "public performance" of Happy Birthday. I know you're rich, but the payment for and audience of 10 million might be kinda high.

      My first thought, exactly. I really hope he got the rights secured or he might get sued for everything he's worth. Those sisters are vicious about protecting their copyright. I would have picked Row, Row, Row Your Boat before Happy Birthday. Way to teach children how to respect copyright Zuck and Bill!

    • When you make a video, that is not a public performance. It is a cover recording. Now, if he had released it as audio only, he would only have to purchase a mechanical license for something like $0.07 per copy. Granting mechanical licenses is mandatory for the copyright holder and the price is set by the government. Unfortunately, mandatory licensing does not apply to audio-video sync licenses, which is what you need if you make a video. AV sync licenses must be purchased directly from the copyright holder

  • by Andover Chick ( 1859494 ) on Friday November 15, 2013 @09:04AM (#45432213)
    It is an indicator of a shift off the first position.
  • Numbering items with an index starting from zero isn't counting. It's just numbering.

    Teach this first, along with counting continguous elements by index substraction + 1.

  • by Millennium ( 2451 ) on Friday November 15, 2013 @09:07AM (#45432251)

    Programmers don't count starting at zero. They index items in collections starting at zero, because it makes certain actions more convenient when you're working at a very low level. But when it comes time to count the items, they start at 1 like everyone else.

  • I'd like to wish Mark Zuckerberg luck in his new teaching career. He'd better start now, it will take him most of his natural life to make a dent in that number.
  • Are those YouTube features personally tailored?

    Also I'm pretty sure that theodp is breaking the Flickr T&Cs by linking directly to the image.

  • We should (Score:3, Insightful)

    by trinaryai ( 949870 ) on Friday November 15, 2013 @09:23AM (#45432411)
    The biggest mistake in teaching mathematics is learning to start counting at one. That's fine if the only math ever learned is basic arithmetic; but higher order concepts including fractions, algebra, and number sets beyond whole numbers become much more difficult as a result. Why do we start counting at zero? Because zero is "Origin". When we count, what we are actually doing is this: I have zero. Adding one, I have one. Adding one, I have two. Adding one, I have three. Etc. By using zero as our origin, we can teach arithmetic using the integer set, rather than the whole number set. We can teach that the minus sign just means a change of direction, and that addition and subtraction are actually the same thing. So addition/subtraction is nothing more than repeated counting - a shortcut. Multiplication and division are repeated addition. Fractions are just another way of expressing division. Exponents/roots are repeated multiplication. "If you can count, you can do math. Everything else is a shortcut." Counting from zero allows us to teach euclidean coordinates / geometry as an extension of what students already are familiar with, rather than something new. Why do we start counting at zero? Because zero is "Origin".
  • by Anonymous Coward

    If you are going to teach idiomatic loops, do it correctly. It's not

    for (i=0; i<=3; i++)

    but

    for (i=0; i<4; i++)

    Note that in the second, idiomatic version your actual number of lines appears.

    Note also that the two conventions are strongly related. [utexas.edu]

  • 4 lines of lyrics from Happy Birthday to You

    Others beat me to the copyright jokes.

    But seriously, both 0-based and 1-based counting have valid, physical meanings. A 0-based count measures the number of valid elements before this one is processed. This count of preceding elements is useful for indexing in the majority of popular programming languages. A 1-based count, on the other hand, measures the number of valid elements after this one is processed. One often needs to allocate memory for elements in a manner such that the amount of memory used at

  • by StormReaver ( 59959 ) on Friday November 15, 2013 @09:31AM (#45432495)

    I started reading the article linked to in, "start counting at zero", and stopped halfway through. I feel sorry for anyone who reads that article, but isn't a programmer (hell, even if they are programmers), as it is self-contradictory crap:

    From the article:

    Itâ(TM)s not about [pointer math] because pointers and structs didnâ(TM)t exist....So I found [the person who originally decided to start array indices at zero] and asked him [why he started array indices at zero].

    Then the father of zero-index arrays said:

    ...if p is a pointer p+1 is a pointer to the next word after the one p points to.

    He then goes on to admit that zero-index arrays are the most efficient means of calculating memory addresses, and brushes aside his self-contradictions by saying that the "why" is more important than the "how".

    Which means, as should be obvious to everyone, that zero indices are the most natural way to express pointer arithmetic; internally to your language runtime if your language doesn't support pointers, or externally if pointers are programmer-facing.

    The author of this article needs to brush up on computer fundamentals before self-publishing his absurd opinion pieces on computer fundamentals. Zero-index arrays are "conventional programming wisdom" because they have always been the easiest way to calculate memory addresses.

    • The author of exple.tive thinks that it's all about execution, efficiency, which his sources clearly indicate it's not -- but he's so hung up on execution efficiency being the most important thing in his mind that he doesn't even realize what his sources are saying. It's actually all about ease of programming. The logic of offsets is easier to follow when indexing from zero. Full stop. (That said, as others have mentioned, people still count from one.)
  • by physicsphairy ( 720718 ) on Friday November 15, 2013 @09:32AM (#45432509)

    Even well into adulthood, people are still confused by, e.g., the difference between "the early 1700s" and "the early 17th century" (which is actually the 1600s). Turns out, whether you like it or not, the first place value of 10^2, 10^3, 10^4, etc. you count through is always the 0th one. It's only in the very specific circumstance of counting the 10^1 place and when all the other 10^x place values are zero that the 0 gets skipped. Why not be consistent?

    Besides being more consistent, I also think it is more intuitive (barring the fact that we are culturally inducted into thinking that it isn't). If you were counting *backwards,* say, starting with ten cookies and removing one cookie off a plate each time, it would be perfectly intuitive to you that you should count down to zero cookies, taking the very last cookie off the plate. The zero cookie limit is enforced by physical reality, while the one cookie limit is enforced by your arbitrary decision to interrupt your process of removing cookies and leave one cookie on the plate. Likewise, in the reverse process, you should also start your counting at an empty plate.

    • by T.E.D. ( 34228 )

      Yes, but it that case, we should all be using base 11 for our human numbering system (with our 10 fingers we can count from 0 to 10.) Or perhaps base 6, and use the second hand as the 6^1 digit.

      I'll tell you what. You start off with base-11/base-6 numbering and math, and get back to the rest of us when you can honestly report how much better that is working for you.

    • Zero is not a counter, it is a placeholder meaning no things to count. It was not even a concept in early number systems.
      Count cookies. Do you close your eyes and say "zero cookies" before moving to the first? No, because that's stupid.
      Remove cookies, does anyone really enumerate zero after the last cookie is gone? No. 2, 1, none.
      If you enumerate with zero, it is far more intuitive to count
      2 cookies
      1 cookies
      0 cookies, zebras, Mexicans, herpes, doors, suns, darts

      Because there is nothing left to say what you

  • Because you have to start counting SOMEWHERE.

  • Comparing against zero is fast. Yes, even in high level languages like JavaScript if you write your loop in reverse it goes faster because your compare will be against zero instead of some in-memory or register value. Do some assembly level programming. At that level it's blatantly, smacked in the face, obvious.

    • That hasn't been true for 30 freaking years. Stop repeating crap your tired old, hasn't worked with a real computer in the past 2 decades, crap professor spewed at you.

      What processor takes more than 1 cycle to test a value other than 0? Educate me, please.

      • What processor takes more than 1 cycle to test a value other than 0? Educate me, please.

        You can often do away with the extra test altogether when you're comparing against zero, provided the decrement operation sets the condition bits. It's also fairly common to have dedicated counters and "decrement and branch if not zero" opcodes. If you're comparing against a non-zero constant, and the compiler doesn't optimize the comparison away, that's at least one extra instruction and one extra cycle in the body of the loop. In optimized code the space required for the extra opcode can be just as import

  • 00.01.02.03.04.05.06.07.08.09
    10.11.12.13.14.15.16.17.18.19
    20.21.22.23.24.25.26.27.28.29
    30.31.32.33.34.35.36.37.38.39
    ...
    0000 0001
    0010 0011
    0100 0101
    0110 0111
    1000 1001
    1010 1011
    1100 1101
    1110 1111
    ...
  • by wcrowe ( 94389 ) on Friday November 15, 2013 @10:13AM (#45432965)

    I think introducing zero-based counting to older children is a good idea. For younger children, this is a mistake.

    "You have ten fingers Zoe."

    "No I don't. I have nine. See? 0,1,2,3,4,5,6,7,8,9 -- 9!"

    Teaching young children zero-based counting, before they can count is like teaching them the Greek alphabet before they learn their ABCs.

  • I've heard of 1 based counting (0,1,2,3,4, etc)
    I've heard of 2 based counting (0,2,4,6,8, etc)
    I've heard of 5 and 10 based counting (0,5,10,15, etc. or 0,10, 20, 30, etc.)
    and so on,
    but wouldn't 0 based counting just give you 0,0,0,0,0?

  • From TFA:

    and though BCPL arrays are zero-origin, the language doesn’t support pointer arithmetic, much less data structures

    In BCPL the only way of addressing arrays is by pointers [cam.ac.uk]. Pointers are fundamental. Variables can contain pointers to data (vectors), procedures, vectors of procedures etc. If you see that the only way of making structures is to use vectors and pointers you see that zero-indexing is fundamental.

  • I LIKE that Mark. If I were on the fBook, I would click a button 4u.
  • Comment removed based on user account deletion
  • by tekrat ( 242117 ) on Friday November 15, 2013 @10:43AM (#45433321) Homepage Journal

    Because you have to start counting kids from ZERO.
    Don't you guys read your own articles?

  • That's no big deal, since CSEdWeek has pushed back the delivery date for final Hour of Code tutorials from its prior little-time-for-testing due date to Dec. 9th

    Software industry, is there nothing you cannot deliver late, not even a simple description of a loop?

  • by safetyinnumbers ( 1770570 ) on Friday November 15, 2013 @11:29AM (#45433923)
    Those who count from 0 and the other 10 types.
  • by PPH ( 736903 ) on Friday November 15, 2013 @11:54AM (#45434291)

    ... Zuckerberg To Chop One Finger Off 10 Million Kids.

    Just to enforce counting from 0..9.

  • 0 is the first number, so everything should start at 0. When you're born you aren't 1 you're 0, 0 is the logical first place to start for counting.

Every nonzero finite dimensional inner product space has an orthonormal basis. It makes sense, when you don't think about it.

Working...