10 ms·
You're supposed to start out by teaching them pointers. Once they fully understand how pointers work, you move them on to Hello World so they can write their fi
by bachmeier 6y ago
You're supposed to start out by teaching them pointers. Once they fully understand how pointers work, you move them on to Hello World so they can write their first program. Then it will be intuitive when they see 0-based indexing. I think that's the HN consensus on teaching kids how to program.
- djxfade 6y agoI don't think a lot of beginner friendly languages exposes pointers to the developer
- randomdata 6y agoUnless they have arrays, which are conceptually not a whole lot different.
- mewpmewp2 6y agoMost of the time you don't use them or think or need to think of them as pointers.
- randomdata 6y agoNo, but pointers are thought of as array indices. If you understand arrays, you understand pointers.
- mewpmewp2 6y agoWhat do you mean by understanding? E.g I have been using arrays productively in PHP and JavaScript, does it mean I understand them?
- randomdata 6y agoIf, given a[n], you understand that n points to a position in array a then you understand pointers.
- deleted 6y ago[deleted]
- wiz21c 6y agopointer is an implementation detail. No one should have to learned that first.
- canadianfella 6y agoHow is it possible to miss sarcasm like this?
- tpush 6y agoA pointer (or reference, or just 'address') is a general concept that by definition is part of any language featuring mutation. Any language that makes use of mutation for primitive constructs (not saying that's the case here specifically) needs an understanding of "observing/causing change" pretty early on.
- improbable22 6y ago> is a general concept that by definition is part of any language featuring mutation. One counter-example is Mathematica. I can mutate any object any time I like, and doing so is extremely common. Yet under "pointer" its help tells me about some unicode symbols, and some GUI stuff about mouse pointers. In reality, some of its lists are dense memory like C, some contain arbitrary objects (such as expressions, or high-precision numbers), but these implementation details aren't part of the language, and most users never know them.
- tpush 6y agoThe specific word or implementation isn't important. In Mathematica's case (and most other languages, sadly), presumably the concept of 'variable' is overloaded with the semantics of a pointer/reference. Meaning, you cause and observe changes to locations via a variable.
- tremon 6y agoMathematica is also not a low-level programming language. It's math-based, so it deals with abstract concepts, not concrete hardware implementations. 0-based arrays are based on hardware implementations; 1-based arrays are based on abstract collections; you could make the argument that 0-based arrays are a leaky abstraction, but the question then becomes: what abstraction? C explicitly tried not to abstract away the underlying hardware.
- stabbles 6y agoThat's great advice for a kid learning python. "Kid, let me tell you about pointers in C, then you'll understand we you have to write range(1, 13)"
- me_me_me 6y agoThat's an excellent idea! We should also teach them quantum physics so instead of questioning programing language flaws they would question reality. Another problem solved. I think we are on the track to create a perfect programmers factory.
- smitty1e 6y agoI was going to go with "bi-stable circuits, building up to half-adders", but you leapfrogged me there adroitly.
- TuringTest 6y agoIt's plank-sized topological-connected vibrating goo all the way down.
- taneq 6y agoHonestly a lot of the confusion that I've seen in novice programmers over the years comes from the fact that nobody explained to them (1) that a program is a set of instructions that are executed one after the other by the computer, and/or (2) that memory is like a long line of boxes, each of which can hold a byte. Once someone understands (2), pointers are incredibly simple and obvious.
- scythe 6y agoI have been surprised several times, when helping people to write "their first program" (which, in science, isn't that rare), that it can take days to internalize the relevance of ordering statements in a program. It's deep in every coder's subconscious that the bottom line depends on the top one and not the other way around, and I have had to consciously restrain myself from saying "whaaaaat?!" when I saw how my colleague tried to do something.
- Jtsummers 6y agoI'm glad you've learned to restrain yourself because that mistake makes sense if you're not used to imperative thinking. It doesn't benefit students to have instructors who are shocked by common/natural errors. Math, as commonly encountered, is a collection of facts and relations. Their notion of variable is very different than in CS and programming. To a mather (one who uses/does math), this makes sense: x = 7 * y y = 6 therefore x = 42 To a coder (of most conventional programming languages) that's an error, y is undefined when x is assigned a value. And even if it did have a value, changing it later wouldn't change x so who knows what x could be. It makes sense to the mather because each statement exists at the same time. To the coder, each statement is realized over a period of time. To the coder "y = 6" hasn't happened yet when "x = 7 * y". This is the part that has to be communicated to the novice with a mathematical background.
- jcelerier 6y ago> You're supposed to start out by teaching them pointers you can just show them a ruler and ask them where does the first centimeter starts
- HPsquared 6y agoVery nice, I'll steal that.
- eutectic 6y agoOr give the example of birthdays; in your first (initial) year of life you are 0 years old.
- gerdesj 6y agoThere's a difference between a cm being the thing that exists between the lines with 0 and 1 against them and the distance that is 1cm. Indexing is within the scope of the first definition. You might as well ask where the 0 or 1th element in an array starts and finishes.
- coldtea 6y agoAnd they'll see that rulers are broken too, they should start with 1 instead!
- doodpants 6y agoTo which they should cleverly reply, "Aha! You said 'first' centimeter, not 'zeroth' centimeter, thus defeating your own argument."
- ycombobreaker 6y agoDoesn't that just demonstrate your (edit: the teacher's) point exactly? The first centimeter starts at 0. The first array element starts at 0.
- deleted 6y ago[deleted]
- erostrate 6y agoI can't tell if this is a joke or not.
- auxym 6y agoIt has to be. Right?
- laichzeit0 6y agoIt's hilarious that people are taking this comment literally. HN comedy gold. Reminds me of when I was working with a German work college and he just could not pick up on English sarcasm.
- valvar 6y agoI thought it was a pretty obvious joke, but then I saw lots of people seemingly seriously agreeing, so now I'm not so sure.
- userbinator 6y agoThere's two groups of programmers, those who started learning with low-level, and those who started with high-level languages. I'm personally in the former group, and think there are definite advantages to doing it that way. You are probably in the latter.
- valvar 6y agoSure, for adults, that's fine (but I still disagree with the approach, as pointers are a notably tricky concept that really isn't necessary in the beginning). But it's like saying that before teaching a kid addition and multiplication they should understand the Dedekind–Peano axioms -- it's simply overkill and more likely to discourage them than anything else. (But it depends on age and aptitude, of course, so obviously YMMV). FWIW I started with K&R, but times have changed and I definitely don't think it's a pedagogically sound way of teaching programming.
- gjm11 6y ago
- Dirlewanger 6y agoThat's how they used to do it in universities back in the 80s/90s. Start out with the hard stuff first in Intro to Computer Science. By the end of the course, you'd go from 400 people to about 50. Wish they'd still do that to keep numbers low.
- dotancohen 6y agoYou are going to get downvoted to hell for "gatekeeping" but you're right. Instead of just graduating 50 people who "get the trade", we're now diluting them with another 350 that "made the grade". Then tech firms need wild, crazy interview processes to sort them back out. Everybody suffers, including the 350 who may have been productive and happy in another, more suitable profession.
- Dirlewanger 6y agoAnd it's weird that people see it as gatekeeping, since there's plenty of other professions out there that artificially restrict supply, and no one raises a sthink about them. People do about software because we work online and are constantly giving opinions no one asked for. It's less about gatekeeping, and more about sustaining a healthy industry that is quickly headed for a disastrous race to the bottom. Google and friends are spending billions under the magnanimous "bringing coding to everyone" when they really just want to lower developer salaries. Not everyone needs to learn how to code, just like not everyone needs to be a doctor, or learn how to be a carpenter. I constantly wonder when will be the right time to "get out" before salaries start their inevitable side downwards. Could be a couple decades though.
- tzs 6y agoAlthough doing it "to keep numbers low" doesn't seem to me to be a good reason to do it, it is generally a good idea to have some hard stuff early in a field. The idea is that if the hard stuff comes too late, people might not find out that they aren't really suited to that field as a career until it is too late to change majors without having to take an extra year or two of college. The intro class is too early for that, though, because CS is useful enough for other fields that many people (perhaps even a majority of people) taking intro CS don't intended to actually go into CS. Better is to put it in the first class in a field that will mostly only be taken by people who are intending to go into that field.
- globular-toast 6y agoI agree, but Python doesn't have pointers. So I agree with your parent that Python isn't a good language for teaching. Unfortunately teaching languages that are good for learning, like Scheme or Pascal, went out of fashion a long time ago. For years now universities have been teaching marketable languages. Ten years ago that was Java. Now it's Python.
- teamonkey 6y agoIs this before or after teaching category theory?
- psychoslave 6y agoJust forbid them to read Principia Mathematica. All of them.
- coldtea 6y agoMonads should make the list too... Also trampolines. Kids love trampolines. From there it's a simple jump (pun intended) to something like the Y-combinator!
- psychoslave 6y agoWhat? I thought first they should go through TAOCP in integral. They should be grateful if you allow them to use MMIX instead of MIX.