Newsgroups: comp.lang.lisp
From: cyber_surfer@wildcard.demon.co.uk (Cyber Surfer)
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!udel!gatech!howland.reston.ans.net!news.sprintlink.net!demon!wildcard.demon.co.uk!cyber_surfer
Subject: Re: Why do people like C? (Was: Comparison: Beta - Lisp)
References: <os2Psc1w165w@sytex.com> <35dcf9$jao@news.aero.org> <CwJ82u.7nL@csfb1.fir.fbc.com> <Cwsvrs.Dtv@cogsci.ed.ac.uk>
Organization: The Wildcard Killer Butterfly Breeding Ground
Reply-To: cyber_surfer@wildcard.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27
Lines: 105
Date: Thu, 29 Sep 1994 07:12:09 +0000
Message-ID: <780822729snz@wildcard.demon.co.uk>
Sender: usenet@demon.co.uk

In article <Cwsvrs.Dtv@cogsci.ed.ac.uk> jeff@aiai.ed.ac.uk "Jeff Dalton" writes:

> >C's conceptual machine model is similar to that of the most common
> >beginner/teaching languages, BASIC and Pascal, without many of the
> >limitations of those languages. 
> 
> I'd be interested in hearing what people think this conceptual
> machine model is.  I suspect that Lisp could be explained in 
> terms of that model or one fairly similar to it.

That's exactly how I think of it. Perhaps that's coz I've sent too
long programming in C/Basic/Forth/etc, but I don't have a problem
with that. I recall that I adapted to "Lisp" very quickly, just as
I seem to with any language that's new to me.
 
> I also wonder how people learning C understand certain things.
> For instance, if a variable has type int, there are a couple
> of ways to think of this:
> 
>   * It ensures that you can assign only ints to it.

Um, doesn't the compiler ensure that the result of an expression will
be coerced to an int, if that's possible? If it's not possible, then
the compiler complains. I don't know what CL is supposed to do, as
that's never been clear to me, even after reading CTtL1/2. I assume
that it's handled at runtime by the interpreter, but I've no idea
what the compiler is suppoed to do about it.

>   * It says how to interpret the bits at the address that corresponds
>     to the variable (including how many of them are part of the var's
>     value).

I'm also unsure about this. If I were to declare than a variable
is of a certain type, like (string 20), what would the variable's
bytes look like, on a CPU with 8 bit bytes and byte addressed
memory? That's a matter for the implementation, but the semantics
are unclear to me. What if I were to assign a literal string of
21 chars, or the value of an expression that may sometimes produce
a string with more than 20 chars?

I know, Steele's book isn't enough. I should read the ANSI CL doc.
I would, but it's too big for me, so I don't have a copy of it.
Hopefully, it'll someday be available on a CD-ROM, along with
any other useful Lisp documents (like CTtL).
 
> BTW, there's a clash between Basic and C when it comes to strings.
> Strings are much easier to deal with in a good Basic (to my mind, at
> least), but the required machine-level model is fairly complex.

Arrays are similar. In interpreted Basics in the early 80, I could
redimension an array at runtime. In a compiled Basic for the same
dialect, the array would have to be statically dimensioned. There's
no really good reason for this, but that's how compiler writers
chose to do it.

> I don't think lists have to be harder to understand than that,
> and I suspect they're easier.

No harder than arrays, but probably a lot easier, but that might
depend on the how the language is taught. One of the several books
I have on Prolog is incredibly bad at explaining unification, but
I know it can be done better, because of the other books I have.
 
> Do novice programmers normally study the hardware instruction set?
> That sounds like a rather hacker-like set of novices to me!

When I began programming, Basic was all I knew, and I thought
of the machine as running Basic directly! It was a pleasant
shock to discover that there was another level below that.
After that, _everything_ became a lot easier!
 
> >  Lisp presents a different way of thinking about the problem
> >that does not fit comfortably with what the novice already "knows"
> >about programming.
> 
> But why is that?  I'm not sure it's true.

My experience tells me that what a novice "knows" can be very
suprising! Z80 processors do _not_ directly execute Basic, nor
do they know how to do I/O. That's what a ROM is there for, and
in the case of my first machine, that ROM was 12K. I neither knew
that, nor cared at that point.

I now "know" differently. I now "know" how little I really "know",
and how much I "assume". This reminds me of a James Burke TV series
years ago, which opened up my mind to the idea that my viewpoint
could be shaped by what I know (and what I "know"), and that it
might be very different from what someone else "knows" about the
world. In the case of this discussion, instead of a model of the
world, it applies to the conceptual model of a computer and in
particular, a computer language. For example, "Lisp".

The above quotes are used whenever I'm refering to something that
is defined by what we think we know about the world, about computers,
and about Lisp. In the case of Lisp itself, it might also mean the
dialect that we think of as Lisp. It could be Common Lisp, or it
could be Scheme, or some other Lisp. It could even be Dylan.

In the same way, I should really refer to "Basic", as that is
even more variable - there seem to be as many dialects as there
are machines, and probably even more than that. I certainly don't
mean ANSI Basic, as I've never seen that. Nobody I know uses it.

-- 
http://cyber.sfgate.com/examiner/people/surfer.html
