It is a universal truth of the ancient world of Limited Bits of which modern laypeople have no knowledge. Back in the days when memory was 64K, we had to be very economical about how we used each precious bit. A byte* can count from 1 to 255. But we would like a clever way to count more things, so we pretend the zero is a counting number so we can stretch out this one byte to count 256 things. One of the things we love to count is locations in memory. That lets us have 256 bytes in memory instead of merely 255. This leads to things like the 0th byte in memory. Such thinking also leads to C arrays that start with the 0th element, because array elements are, under the covers, just memory locations. Even in today’s modern world of 12G of RAM and buying a terabyte of storage for you home computer for $100, we continue to seek this economy because the computer programmers who grew up in the Great Depression know it’s a sin to waste bits.
However, I cannot abide the cuteness that the author used when he started my computer science textbook with Chapter 0. :rolleyes:
*Well, technically, a word. But let’s keep it simple for illustrative purposes.
I have absolutely no clue. I mean, I actually do this and don’t notice it until I reread the post later. I have no idea why.
Well, for arrays it makes a certain amount of sense
TECHNOGEEK SHIT AHEAD:
If you take an array (called Array) as a contiguous section of memory where each member is <n> bytes, and have a zero-indexed array, starting at address <a>, the address of its <k>th element can be accessed by the expression a + n*k
So the zeroth element is at the address a, that is, the beginning address of the array, which makes a certain amount of sense. (This logic also makes it easy to do multidimensional arrays, e.g. an array with k rows and l columns and so on).
Sure, if you want one-indexed arrays you can just use a+n*(k-1), but why bother with the extra subtraction? I suppose in some/most cases you could do some compile-time trickery, but then you have to ask yourself why you’re so insistent on 1-indexed arrays and if the extra hackery is really worth it.
My wife and I are on vacation and today we stopped in an antique shop that had a book on how to teach math (from about 1960). I regret not buying it (for a whole $4.00), since it might help me with my computer science teaching. I’d like to know if there are any good books out there that teaches how to teach programming?
I too have difficulty with beginning programmers not grasping loops and arrays. One thing that helps is we introduce programming using Java (using just procedural programming), then follow that with a course in C/C++. Several students have said to me that learning the second programming language was when their brains clicked and they picked up what arrays and loops are doing. It’s similar to my experience in learning a second language; English grammar became much clearer after I learned a foreign language (German) in high school.
A lot of people do this too! It’s always bugged me.
Somewhat similar, I knew this woman who would spell out some numbers and put the digits for others, with absolutely no rhyme or reason to it. I mean, she would really write things like, “There were 22 people there today and twenty-two yesterday also.” She did this all the time.
I hate to say this but I wonder if it is worth the bother. Programming is basically a talent that you have or you don’t and I don’t think you can teach it in any real way. I have always made my living as a Systems Analyst/Developer usually for megacorps and I have seen too many people both onshore and offshore (almost always India) that learned enough programming in school to get a job but still didn’t understand it at a fundamental level.
We don’t need any more of those because I have to help identify and fire them all time even though they are supposedly doing their job even though they really contribute nothing. It is like teaching everyone to play the violin. You don’t need very many to form an orchestra and every other player is just a dead weight after that.
I am convinced that it isn’t their fault. Most of them are very smart in other ways and hardworking but they just can’t think like computer systems do. You really need to be able to run simulations in your head just like the systems you work on do just given a rough verbal description.
There are very few people that are truly good at that but the ones that are can be easily identified and given the true responsibilities. Almost all of the true work comes just from the talented few. The rest are a net drag on the whole process. You would be better off coming up with ways to identify those talented few in advance and giving them the vast bulk of the true design and implementation work. There would still be some tasks left for those that just learned what they learned in school but it wouldn’t pay nearly as much and there is already a glut of those.
In my single formal role as a teacher I was working with a class of mostly 13 year old girls. It was part of a mentoring program circa 1983 and the schools had nothing for them. To teach them loops and arrays we played the Program Counter game. Never mind the name, it worked by giving each student a command to execute in a simple program, and then pass their result to the next person in line. The ones doing the Ifs and Loops had to do the work of deciding who to go to next. By having students write the changing values on the board, and fill in a grid on the board with array values as things moved along. They were able to pick up loops, nested loops, and even a simple sort. Now these kids were pretty bright, though evil, but it interested them, and they liked doing it.
I’ve found in general that explaining loops works better by seeing graphic represented results as you go through all the steps of the loop repeatedly.
(This is something like the forth time this has been quoted. Is there a prize for that?)
I was taught the best way to survive traffic on a bicycle is to obey traffic laws. Stop at red lights, show intentions, etc. Therefore being on the wrong side of the road would be all sorts of wrong. That would get you killed on a road I used to ride on. Cars would come around tightish corners “blind” and tucked in… They’d be sure to hit you.
I’m not too troubled by cars coming up behind me. It’s a rarity for me not to hear them approaching.
If you have to ride in the street (and there’s not a dedicated lane for bicycles) how is riding, facing traffic, a bad idea?
Way back when I did ride a bicycle on city streets, that’s how I rode.
And it saved me from getting run down/sideswiped, more than once.
ETA: I take it you haven’t done a lot of bicycle riding on inner city streets, have you? :rolleyes:
By the time you’ve heard a car approaching from behind you, on the average city street, you’re not going to have time to ascertain whether or not the driver of that car notices you.
Countless times, I’ve realized that the approaching vehicle/drivers attention was not where it should have been, namely, on the road.
The fact that I was facing traffic enabled me to ‘bail’, just in time to avoid being hit. Had I been on the ‘right’ side of the road, hearing the vehicle approaching and getting hit, would have been nearly simultaneous. :eek:
Er, if you are riding *in *the street and *not *off to the side in a bike lane, and are riding facing traffic, then you are riding against oncoming traffic in the wrong lane.
I can’t imagine why that may not be the best idea.
Seriously? You don’t see how two vehicles approaching one another head-on could be a bad thing?
If I’m driving, and you’re on a bicycle in the same lane going the same direction, I have the option of going around you if there’s room to do so, or simply slowing down and staying behind you until I can safely pass. If you’re coming at me, I can’t do the latter, and I may not have room to do the former. So what am I supposed to do, to avoid a collision?
As a bicyclist, you’re part of traffic, and you’re supposed to obey the rules of the road just as other vehicles are.
How could you know this? If you weren’t riding against traffic, you wouldn’t be in the same situation.
Because the guy pulling out of the driveway and turning right will never see you as he is looking left which is the direction traffic is supposed to be coming from.
Riding the wrong way is one of the 3 stupidest things you can do in a bike.
Many drivers look both ways before pulling out of a driveway. Bicyclists, pedestrians, fire-trucks, running dogs (imperialist capitalist or not) etc: all can come up from the other side.
But the hell of it is that, at one point in time at least, this was taught! I HATED my old Driving Training instructor in High School because of this. The sodding stinkard actually taught, “Look left, turn right.” I refused: I looked left and right and turned right. Every driver I’ve ever been with does also.
So the hell of it is, even if you do it right, some jackass driver might do it wrong, and still hit ya!
There’s some evidence that you can tell pretty easily who will learn programming by giving them a simple test before they start studying it.
It had questions like:
After this program
x = 10
y = 20
x = y
What are the values of x and y?
With choices all over the place.
What’s important is not that you know how a given programming language works, but that you establish and stick to a consistent mental model. Like, maybe you think that x = y means to average x and y, so they’re now equal (each with value 15). As long as you consistently apply the variable = variable operation resulting in both being equal to the arithmetic mean, then you can learn to program.
A significant number of people can’t seem to do so. And didn’t learn to do so after several weeks of the class, either. That doesn’t mean it can’t be taught, but it does mean that some deeper understanding needs to be achieved before you can start talking about syntax and iteration.
A number of my computer science students say the reason they chose that major is they are serious gamers. I can tell within a few weeks who really “gets” programming versus those who struggle for their entire first and second semesters (and possibly drop).
During the year I explain how useful a tester’s job is, and that might be a more viable job for them. They seem to understand testing is like pushing the limits like playing a game. On the other hand, I just can’t understand why game playing is fun or worthwhile. To me, it’s like the difference between reading a novel versus reading a work of non-fiction; I simply think reading novels are a waste of time.