Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Zuckerberg To Teach 10 Million Kids 0-Based Counting

Soulskill posted about 9 months ago | from the why-not-mix-things-up-and-start-at-pi dept.

Programming 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."

cancel ×

295 comments

Sorry! There are no comments related to the filter you selected.

They don't. (4, Informative)

skywire (469351) | about 9 months ago | (#45432095)

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

Re:They don't. (3, Funny)

wonkey_monkey (2592601) | about 9 months ago | (#45432263)

This press conference is over.

Re:They don't. (4, Funny)

ackthpt (218170) | about 9 months ago | (#45432317)

This press conference is over.

The press conference began at 0 PM, where were you?

Re:They don't. (0)

Anonymous Coward | about 9 months ago | (#45432399)

This press conference is over.

The press conference began at 0 PM, where were you?

I was at 0 Main Street.

Re:They don't. (2, Funny)

Anonymous Coward | about 9 months ago | (#45432651)

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:They don't. (0)

Anonymous Coward | about 9 months ago | (#45432345)

Only after I am done speaking my run-on sentences that don't seem to bother anyone in this crowd as we are all seemingly used to them...

"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."

Re:They don't. (2)

bsDaemon (87307) | about 9 months ago | (#45432389)

Why would programming want to meet kids as young as six years old?

Re:They don't. (1)

ackthpt (218170) | about 9 months ago | (#45432341)

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 (2)

swm (171547) | about 9 months ago | (#45432395)

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 of the set.

This is just one of many possible algorithms for ascertaining numerosity. In some societies, people pair up the objects with parts of their body, and I know several computer programmers who count like this: "Zero, one, two three, four. There are five."

--Steven Pinker, The Stuff of Thought, p. 141

Re:Counting is an algorithm (1)

Joining Yet Again (2992179) | about 9 months ago | (#45432805)

Now try formalising that without begging the question.

Re:They don't. (1)

mpicker0 (411333) | about 9 months ago | (#45432465)

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.

Re:They don't. (3, Informative)

CastrTroy (595695) | about 9 months ago | (#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.

Re:They don't. (2)

Joce640k (829181) | about 9 months ago | (#45432677)

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:They don't. - They really don't. (3, Insightful)

Jane Q. Public (1010737) | about 9 months ago | (#45432601)

We don't start counting at 0. Our compilers do.

Re:They don't. (0)

Anonymous Coward | about 9 months ago | (#45432643)

What do you expect when an "awesome" web "programmer" is involved.

Re:They don't. (1)

gweihir (88907) | about 9 months ago | (#45432949)

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.

What is this shit? (1)

larry bagina (561269) | about 9 months ago | (#45432115)

Can I request an Editor Week?

We don't (5, Insightful)

Anonymous Coward | about 9 months ago | (#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:We don't (2, Informative)

Anonymous Coward | about 9 months ago | (#45432163)

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

Re:We don't (1)

TeknoHog (164938) | about 9 months ago | (#45432183)

Also, Real Programmers(TM) use Fortran where array indices start at 1 by default, though you can also define your own way.

Re:We don't (1)

TVmisGuided (151197) | about 9 months ago | (#45432289)

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

Re:We don't (3, Insightful)

T.E.D. (34228) | about 9 months ago | (#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 (1)

Anonymous Coward | about 9 months ago | (#45432517)

If you'll read the article (I know, I know) it's a feature of BCPL that C inherited, and was done to shave a few cycles off of the compilation time on some old-ass IBM mainframe so that you didn't run out of your timeshare or get bumped because the CEO of IBM wanted to run his yacht-racing simulation or whatever.

Obviously, indexing from 0 or 1 is just an arbitrary decision and you may as well index from -1 or 2 or, as the old joke goes, 0.5 as a compromise.

Re:We don't (-1)

Anonymous Coward | about 9 months ago | (#45432699)

Usually you Aspie types use it's all over the place, you're unique in that you used its when you *wanted* it's. It never ceases to amaze me that people like you who can argue the finer points of dozens of languages can't grasp the simple apostrophe.

Re:We don't (-1)

Anonymous Coward | about 9 months ago | (#45432945)

Usually you Aspie types use it's all over the place, you're unique in that you used its when you *wanted* it's. It never ceases to amaze me that people like you who can argue the finer points of dozens of languages can't grasp the simple apostrophe.

And it never ceases to amaze me that people making arguments about correct use of punctuation marks can completely ignore the concept of a quote, causing their sentences to be utter nonsense.

Here's how your first sentence would read with correct quoting:

Usually you Aspie types use "it's" all over the place, you're unique in that you used "its" when you *wanted* "it's".

(And please don't argue whether the full stop belongs inside or outside the quote. Both conventions exist.)

Also note that the correct quoting is much simpler than the correct apostrophe: In English, a possessive case "s" ending always gets an apostrophe except it the word happens to be a pronoun. So "its" is an exception to the rule. On the other case, the quote rule has no exceptions: If you are speaking about the word or phrase instead of using it, you quote it. Always. Without exception.

Examples:

"He didn't know how to write the word sequence" means there was a sequence of words he didn't know how to write.
"He didn't know how to write the word 'sequence'" means he didn't know how the single word "sequence" is written.
"He didn't know how to write 'the word sequence'": means he didn't know how to write the word sequence "the word sequence".

Re:We don't (1)

Joce640k (829181) | about 9 months ago | (#45432645)

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 (-1)

Anonymous Coward | about 9 months ago | (#45432721)

Of course you do. Proper iterators.

Pay no attention to the fact that in pretty much every implementation of the STL for a decade and a half, vector<T>::iterator was a typedef for T*.

Re:We don't (0)

Anonymous Coward | about 9 months ago | (#45432193)

Also, we like to count from a higher number down to zero because branching on zero-flag or borrow after the decrement saves a cycle.

Re:We don't (3, Insightful)

aaribaud (585182) | about 9 months ago | (#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. :)

Re:We don't (0)

Anonymous Coward | about 9 months ago | (#45432337)

Still interesting, but show me a count of things at Zero. Physically, if there is nothing there to be represented, why is it counted? But using a imaginary construct, as an item? Illogical. I know, the arab system, starts with nothing, and the roman/greek system starts with 1. And their maths both work out....

Re:We don't (1)

Ihlosi (895663) | about 9 months ago | (#45432387)

Still interesting, but show me a count of things at Zero. Physically, if there is nothing there to be represented, why is it counted?

Zero meters/miles/etc. "You haven't moved yet."

Critical corner case... (0, Flamebait)

Anonymous Coward | about 9 months ago | (#45432537)

There is at least one very important case where it is critical to distinguish between counting from 0 or 1. It's counting of "gods".

Christians start at 1.
Atheists start at 0.

Re:We don't (1)

MtHuurne (602934) | about 9 months ago | (#45432599)

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:We don't (1)

findoutmoretoday (1475299) | about 9 months ago | (#45432559)

Why do programmers start counting at zero?

We don't.

Even a six year old kid knows that ... shouldn't we start at one, that's a seven year old

Re:We don't (0)

Anonymous Coward | about 9 months ago | (#45432633)

I know I do. My loops always are from 0 to n in C/C++ even if the loop counter is not used for any indexing.

Re:We don't (0)

Anonymous Coward | about 9 months ago | (#45432653)

sorry, there's a < sign missing before n

Re:We don't (0)

Anonymous Coward | about 9 months ago | (#45432781)

If you count from 0 to n (less than n), you'll never start counting at all. Don't you mean n -1?

Please confirm that you don't actually program for a living.

Meanwhile ... (0)

Anonymous Coward | about 9 months ago | (#45432133)

... the Lua and Matlab developers are shaking their fists at the skies.

Simple (0)

Anonymous Coward | about 9 months ago | (#45432147)

Because that's how many girlfriends most of them had.

All the big names (0)

Anonymous Coward | about 9 months ago | (#45432165)

from the firms giving us the finest in privacy destroying bad code.

This is so cheesy I'm getting queasy. Won't somebody think of the poor, poor children?

Fortran (1)

Roger W Moore (538166) | about 9 months ago | (#45432169)

Why do programmers start counting at zero?

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

Re:Fortran (1)

TheRealMindChild (743925) | about 9 months ago | (#45432613)

VB programmers

Sesame Street: Feist sings 1,2,3,4 (1)

theodp (442580) | about 9 months ago | (#45432177)

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

Why do programmers start counting at zero? (1)

cold fjord (826450) | about 9 months ago | (#45432179)

It's a "C" thing. Try Pascal or other Wirth family languages instead if you want to start at 1.

Re:Why do programmers start counting at zero? (1)

CubicleZombie (2590497) | about 9 months ago | (#45432235)

It's a "C" thing. Try Pascal or other Wirth family languages instead if you want to start at 1.

Or .NET.

Maybe.

Re:Why do programmers start counting at zero? (1)

martijn hoekstra (1046898) | about 9 months ago | (#45432561)

Last I checked .NET isn't a language.

Re:Why do programmers start counting at zero? (0)

Anonymous Coward | about 9 months ago | (#45432575)

If you dare?

Re:Why do programmers start counting at zero? (1)

pr0fessor (1940368) | about 9 months ago | (#45432693)

.Net is 0

Re:Why do programmers start counting at zero? (1)

CubicleZombie (2590497) | about 9 months ago | (#45432907)

In the mish mash of legacy components wrapped up in the .NET architecture and the various third party components in frequent usage, I've run into all kinds of things indexed at 1. Thus the 'maybe'.

Re:Why do programmers start counting at zero? (1)

Anonymous Coward | about 9 months ago | (#45432253)

Actually, in Pascal you can start your index whereever you want. For example, the following defined an array starting at 42:

var a: array[42..99] of integer;

Re:Why do programmers start counting at zero? (2)

Ihlosi (895663) | about 9 months ago | (#45432309)

It's a "C" thing

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:Why do programmers start counting at zero? (1)

larry bagina (561269) | about 9 months ago | (#45432385)

It's a computer thing. (What is C if not a portable PDP 11 assembler?)

Re:Why do programmers start counting at zero? (1)

T.E.D. (34228) | about 9 months ago | (#45432833)

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 every language decision). C became popular, so a lot of languages copied it. But a lot more did not. (Ada for example allows the user to pick their own array indices for their own convenience, rather than the compiler writer's.)

Don't confuse historical accidents with holy writ.

Re:Why do programmers start counting at zero? (1)

MtHuurne (602934) | about 9 months ago | (#45432487)

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:Why do programmers start counting at zero? (1)

T.E.D. (34228) | about 9 months ago | (#45432673)

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.

10 million? (2)

sootman (158191) | about 9 months ago | (#45432187)

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

Re:10 million? (1)

transporter_ii (986545) | about 9 months ago | (#45432277)

Dude, you have to start at 0, so it is 9,999,999 kids.

Re:10 million? (0)

Anonymous Coward | about 9 months ago | (#45432331)

No need to add (dec) if you spell it out. "ten" always refers to the smallest product of two non-consecutive primes, which can be written in digits as (bin) 1010 or as (dec) 10. But (bin) ten would not be (bin) 10, but (bin) 1010, because the word "ten" describes a number, not a digit sequence (the corresponding digit sequence would be either (dec) one-zero, or (bin) one-zero-one-zero).

Re:10 million? (0)

Anonymous Coward | about 9 months ago | (#45432729)

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

It's really only 128 kids. Zuckerberg is trying to look nerdy by using binary.

So is it... (0)

Anonymous Coward | about 9 months ago | (#45432189)

10 million kids or 10,000,001 kids?

Re:So is it... (1)

theodp (442580) | about 9 months ago | (#45432259)

10 million, but your point is well-taken - you'd refer to the ten millionth kid as 9,999,999!

Copyrights! (5, Insightful)

sootman (158191) | about 9 months ago | (#45432209)

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:Copyrights! (1)

Vintermann (400722) | about 9 months ago | (#45432267)

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

Re:Copyrights! (0)

Anonymous Coward | about 9 months ago | (#45432419)

He could just not pay it, because the copyright on Happy Birthday is bogus, and the people trying to claim it wouldn't dare sue Zuckerberg: One high profile defeat would ruin their business^wscam.

Re:Copyrights! (1)

multimediavt (965608) | about 9 months ago | (#45432589)

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 count, it's an offset (3, Informative)

Andover Chick (1859494) | about 9 months ago | (#45432213)

It is an indicator of a shift off the first position.

Confusion of terms (1)

advid.net (595837) | about 9 months ago | (#45432227)

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 (3, Informative)

Millennium (2451) | about 9 months ago | (#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.

Re:Counting versus Indexing (1)

Anonymous Coward | about 9 months ago | (#45432727)

Depends if you start counting before you see the first element or not. If I need to count the beans in an empty jar, I would start from 0. In fact, every sane counter is initialized with 0.

I think the old-schoolers here still have to understand the meaning of the cardinal number zero.

But no, preschoolers don't have to worry about that.

obligatory slashdot knee jerk post (-1)

Anonymous Coward | about 9 months ago | (#45432269)

I don't even haz teh Facebooks.
 
ELgg FTW!!!!1111!!!!
 
HERP!!!

Z aslo teaching 0-based privacy... (0)

Anonymous Coward | about 9 months ago | (#45432271)

But hopefully the kids have a lesson for him soon.

0 Happy Birthday to You (1)

Anonymous Coward | about 9 months ago | (#45432275)

1 The RIAA Will Sue
2 Happy Birthday to Marky
3 Our Lawyers'll be Contacting You

Re:0 Happy Birthday to You (1)

mrego (912393) | about 9 months ago | (#45432909)

Maybe Zuckerberg will buy Warner's copyright (which supposedly goes until 2030) and give the song away to the US for free. Otherwise he can pay the royalties.

A Good Use of His Time? (1)

bobwalt (2500092) | about 9 months ago | (#45432295)

Perhaps his time would be better spent getting Facebook to work correctly or maybe its just that his method of counting doesn't work that well.

Wrong (0)

Anonymous Coward | about 9 months ago | (#45432297)

Teach kids how to spell, write and do math correctly, then make them learn how to build a fire, build a house, grow vegetables.

When the end of the world comes, it's not diseases that's going to kill humanity, it's the lack of basic skills.

Please... (0)

Anonymous Coward | about 9 months ago | (#45432303)

Please teach them about RUN-ON SENTENCES first!

"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."

No zero (1)

Anonymous Coward | about 9 months ago | (#45432313)

Personally, I am sick and tired of seeing Microwaves that treat zero like it's a counting number. When it reaches zero it's supposed to stop, but instead they often continue for an additional second.

Youtube does the same thing. Advertisements on videos with that little countdown button. It says it delays 5 seconds, but it actually delays 6, because once it reaches zero, it waits for another second before ending.

This is grade school math folks. Zero is NOT a counting number. It's the FIRST (1) combination of a bit pattern.

So for any of you programmers out there that have been using zero in this way... STOP. It's sloppy programming, and I wouldn't hire you.

shIT! (-1, Offtopic)

Anonymous Coward | about 9 months ago | (#45432351)

Good Luck (1)

puddingebola (2036796) | about 9 months ago | (#45432355)

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.

Zero-based (0)

Anonymous Coward | about 9 months ago | (#45432367)

'Why do programmers start counting at zero?' wondered Mike Hoye...

They don't. C, and its associated siblings, start counting at zero. They do this because there's no [meaningful] distinction between arrays and pointers. Older programming languages such as Fortran, which understand that there is a semantic difference between memory and arrays, and are quite happy to start their numbering at 1.

-JS

Make women *what* you? (2)

JamieKitson (757690) | about 9 months ago | (#45432375)

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 (3, Insightful)

trinaryai (949870) | about 9 months ago | (#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".

All this energy to teach programming! (0)

Anonymous Coward | about 9 months ago | (#45432417)

All this energy to teach programming but nothing is mentioned about teaching basic science and math - what is truly missing in the US educational system.

And if you think kids will pick up those skills programming, i can assure you it won't happen.

Alls not well. (0)

Anonymous Coward | about 9 months ago | (#45432425)

Look, I am happy teaching kids programming, it is a very valuable thing because it teaches many different things all in one subject, but what the hell does an index offset have to do with counting?

0 is the first index of a typical storage location, it isn't because it is useful for counting, it is because it is base10.
Ignoring 0 because it is 0 would be silly, but then you could also argue that using -1 no position would be a bad thing in the case of stuff like "In String" or "Sub String" since it uses an extra character.
If we were to use 0 for nothing in these examples, then negative values could be used for offsets from the right edge, which can be useful in some cases and sometimes faster depending on the operation you are doing.

But, it isn't, because everything else uses 0 as the first index, changing one of them to be like this would be annoying as all hell.
Keeping things standard across all functions is incredibly useful.
Making exceptions is something a shoddy PHP developer would do with that crappy exceptions-based language that it is.
I've never used such an atrocious language in my life, the amount of stupid rules for specific functions is terrible, even worse because seemingly similar functions have opposing behaviours! WHY?!
PHP, the rotting sandwich in your toolbox. You wouldn't hammer a nail with last months sandwich now, would you? Go get a real sandwich, like Perl.
If we never kept standard behaviour between similar features, stuff like PHP comes out of it. You don't want more PHP, do you? DO YOU?!

That "birthday loop" has the wrong upper end (2, Informative)

Anonymous Coward | about 9 months ago | (#45432463)

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]

What 0-based and 1-based counts mean (1)

tepples (727027) | about 9 months ago | (#45432491)

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 once matches a 1-based count.

The Article Is Self-Contradicting (3, Informative)

StormReaver (59959) | about 9 months ago | (#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.

Counting From Zero Actually Makes more Sense (4, Insightful)

physicsphairy (720718) | about 9 months ago | (#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.

Re:Counting From Zero Actually Makes more Sense (0)

Anonymous Coward | about 9 months ago | (#45432835)

Counting from zero is how our numerical systems are represented and function - be it binary (0-1), decimal, (0-9), hexadecimal (0-F) etc..

If zero wasn't a number then 10 would not be a number in any such system.

The fact that our system starts is based upon and around the representation of nothing is something many people have trouble understanding, but without it, we'd have all kinds of problems. Learning how to count properly is therefore a big problem currently, often being based on 1-10 instead, which is inconsistent.

Re:Counting From Zero Actually Makes more Sense (-1, Troll)

fredrated (639554) | about 9 months ago | (#45432869)

Flunked math didn't you? As a mathematician I won't even respond to your 'points' since you are posting gibberish.

Re:Counting From Zero Actually Makes more Sense (1)

T.E.D. (34228) | about 9 months ago | (#45432915)

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.

Simple (1)

bickerdyke (670000) | about 9 months ago | (#45432529)

Because you have to start counting SOMEWHERE.

Beyond absurd to teach programming to kids... (0)

Anonymous Coward | about 9 months ago | (#45432587)

Most don't need it and will never use it. Moreover, Zuck and other billionaires who apparently have nothing to do with their money would be far better served by making sure every kid can read at their own grade level up until they graduate from high school.

Also, since most people in the US can only read at the 6th-7th grade level, it is literacy, not the ability to program, that's one of the greatest predictors of success in life and an endeavor that would be far more logical and worthy for them to pour their money into.

Simple: Because computers do. (1)

VortexCortex (1117377) | about 9 months ago | (#45432665)

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.

If you don't start with zero it won't make sense (1)

Xiver (13712) | about 9 months ago | (#45432701)

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
...

xmod 1down (-1)

Anonymous Coward | about 9 months ago | (#45432743)

moSt people i8to a

Zero is a special case (0)

Anonymous Coward | about 9 months ago | (#45432757)

Poor programmers and people with poor maths skills frequently imagine themselves better than they are if they've had a dose of formal education.

In code, the FIRST element of an array if at offset ZERO, a fact which causes no end of bugs in much code. I can't count the number of times I've seen programs go wrong when the 'empty set' case occurs, because the programmers fail to understand that 'empty' (a form of zero) IS often a special case, not just another number like 1,2,3 etc.

At Junior school (7-11 years old), counting from zero was introduced as part of a process building to the concept of integer space, including negative numbers. But how many programmers test for zero when handling floating point values, not understanding how WRONG it is to contain precise integer values in floating point variables (and the excuse "but it works for me" only makes the incompetence worse).

There is nothing clever in dumbing down maths, and this includes the claim that counting from zero is 'cleverer' or more correct. Maths teaching has to respect a very simple principle- namely that people split into two categories.

1) Those who simply want dumb maths rules to follow by rote, and want to learn no more rules than are useful in their lives.
2) Those who want to understand mathematical principles to some degree of sophistication (most of us eventually give up at some point, leaving the really esoteric stuff to people who dedicate their lives to maths).

There is NOTHING wrong with all those people (the vast majority) who place themselves, or are placed by inherent mental limitations, in category 1. However, people who have an inclination for category 2 should receive an education at school that gives them maximum opportunity to explore their interest in maths.

HOWEVER, I find that it is category ONE people who over-rate their ability, who dribble on about higher maths understanding being essential for EVERYONE. This falls under the old saying "a little knowledge is a dangerous thing".

Re:Zero is a special case (1)

Joining Yet Again (2992179) | about 9 months ago | (#45432893)

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 have two orders of magnitude clock speed increase.)

HUMANS count from zero! (0)

Anonymous Coward | about 9 months ago | (#45432927)

Not just programmers!

When a car comes off the assembly line, is the mileage set to 1 mile?

When a stopwatch is reset, is it set to 1 second?

Is the far left edge of a ruler set to 1 inch?

If you empty your bank account, do you have 1 dollar?

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>