From: Kenny Tilton
Subject: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <4pg6id$c90@betty.bway.net>
A couple of people asked about a language comparison I had cooked up, so here 
goes.

The genesis of this comparison actually was an attempt to decide if Java was 
more like C++ or Smalltalk. Then I threw in Dylan and Lisp so they could shine. 
:) I hear ObjC should be in this comparison as well, and that it may be Java's 
closest evolutionary kin. Perhaps an ObjC person can fill in that column.

Bear in mind I am no language expert, I was just putting down what I had heard. 
Corrections welcome.

Rows are meant to be pluses, so you'll see things like "Pointer-free" which are 
awkward ways of making a negative into a positive.

Conclusion? I guess Java is a litte closer to Smalltalk than C++, because the 
areas of agreement are so substantial: GC, pointer-free, single-inheritance.

                           Java C++ Smalltalk Lisp Dylan
Dynamic language                        x      x     x
Dynamic objects(1)           x          x      x     x
Pointer-free                 x          x      x     x
Garbage Collection           x          x      x     x
Multiple Inheritance             x             x     x
Text Macros(2)                   x             x     x
Procedural macros(3)                           x
Loose (Run-time) typing                 x      x     x
Closures                                x      x     x
"apply"(4)                       x             x     x
RTTI                         ?   x      x      x     x
Generic Functions                              x     x
Function overloading         x   x      x     (5)   

1. Not sure what to call this behavior. Maybe "late-binding"? What I mean is, 
in Java if you pass an object as an argument to a function expecting an 
instance of a *superclass* of the passed object, if that function subjects its 
argument to polymorphic dispatch, it behaves as its runtime self, according to 
its own class, while in C++ it is treated as an instance of the superclass.

2. Token-wise expansion a la C macros.

3. I do not think "procedural" is the right word. Anyway, I have never heard of 
any language other than Lisp having such an animal.

4. "apply", "funcall", or in C (*functionPointer)(...).

5. Though different in some respects, &key, &optional and &rest args offer at 
least as much expressive power as function overloading.

From: Marty Hall
Subject: Re: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <DssE9L.854@aplcenmp.apl.jhu.edu>
In article <··········@betty.bway.net> Kenny Tilton <····@qi-labs.com> writes:

>                           Java C++ Smalltalk Lisp Dylan
[...]
>RTTI                         ?   x      x      x     x

I would think that "instanceof" in Java gives you this.

>Function overloading         x   x      x     (5)   
[...]
>5. Though different in some respects, &key, &optional and &rest args offer at 
>least as much expressive power as function overloading.

Besides, from the user's perspective generic functions and regular
functions are the same. I can do

