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-20 19:06

>>53
Well well, status dropping. I've been using C from 1995 onward on a hobby basis (i.e. demo programming and such).

As for your challenge, let's start with the obvious: zero-terminated strings are a nice thing to have, because a pointer to the middle of a zero-terminated string is exactly as good a string as any other. That is to say, O(1) head, tail and drop operations (where "tail" is obviously just "drop 1") though you still need to manage memory on your own. Arbitrary slicing that doesn't collapse to head, tail or drop is still O(n) where n is the length of the slice. Under some circumstances (parsers come to mind), this is not only rather intuitive but also relieves the programmer from having to create and then destroy a slice copy of the string being processed.

Another, just because I'm feeling like it: it's trivially simple to write a routine that takes character data read from a file, replaces all instances of the line feed with a '\0' and stores the appropriate pointers in an array, thus making for a line splitting function which allocates no extra memory for the resulting lines.

I'd rather like to hear what the matching idioms would be, if strings in C were length-prefixed rather than zero-terminated. Both of these examples assume that no garbage collection is being used; I think this is reasonable given that neither C-the-language or C-the-library require nor specify any such thing.

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