Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Teaching programming h;lp

Name: Anonymous 2006-09-18 11:08

I'm going to teach programming to somebody who's going to study it more formally in a year, but wants to be learning part of it in the mean time.

What SIMPLE, CLEAN, STRUCTURED language would you recommend me to use for teaching? Please, refrain from language wars as this is not a fanboy thread but a serious question. Before yuo mention it, I'm not going to start with either Python or Ruby because they're too complex and get too much in the way, and no, I'm not stupid enough to start with Java because a radical OO language (and a crappy one at that) with a shitty enterprise API is not the best either.

I'm thinking Pascal. As much as it sucks, it has strict/anal types (it's better to start anal than to start easy-going and botch it), simple yet not messy syntax, simple stdin/stdout input and output to play with (that's all I'll need), and none of the complexity of OO. Yet it sounds so useless. But I don't know of other languages that meet these requirements.

Name: Anonymous 2006-09-19 11:23

>>17 >>22
Oh I call bull on this shit. All operations on strings are O(n). There's a library called Ropes (that comes with the Böhm GC), which provides for crazy things like an O(1) strcat (since it just makes a string head structure which contains the two other strings in a left-right reference fashion), but even Pascal-style strings require a O(n) strcat. Don't believe it? Copying everything from string A and string B into string R depends on the lengths of string A and string B. Therefore, O(lA+lB), which is O(n); indeed, O(2lA+2lB) would be O(n) as well. Habeeb it.

And before the peanut gallery chimes in about "BUT BUT BUT TWICE AS SLOW!", allow me to introduce you to cache miss latency. On a minty-fresh Intel processor, one L2 cache miss is going to cost you far more (that is to say, ~200 cycles on a 2.4GHz P4 at minimum) than a few redundant strlen()s over strings of lengths typical to an average C program! Profile first, kids. Better yet, use a memory profiler like cachegrind before you scream omg slow. Bestest yet, remember that the best optimization is that which moves a program from a non-working state into a working one!

For what it's worth, no Pascal-like language implementation that I know of uses a rope-like data structure for strings. Ropes are ropes and strings are strings.

All that said, perhaps it would be a passable idea to teach programming with something simple that >>1-san can understand. Like BASIC for instance, or Python -- both of those are wonderful for simple and trivial examples that don't need to grow up into real programs.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List