(defmethod Square ((N number)) (* N N))
(defmethod Square ((S string)) (concatenate 'string S S))

This sure seems like overloading to the C++/Java programmer.


I'm always a bit dubious about what these comparisons show, anyhow
(and Ken wasn't claiming it proved anything), since the items you
choose to list reflect your biases. The Java advocates would list
"builtin support for multi threading", "standard interface to C",
"portable graphics library" and (especially :-) "ability to be run in
WWW pages" to *their* list. Paul Graham commented insightfully in _On
Lisp_ that what you consider important in a language is partly a
reflection of what you are used to. You don't know to want a certain
item until you've used it and seen its power. Of course this cuts both
ways: I'd like a builtin portable graphics library in Lisp, a standard
interface to C, and standard support for multithreading. In Java, I would
really, really, like first class functions and multiple
inheritance. Macros are too much to ever hope for. 

Cheers-
					- Marty
(proclaim '(inline skates))

Lisp: <http://www.apl.jhu.edu/~hall/lisp.html>
Java: <http://www.apl.jhu.edu/~hall/java>
From: Richard A. O'Keefe
Subject: Re: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <4piqv4$nb7@goanna.cs.rmit.EDU.AU>
Kenny Tilton <····@qi-labs.com> writes:
>                           Java C++ Smalltalk Lisp Dylan
>Procedural macros(3)                           x
>3. I do not think "procedural" is the right word. Anyway, I have never heard of 
>any language other than Lisp having such an animal.

In Pop-2, a macro is an identifier that is bound to a function, in such a
way that when the compiler sees the identifier, it calls the function.
Pop-2 macros consume as many tokens as they want from the input stream,
and push back whatever tokens they want.  It's not as handy as Lisp (tree->
tree) but it sure is procedural!

-- 
Fifty years of programming language research, and we end up with C++ ???
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
From: Ken Hirsch
Subject: Re: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <31BD049F.912@ix.netcom.com>
Kenny Tilton wrote:
[omitted]
> 
> 
> 1. Not sure what to call this behavior. Maybe "late-binding"? What I mean is,
> in Java if you pass an object as an argument to a function expecting an
> instance of a *superclass* of the passed object, if that function subjects its
> argument to polymorphic dispatch, it behaves as its runtime self, according to
> its own class, while in C++ it is treated as an instance of the superclass.

"Late binding" is a good name but a little vague; it's usually called "dynamic binding."
It does exist in C++, but it is unfortunately not the default.  You must use the "virtual"
keyword.

Ken Hirsch
Carrboro, N. C.
From: Ken Tilton
Subject: Re: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <31C1770B.6E39@bway.net>
Thomas,

Thanks for the corrections, Ken now writes <g>:

>                               Java C++ Smalltalk Lisp Dylan
> Huge...:)
>    Dynamic development                     x      x     x
>
> Memory...
>    Pointer-safe                 x          x      x     x
>    Garbage Collection           x          x      x     x
>
> Type stuff...
>    Loose (Run-time) typing                 x      x     x
>    Run-time type info           x   -      x      x     x
>    Meta Object Info                        x      x     x
>
> Meta-programming..
>    Text Macros(2)                   x             x     x
>    Procedural macros(3)                           x
>    Closures                                x      x     x
>    "apply/funcall(-)"               -             x     x
>
> OO issues (kinda)
>    Multiple Inheritance         -   x             x     x
>    Generic Functions                              x     x
>    Function overloading         x   x      x      +     +

Thomas wrote:
> 
> I don' tkow what you mean by "dynamic language".

I'll rename it "... development". In Lisp and Smalltalk while my application is running I can sit 
at a command line and poke around my application data structures programmatically because 
information has not been compiled away. Also, I can modify a function use by my app while it is 
running and the next time it goes there the new version executes. That sort of thing.

> 
> Java has a limited form of "multiple inheritance" for interfaces.
> 

An Objective C guy told me about interfaces, but he conceded it took a lot of work to avoid a lot 
of code duplication. Sounds like a kludge which back-handedly proves m/i is OK. But I'm easy. 
I'll give Java a "-".

> C++ does not have "apply", it has a kind of "funcall". 
> 

Yes. I was bending over backwards to help C++. :) I'll drop it to a minus.

> None of those languages are "pointer free".  C++ happens to have
> unsafe pointer operations

The first thing I noticed about Smalltalk is that one indeed must keep clear the difference 
between an object and a reference to an object, such as the diff between copy and deep-copy.

How about pointer-safe instead of pointer-free?

> 
> All of those languages have RTTI (in the C++ sense)
>

Oh, I meant to put quotes around that to convey I was speaking generically. My fault. I'll reduce 
C++ to a minus and leave Java at "x" on your word it will improve soon. :)

>  But C++ also has call-by-value for compound data structures and
> compounds-of-compound data structures, both of which are big plusses
> compared to the other languages in your list.

Why is that a big plus? Sell me on it and I'll add it to the table.

Speaking of big pluses, I have heard C++'s strong typing described as a "big win". I think I 
understand why, but I also see it is as a huge negative! So there is a comparison attribute (I 
guess mult/inherit is another) that is kinda "to each hisher own".

Ken
From: Marty Hall
Subject: Re: Lisp vs Java vs C++ vs...
Date: 
Message-ID: <Dt56pL.9tt@aplcenmp.apl.jhu.edu>
In article <·················@best.best.com> ···@best.com (.) writes:

>SML has a static type system that I find rather non-intrusive, even
>though it does not (yet!) have dynamic typing facilities.  

But it does have type variables. For those who haven't seen them, they
are sort of like a more powerful version of C++ templates, letting you
specify an unnamed type. For instance, for a sorting routine you could
specify that the inputs are a list and a function. The list has
elements of type foo, and the function takes two foo's as input and
returns a boolean. This is all completely type safe and can be checked
at compile time. SML'ers call it "alpha" instead of "foo" to use the
same convention as the simply typed lambda calculus.

					- Marty
(proclaim '(inline skates))
<http://www.apl.jhu.edu/~hall/lisp.html>