Pros and Cons
i’ve spent most of this Day of DH thinking about the pros and cons of programming languages, but not in the usual way. You see, I’m thinking of writing my own.
Really? Another programming language?
There are pros and cons to every language, of course – debating that is a contact sport on Hacker News and various other geeky sites I frequent. But I’m thinking more about the fact that (a) most programming languages are designed for pros and (b) the idea that learning those languages is easy is a big con. Programming is hard. Full stop. And it’s made harder by the fact that language designers seldom (and all things being equal, shouldn’t) have beginners in mind.
What I have in mind is a language that has the following features:
Brutal consistency. Those “pro” languages break consistency in favor of concision. “Everything is an object” in Ruby, for example, but some methods (functions?) are attached to mysterious unseen objects. The reason is obvious: You can print “Hello, world!” by typing “puts ‘Hello, world!’” But as we soon as we’ve offered that convenience, we’ve introduced an inconsistency that is confusing to beginners (I think).
Brutal verbosity. Global vs. local variables is a good example. If you’re an experienced programmer (one of those “pros”), lexical scoping, say, seems easy enough. It baffles beginners. So why not demand that when a variable is declared, its scope is declared as well: “let global x = 2”. We wouldn’t stand for that in a mainstream language, but what about a language aimed at beginners? Wouldn’t it be better to make everything as explicit as possible?
Enough batteries to do your homework. A language aimed at beginners doesn’t need facilities for dealing with udp packets; what it does need is a standard library big enough to facilitate the study of basic algorithms and data structures. The Python API isn’t “too big” and the C API isn’t “too small” for a pro, but somewhere in the middle is an API that gives students just enough for learning how to build programs out of all the various pieces.
Sugar free. Whether “expressive-ness” is a good or a bad thing in a language is subject to debate. But when it comes to first language learners, I’m convinced it’s a Bad Thing. Having six different ways to write a loop makes it harder for students to read other peoples’ code. This is one thing that Python gets right, though I’d want to go even further. In my dream teaching language, a switch-statement is already too sugary.
Well, I already regret everything I’ve just written. Who knows what I’ll write, or whether the whole thing is totally wrongheaded. But for the last week, I’ve been dusting off books on compiler theory, and in every spare moment I’ve been dreaming about my ideal teaching language.
And that, my friends, is what I’ve done with my Day of DH.