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-18 20:04

C-style (null-terminated) strings are retarded. Many operations on them are O(n), which would be O(1) with Pascal-style strings. Imagine what strcat does in the general case:

* Find length of string A (O(n))
* Find length of string B (O(m))
* Allocate lenA + lenB (depends on allocation scheme)
* Copy string A (O(2n))
* Copy string B (O(2m))

Strings that start with a size byte or int (Pascal-style) reduce the first two to O(1).

Furthermore, null-terminated can't contain anything that might contain nulls, which you'll know is a useless if you've ever operated on binary data. And for the finishing touch, it's a lot easier to overrun the lenght of a null-terminated string (forgot that null? whoops!), leading to stupid flaws and possible security vulnerabilities.

The reason we're stuck with a default string library that's gay like this? The PDP-fucking-11. Awesome 1970s Batman!

Pascal-style strings are simple to implement. All they are is:

typedef struct {
  int length;
  char *array;
} string;

Or you could use a sane system language that uses them by default, like D, or even C++'s STL.

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