2013-01-10 Why did Dijkstra Hate Basic?

Dijkstra is an emminently quotable computer scientst, mostly for his famous lists of uncomfortable truths. Oft repeated is his rallying call against BASIC, most of the time without context–

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

The essay itself was arguing “How do we tell truths that might hurt?”, when commonly accepted problems are shrugged off or avoided. The answer turns out to be rather inflamatory. Dijskstra was so effective at raising his arguments this way that we’re still arguing about them now.

The thing people forget is that programming was substantially different in 1975. Dijkstra railed against Dartmouth Basic—a glorified assembler language. It isn’t the BASIC used today–

Variables names were one letter long with an optional digit

Although FOR was present - while loops, break and other niceties were implemented with unrestricted goto.

Whitespace was optional between expressions.

Subroutines were available. GOSUB line number and RETURN.

All parameter passing had to be done with the existing global variables.

26 user defined functions could exist FNA-FNZ, which could contain one line of code.

IF statements were also limited to one line of code.

I could go on about the limitations, but the consequecnes are pretty obvious: It was hard to write readable and understandable code in. The features we take for granted now just weren’t present. It wasn’t until after the article that BASIC began to grow up, into the language people know today.

When you learn your first language, you continue to write programs in that style in other languages (“You can write FORTRAN in any language”). The hardest part of growing as a programmer is not accquiring new knowledge, but unlearning old habits in light of it.

Learning to carefully assemble a large ball of mud doesn’t help you to write structured programs. Even today, it would be easier to teach someone a modern variant of basic if they’d had little or no exposure to its grotesque ancestor. Although some sucessors still have a lot to answer for.

Programming is hard. Making it harder doesn’t help beginners, or experts alike. Dijkstra hated basic, but you would probably hate it too. It is a shame that Dijkstra is most remembered for his vocal criticism rather than his vast contributions to programming, but that is another issue altogether.