Newsgroups: comp.lang.lisp,uk.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!pipex!dircon!rheged!simon
From: simon@rheged.dircon.co.uk (Simon Brooke)
Subject: C vs LisP yet again (long but thoughtful)
Message-ID: <CwI0Ly.3Av@rheged.dircon.co.uk>
Organization: none. Disorganization: total.
Date: Wed, 21 Sep 1994 21:20:20 GMT
Lines: 163


doner@aero.org (John Doner) wrote
	In article <os2Psc1w165w@sytex.com>, Scott McLoughlin 
	<smcl@sytex.com> wrote:
	>I'm still _VERY_ curious (concerned?)
	>about why Lisp isn't more popular in "the trenches".
	...
	>        So why don't folks use Lisp to write this stuff? Blazing
	>speed,space,etc. aint that critical. What gives?

	I posed a similar question to the comp.lang.dylan newsgroup a couple of
	months ago.  I received many interesting replies which I haven't yet
	fully digested.  Reasons having to do with availability, popularity,
	vendors' support, what they teach in school, etc., are common, but
	really beg the question because they don't explain why C got there in
	the first place.  None of them can explain why C won out over Pascal,
	for example.  My latest theory is that the answer lies in cognitive
	effects arising from the conception and structure of the language.
	People make up mental models of how things work, and interpret the
	programs they write in terms of those models.  For experienced
	programmers, compiler writers perhaps, these models are complete and
	accurate, closely corresponding to the objective reality.  Novice
	programmers have poor models that are incomplete, poorly related to the
	actual computing machines, and perhaps even inconsistent.  The
	intellectual effort required to develop a good model for Lisp or Ada is
	much greater than that required to develop one for C.  There are more
	abstractions involved.  Thus, C is more easily comprehended by
	inexperienced programmers.

	I invite criticism of this theory.

	John Doner

I don't think John's right, and offer an alternative view as follows:

(i) Why is C popular

C is a language designed by some very bright people to solve real
problems which they really had, in days when horsepower was expensive.
It is a very low level language, and as such is suitable for
down-to-the-metal/silicon tasks such as device drivers; at the same
time, unlike its predecessor BCPL, it has (rather primitive and
fragile) high level constructs which allow skilled and careful
programers to build very sophisticated things with it.

Again, the software industry is inherently conservative. Commercial
software teams are led -- and development languages chosen -- by
people whose training is decades out of date. So commercial choices of
language now depend on what was current in the undergraduate courses
of the seventies, not on what is now being taught. Look at the adverts
for CoBOL jobs -- industrial archaeology rules!

Furthermore, C is the language of Unix. Not only is the operating
system written in C, but until very recently the full set of C
language tools came free with the operating system. Because many of us
learned our trade on Unix, and the Unix gurus were the people we
looked up to, C tended to be the language we learned first.

Finally, in the context of a machine with an operating system
optimised for the sort of programs the C compiler produces, a trivial
program, written in C, loads and executes quickly. The same program
written in a high level language will require to load the whole
operating environment for that language before it can run. By
contrast, on a LisP machine (such as a Xerox D series, a Texas
Instruments Explorer, a Symbolics, or a LisP Machine) the program
written in LisP would load and execute quickly, and the C version
would be a pest. However, because most of the current generation of
operating systems are C based, many people have forgotten that that is
a technical choice.

(ii) Why C is no longer a good choice as a general purpose language

The problems C was written to solve are problems which we don't often
face any more. C's great merit is that it is small, and creates small
executables. We're no longer tight for space. C's next merit is that
it's easy to write to the silicon. Most of us no longer work at that
level. C's third merit is that it produces tight code. Horsepower is
no longer expensive.

C's great demerit is it's primitiveness. As an example, the C
programmer spends much of his time manually allocating and
deallocating store. This is skilled work because errors are easy to
make, are unlikely to be detected at compile time, and will lead to
unpredictable but often fatal errors at run time. In this sense
programming in C is very much more like programming in assembler than
programming in a high level language like LisP or ProLog. The
programmer has to think, not about what he wants to do, but about the
technical details of how the machine will do it.

In summary, C is efficient on machine resources but inefficient on
human resources.

(iii) Why people perceive LisP as difficult

(I'm not going to theorise about Dylan or Beta because I don't know
them. But I've taught enough people LisP (and ProLog) to know what
happens.)

Few people come to LisP as their first language. Most people find
their first language difficult to learn, because, as John says, they
have to form a model of what goes on inside the machine, and that is
initially difficult.

Because people invest so much effort in developing this mental model
of computation, they wish to transfer it to a new language when they
learn it. My own progression was BASIC -> Pascal -> BCPL -> 6502
assembler -> LisP -> ProLog-> C. For me the steep learning curves were
BASIC (to learn to program at all), LisP (to switch from imperative to
functional programming) and ProLog (to switch to declarative
programming, which I still don't feel I've really mastered).

However, my experience of teaching LisP is that people who have never
previously used any programming language learn quicker than those who
are converting. But the intellectual effort to learn LisP should be
much less than learning an AlgoL or ForTran family language (Pascal,
BCPL, C, BASIC...) because the language is so much simpler and more
consistent. (No, before you flame, CL is neither simpler nor more
consistent than anything else. It is the most arbitrary, baroque,
incoherent dog's breakfast of a language ever to come out of anyone's
most turgid nightmare. But CL is neither the beginning nor (I hope)
the end of LisP).

Oh yes, that's another serious point. For ***'* sake don't start
anyone LisPing with the aluminium book abortion. Start them on a small
elegant LisP like Scheme or XLisp or even good old PSL. As Arthur
Norman put it, 'aluminium books rot brains'. It (CL and CLTL both)
must have put more people off the language than any other factor.

Conclusion

Most people who are seriously interested in software study computing
at college or university where they typically learn an AlgoL family
language (C or Pascal) first. They find this language adequate for
most of the tutorial problems they tackle, and when they attempt a
radically different language they find the skills they've learned
don't transfer.

By the time they become really skilled, they can tackle more or less
any computing problem in their language of choice, so don't need to
transfer. 

However, I'm one of the people who have chosen to transfer.  My
language of choice is LisP. This is because I value my time:
programmers are expensive, silicon is cheap. Or, to put it another
way, people are more important than things.

I'd be interested to know how many students from those colleges which
as a matter or practice teach a LisP variant *first*, later *choose*
to switch to an AlGol family imperative language. Has anyone done any
relevent research?

PS could anyone out there still using a pre Medley version of
InterLisP please mail me the value of the atom CAR? My memory is that
it is #SUBRxxxxxx, where xxxxxx is a hex number. I want it for a
bumper sticker (you know, 'my other car is #SUBRxxxxxx').


-- 
    .::;====r==\              simon@rheged.dircon.co.uk (Simon Brooke)
   /  /____||___\____         
  //==\-   ||-  |  /__\(      MS Windows IS an operating environment.
 //____\___||___|_//  \|:     C++ IS an object oriented programming language. 
   \__/ ~~~~~~~~~~ \__/       Citroen 2cv6 IS a four door family saloon.
