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:

Blogger grant rettke said...

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

16:07  
Blogger grant rettke said...

Great paper.

16:07  
Blogger Pascal Costanza said...

Grant,

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

16:26  
Blogger 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.

12:14  
Blogger 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).

13:38  
Blogger lele said...

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

12:19  
Blogger 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.

14:31  

Post a Comment

Links to this post:

Create a Link

<< Home