March 30, 2009

Credo

It has been suggested that certain programming language constructs, in particular the GO TO, lend themselves to obscure coding practices. Some language designers have even gone so far as to design languages which purposely omit such familiar constructs as GO TO in an attempt to constrain the programmer to refrain from particular styles of programming thought by the language designer to be "bad" in some sense. But any language with function calls, functional values, conditionals, correct handling of tail-recursions, and lexical scoping can simulate such "non-structured" constructs as GO TO statements, call-by-name, and fluid variables in a straightforward manner. If the language also has a macro processor or preprocessor, these simulations will even be convenient to use.

No amount of language design can force a programmer to write clear programs. If the programmer's conception of the problem is badly organized, then his program will also be badly organized. The extent to which a programming language can help a programmer to organize his problem is precisely the extent to which it provides features appropriate to his problem domain. The emphasis should not be on eliminating "bad" language constructs, but on discovering or inventing helpful ones.


Guy L. Steele Jr. and Gerald J. Sussman
Lambda - The Ultimate Imperative

7 comments:

grant rettke said...

You should block-quote that passage; or are you paraphrasing?

grant rettke said...

Great paper.

Pascal Costanza said...

Grant,

You're right, I have block-quoted it now. Thanks a lot for the hint!

Slobodan Blazeski said...

Low level constructs are great tool for transformation written program. Whenever you need to squeeze last bit of speed you could use such constructs or even better macro tarnsform toward the. Let over lambda chapter 7 has some very good examples.

Astrobe said...

In the end, most constructs are goto-based. Why for-loops, while-loops, switch...case, break, continue, instead of GOTOs? because they are more convenient and limited forms of GOTO, so they are far less harmful.

I also agree with you: one cannot prevent someone from writing bad code, but one can help with writing good code, or at least the langage should not prevent one from writing good code.
There still is some construct to be invented to help giving a better answer to some problems, like error handling for instance (if you read french, see my blog).

lele said...

Modern languages do allow for forward GOTOs at least. Nowadays people call them "exceptions".

lele said...

However, if bad programmers can write bad code without gotos, imagine what a mess they could generate if they had gotos available. Because bad programmers usually lack the skills to work around limitations of the language they are using.