low-level approach
Ulrich Hobelmann
u.hobelmann@tu-bs.de
Mon Jan 14 02:49:02 2002
Kyle Lahnakoski wrote:
> For example, the difference between C and Java can be summed in three
> aspects:
> Java has garbage collection
> Java has inheritance (limited polymorphism)
> C has function pointers
I'd claim that Lisp first class functions are way more powerful than C
fun-pointers
in that they capture an environment.
Concerning Java's OO features, well, I don't like the fact that
functions and
types are kind of thrown together here:
compare this to Haskell, where you can have arbitrary sum&product types,
while
limited polymorphism is handles via type classes.
(BTW: can anyone tell me in what way Java's inheritance doesn't
correctly
model subtyping? this was hinted at in the TUNES-glossary->Inheritance
... ?)
> All compound objects are treated as lists.
> Function references, using quotation, are available.
> Lisp syntax is simple
I think the point here is that the C type system is _very_ weak, and
there's
no safety or GC, so writing List code is very bug-prone compared to
Lisp.
Also, in general, most Lisps have other types like vectors and records.
Other Lambda-based languages like Haskell/ML use these other types much
more than lists...
> The first advantage can be easily overcome by using library functions in
> any procedural language. I have seen a comparison of Lisp (Prechelt?)
> to C
> and Java with respect to development time, with Lisp winning. The
> positive result was a side effect of having a string intensive program
> requirement. Lisp naturally handles strings, but Java and C require the
> developer to make/find good string libraries to compete.
To me the bad point about Java is that in Lisp you can have Objects or
structs,
while in Java, expressing functions (via interfaces..) is sooo ugly...
(Hmmm... wasn't Java developed by James Gosling and Guy Steele, two
Lispers???)
> The second advantage is significant compared to Java (as discussed), but
> not too significant with respect to C (which has function pointers).
> Many Lisp "superiority" examples compare themselves to "equivalent" C
> programs, but I have yet to see one that does not use a deliberately
> verbose C equivalent.
Usually, when you directly translate C into Lisp, you immediately notice
several
points which need improvement, because C code is more bound to
restictions in language
comfort, which Lisp is more free-form and doesn't restrict you in any
way.
You can even implement your own syntax macros.
> SUMMARY
IMHO the only advantage of C is direct control over how data is put in
memory.
In all other points the language has too many unnecessary restrictions
(and not even
tail recursion!!). For a better done C, google for Cyclone.
Java, OTOH, has _no_ single advantage to me, meaning every good point in
Java is
done better elsewhere...
Greetings, Ulrich