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."
They don't. (Score:5, Informative)
Iterating through offsets beginning with zero is simply not counting. The writer is confused.
Re:They don't. (Score:4, Funny)
This press conference is over.
Re:They don't. (Score:5, Funny)
This press conference is over.
The press conference began at 0 PM, where were you?
Re: (Score:2, Funny)
This press conference is over.
The press conference began at 0 PM, where were you?
I was at 0 Main Street.
"The corner of 0th and Null" was the joke you wanted.
Re: (Score:2)
Are you referring to my ding-a-ling by any chance?
http://www.youtube.com/watch?v=p490t_6Z9aY [youtube.com]
Re: (Score:3)
Why would programming want to meet kids as young as six years old?
Re: (Score:3)
Why would programming want to meet kids as young as six years old?
Because marketing thought it would be a good idea, and management agreed?
Re: (Score:3)
That's the reason we do thinks bitterly and with a ton of resentment, not why we want to do things.
Re: (Score:2)
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 (Score:3)
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
Re: (Score:2)
Now try formalising that without begging the question.
Re: (Score:2)
Re: (Score:3)
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: (Score:2)
the similarity is overwhelming.
Re:They don't. (Score:4, Informative)
Re: (Score:3)
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.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
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.
Re:They don't. - They really don't. (Score:4, Insightful)
Re: (Score:2)
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 ..."
Re: (Score:3)
In that instance, you're counting down the number of bottles left. And zero is the value at which you *stop* counting.
Re: (Score:2)
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)
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)
Exactly. The element count of an array where only index [0] is populated is still 1.
Re: (Score:2)
Re: (Score:2)
Re:We don't (Score:4, Insightful)
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)
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.
Re: (Score:3)
Everything you've listed is *an artifact of C*, at least in the context of the gamut of languages also thus far mentioned.
Everything is an artifact of the hardware. The fundamental properties of the computer itself. C is just closer to the hardware. Its not artifacts of C its artifacts of the hardware.
You're too stuck in C-think to realise how different other languages are, and how Algoloid-specific your knowledge is.
I've worked with LISP and ML and Smalltalk and XSL and SQL... but that's beside the point.
Re: (Score:2)
Re: (Score:2)
No. The creators of C were not terribly concerned about the extra compilation time - they were concerned about generating efficient code and representing it efficiently in the source.
Yes. But what made C such a universal language was the incidental fact that this made the compiler easier to implement. That allowed people to easily create C compilers for any new architecture; even all those newfangled 8-bit home computers with only 16K of addressable RAM. This is what popularized C's syntax, and thus the 0-based array.
So today, it is essentially a historical accident.
Re:We don't (Score:4, Informative)
No. The creators of C were not terribly concerned about the extra compilation time - they were concerned about generating efficient code and representing it efficiently in the source.
Yes. But what made C such a universal language was the incidental fact that this made the compiler easier to implement.
Except the first machines C ran on didn't have an "add unity to memory" instruction unless you got out the wire wrap tools and made one, so this excuse doesn't work.
The real reason is that variables and arrays actually take up memory, and if you understand this fact, then you will naturally gravitate toward using a 0 offset, whereas if you don't, then you probably learned programming using a language that hides the underlying memory allocations from you. Which is why anyone who wants to claim they are a programmer should learn at least one assembly language, so that they understand that memory is just that free stuff, and that you actually have to allocate backing store for variables.
Re: (Score:2)
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)
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. :)
Re: (Score:2)
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.
Re: (Score:2)
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).
Re: (Score:2)
Zero meters/miles/etc. "You haven't moved yet."
Re: (Score:2)
Physically, if there is nothing there to be represented, why is it counted?
Because people tend to decide what they count before they actually start counting. If someone asks you to count forks in an initially closed drawer, do you open the drawer and start counting, or do you answer "I cannot do that, since I don't know if the drawer contains any forks"?
Re: (Score:2)
How many years old were you from the time you were born until your first birthday?
Re: (Score:2)
Still interesting, but show me a count of things at Zero. Physically, if there is nothing there to be represented, why is it counted?
It is counted because it was expected and missing, or it was present then removed, or it is the lack of something expected to come. Think of someone who has a dept to pay but has no money, or who has a dept to pay and just enough money, or who starts his life with no possessions yes. In all three cases, a count of zero is considered, and even though Romans did not represent zero as they did other numbers, the concept of zero money was perfectly accessible to them, either in a comparison, or as a result of s
judging world's smallest self-replicating program (Score:3)
There was a contest for the smallest program that produces as output its own source code. Count the characters in the winning entry, which follows:
Yeah, but you're ruining a traditional joke (Score:2)
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
Re: (Score:3)
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
Re: (Score:2)
There are two kinds of programmers:
1) Those who start an index at 1
1) Those who start an index at 0
Fortran (Score:2)
Why do programmers start counting at zero?
I expect that this is going to annoy a lot of Fortran "programmers".
Re: (Score:2)
Sesame Street: Feist sings 1,2,3,4 (Score:2)
Sesame Street: Feist sings 1,2,3,4 [youtube.com]. Not 0,1,2,3. :-)
10 million? (Score:3)
So, is that (dec) ten million kids or (dec) two million?
Re: (Score:2)
Dude, you have to start at 0, so it is 9,999,999 kids.
Copyrights! (Score:5, Insightful)
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.
Re: (Score:2)
Not to mention if it's in a loop. Good lord, Zuckerberg could go broke!
Re: (Score:2)
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!
It's not a public performance (Score:2)
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
It's not a count, it's an offset (Score:3, Informative)
Confusion of terms (Score:2)
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.
Counting versus Indexing (Score:4, Informative)
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.
Good Luck (Score:2)
Make women *what* you? (Score:2)
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)
That "birthday loop" has the wrong upper end (Score:2, Informative)
If you are going to teach idiomatic loops, do it correctly. It's not
but
Note that in the second, idiomatic version your actual number of lines appears.
Note also that the two conventions are strongly related. [utexas.edu]
What 0-based and 1-based counts mean (Score:2)
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
The Article Is Self-Contradicting (Score:4, Informative)
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.
Not only that, but he misses the point entirely (Score:2)
Counting From Zero Actually Makes more Sense (Score:5, Insightful)
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.
Re: (Score:2)
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.
Re: (Score:2)
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
Re: (Score:2)
Flunked kindergarten, didn't you? You know, the part about working and playing well with others.
As a person, I won't even respond to your "points" since:
a) You don't appear to have one
and
b) You're an asshole.
Please, stay off the interwebs. We're all full up on jerks here.
Re: (Score:2)
Well, since we (as humans) tend not to converse in math, why don't you explain it in English?
Actually, since this is /., someone needs to post a car analogy.
Simple (Score:2)
Because you have to start counting SOMEWHERE.
Simple: Because computers do. (Score:2)
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.
Re: (Score:2)
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.
Re: (Score:3)
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
If you don't start with zero it won't make sense (Score:2)
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
I disagree (Score:3)
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.
0 based counting? (Score:2)
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?
He's wrong about BCPL (Score:2)
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.
Like (Score:2)
Re: (Score:2)
It's actually only 9,999,999 kids.... (Score:4, Funny)
Because you have to start counting kids from ZERO.
Don't you guys read your own articles?
Down the waterfall (Score:2)
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?
There are 10 types of people in the world (Score:3)
In related news ... (Score:3)
Just to enforce counting from 0..9.
Simple (Score:2)
Re: (Score:2)
It's a "C" thing. Try Pascal or other Wirth family languages instead if you want to start at 1.
Or .NET.
Maybe.
Re: (Score:2)
.Net is 0
Re: (Score:2)
Re: (Score:2)
the basic arrays, generic list, etc... are all 0 I can't think of anything in the .Net framework itself that indexes at 1 but I've seen 3rd party classes with indexes that start at 1 and it is annoying.
Re: (Score:3)
No, it's actually an assembly language thing, where you access array elements by base address and offset. Your first element sits at offset zero. C is merely a wrapper for assembly that's suffering from various wardrobe malfunctions.
Re: (Score:2)
C is merely a wrapper for assembly that's suffering from various wardrobe malfunctions.
Ooo. I like that.
Re: (Score:2)
I recommend indexing from 0 and using exclusive upper bounds in all languages. The number of off-by-one errors decreases dramatically in my experience.
Re: (Score:2)
It's a "C" thing. Try Pascal or other Wirth family languages instead if you want to start at 1.
...or pretty much any language that didn't crib its syntax from C.
Thinking that counting from 0 is a programming thing is a sure indication of a person with a very narrow experience with programming languages. The most programmer-abusive set of them at that.
Re: (Score:2)
No, its not "a computer thing" computers don't "count". They increment binary numbers. They don't have arrays; they have RAM and indexing features.
Nearly all programmers don't interface directly with computers, they use programming languages. How programming languages index their arrays is entirely up to the programming language designers. Different ones do it differently. C's designers chose to do it in a way that allowed their compiler writers to do as little work as possible (which is how they made most
Re: (Score:2)
Sure its a computer thing - computers just count 2 states, zero and one ;)
Re: (Score:2)
10 million, but your point is well-taken - you'd refer to the ten millionth kid as 9,999,999!
Re: (Score:2)
Your whole post is very time-cuboid, but I especifically got brainfucked by:
'empty' (a form of zero)
This is the kind of crap that comes from programmers trying to think in the machine domain rather than the problem domain, which in turn comes from fucked up hybrid languages like C++.
(I mean, I'd accept the excuse, "C++ gives you high level tools but is also close enough to the machine to allow efficient programming," if anyone actually programmed efficiently these days. But increase in software complexity should NOT require me to
Re: (Score:2)
We have editors? Where do you see that?
Re: (Score:2)
When you put in 1 minute, the instant you press start it likely goes to 0:59, which is a property of the display.
If you could see ms you would see those counting down.
So you are still nuking your food for exactly a minute, just that the time remaining is always truncated.
Re: (Score:2)
Re: (Score:2)
The reason nobody sang 'Happy zeroth birthday' to me was that my mom was in no mood to sing at the time.