is LISP the ultimate prgram language?

J

James Kanze

Brian Wood <[email protected]> writes:

[...]
(BTW: Seems to me as if someone also said this about
democracy.)

That's the way I first heard it, too. I just adapted it to C++.
(I think the original form, and the way I adapted it, was that
C++ isn't very good, but the alternatives are even worse. And
of course, it's one of those quotes which really doesn't mean
much---there are certainly cases where C++ isn't appropriate:
it's not about to replace PHP, for example, in the applications
where PHP is used, nor SQL.)
 
J

James Kanze

C++ started out as »C with classes«, so, initially,
classes were seen to be the main raison d'être for C++.

A desire to support object oriented programming is certainly one
of the motivations for using C++, rather than e.g. C. Object
oriented programming is a useful paradigm, and it's rare that I
don't use it for some parts of my application. *For* *some*
*parts*. The advantage of using C++ is that I don't have to
switch languages when other paradigms are more appropriate. Or
force my design into a paradigm that isn't appropriate. Or fake
it somehow (like java.lang.Math), pretending to be OO when I'm
not.
Ignoring other paradigms, C++ does not support
object-oriented programming well even when it is viewed in
isolation.

It supports it "sufficiently".
It misses:
- »Everything is an object«

Which is an advantage. Some things aren't objects, and
shouldn't be considered such.
- In C++, there is no support for most literals
as objects:
- »2« is not an object
- »"abc"« is not an object

Define "object". According to the standard, both are objects.
I assume that you mean something more, however, but what
exactly? And depending on your answer, maybe 2 or "abc"
shouldn't be objects. (They certainly shouldn't be polymorphic,
nor have identity.)
- In C++, there is no support for several kinds
of data as objects (numbers are not objects,
booleans are not objects)

Again, depending on your definition of object, maybe they
shouldn't be.
- In C++, there is no support for code blocks
as objects:
- »{ o.f(); }« is not an object

Not yet:).
- Dynamics
- In object-oriented programming, most is done
as late as possible at run time (like message
dispatching) - the C++ standard library tries
to do as much as possible as early as possible
(at compile time; template instantiation).

That really depends on your definition of object oriented
programming. C++ leaves it up to you to define when you want
late dispatch. In a controlled (type verified) manner. Which
for most uses is superior to uncontrolled dynamism a la Lisp:
errors at compile time are far better than the program failing
in the field. (Note that even an expert like Meyer insists on
static type checking.)
 
S

Stefan Ram

Juha Nieminen said:
(wouldn't "class" be the proper term? "object" is an instance
of a class, at least when we are talking about C++)

An object is an entity of the run-time model.

A class definition is an entity of the source-code model.

Not all object-oriented languages have classes, for
example, early JavaScript did not have classes IIRC.
And usually such OO purity comes with the cost of increased
memory usage and slower execution speed.

Often it is possible to avoid this when a compiler/optimizer
gets smart enough. For example, assuming all numbers were
objects in C++, then an expression such as:

i.inc()

might often be compiled to the same code as

++i

in the case where »i« is a primitive value. In many cases
»i« also will not have to be more memory than an int as long
as it behaves like an object in source code.

See also:

»All in all - Java could have been purely object
oriented with no significant performance hit.«

http://gbracha.blogspot.com/2009/05/original-sin.html
Are you sure that's really part of the definition of "object
oriented programming language"? It sounds to me more like
belonging to the functional programming paradigm.

In object-oriented programming, there does not have to be a
primitive »if« statement or boolean type, as both can easily
be defined.

For example, in Smalltalk, one can define a class »Boolean«
and then two subclasses of it using

True (subclass of Boolean)
if: block ^block value
False (subclass of Boolean)
if: block ^nil

»if« now is a method taking a block object in both
subclasses.

Then, the following code

True new if: [Transscript show: 'alpha']
False new if: [Transscript show: 'beta']

will print

alpha

, that is, we have just implemented a boolean type an an
»if« statement for it.

Thus, methods can double as »control structures« when code
blocks become objects. One can easily add custom control
structures, for example »with open file do ...«, which will
close the file after it has been used (which, in this
special case, can be handled by RAII in C++).

It might be difficult to do something like this in C++,
I once tried to show how to emulate it (a custom boolean
type with custom control structures for it) in Java:

http://www.purl.org/stefan_ram/pub/smalltalk-blocks-in-java

, where i do not use the primitve type »boolean« of
Java anywhere at all, yet implement a while loop using
object-oriented means.
 
S

Stefan Ram

James Kanze said:
Define "object". According to the standard, both are objects.

»2« is a literal and and expression denoting an r-value,
»"abc"« is a literal and expression denoting an r-value
of pointer type.

You are right that one has to take care with the word
»object« as it means two different things in C++ and in
»object-oriented«.

In this case, i intended use »object« in the sense of »an
entity that accepts messages at run-time«, but this is not
directly applicable in C++ as C++ also does not have »messages«.

So, I meant to say: For a language to be called »object
oriented«, it should have »things« that can receive messages
at run time, and the traditional »values«, »objects«, and
»blocks« of procedural programing languages should become
such »things«.
That really depends on your definition of object oriented
programming.

I took it from Alan Kay, the one who coined it:

»OOP to me means only messaging, local retention and
protection and hiding of state-process, and extreme
late-binding of all things.«

http://www.purl.org/stefan_ram/pub/doc_kay_oop_en
 
S

Stefan Ram

Keith H Duggar said:
Computerized symbolic mathematics systems ie Macsyma and its
imitators. I find that useful on a weekly basis ;-)

The meaning of »"AI"« might have changed: For example, text
recognition (as in »Google books«) is not deemed »AI« today
I believe. A »chatbot« is not deemed AI today, nor are
computer games with a computer player (although in this case
the computer player is called »AI« by programmers).

Maybe the outstanding project of classical AI is Cyc, I am
not aware of any impressive results yet. By its original
goals, Cyc should be reading newspapers today and learning
from it. Of course, there might be something like this today
and kept secret for some reason.

Any claim of advances in AI should be related to what
was already achieved about 40 years ago:

»Person: WHAT COLOR IS IT?
SHRDLU: BY "IT", I ASSUME YOU MEAN THE SHORTEST
THING THE TALLEST PYRAMID'S SUPPORT SUPPORTS.
SHRDLU: RED
Person: HOW MANY THINGS ARE ON TOP OF GREEN CUBES?
SHRDLU: I'M NOT SURE WHAT YOU MEAN BY "ON TOP OF
"IN THE PHRASE "ON TOP OF GREEN CUBES ".
DO YOU MEAN:
1 - DIRECTLY ON THE SURFACE
2 - ANWHERE ON TOP OF ?
Person: 2
SHRDLU: THREE OF THEM.
Person: HAD YOU TOUCHED ANY PYRAMID BEFORE YOU PUT THE
GREEN ONE ON THE LITTLE CUBE?
SHRDLU: YES, THE GREEN ONE.
[...]
Person: PICK UP A BIG RED BLOCK.
SHRDLU: OK. (does it)
Person: GRASP THE PYRAMID.
SHRDLU: I DON'T UNDERSTAND WHICH PYRAMID YOU MEAN.
Person: FIND A BLOCK WHICH IS TALLER THAN THE ONE YOU ARE
HOLDING AND PUT IT INTO THE BOX.
SHRDLU: BY "IT", I ASSUME YOU MEAN THE BLOCK WHICH IS TALLER
THAN THE ONE I AM HOLDING.
SHRDLU: OK. (does it) «

http://hci.stanford.edu/~winograd/shrdlu/

Lupo LeBoucher said in 2004:

»Computer science has been in a dark age since the 1970s.«

(IIRC, in »comp.lang.lisp«)

However, one should not despair, after all nowadays we have

http://google.to/search?q=number+of+horns+on+a+unicorn

and automatic weapon control:

»It appears as though the gun, which is computerised,
jammed before there was some sort of explosion, and then
it opened fire uncontrollably, killing and injuring the
soldiers."«

http://blog.wired.com/defense/2007/10/robot-cannon-ki.html
 
M

Mick

Richard said:
Hmm. And what has AI achieved as a result, a quarter-century later?

;-/
Probably so. But in answer to the claim 'Nothing has been programmed in
LISP' the answer seems to be that someone has been using it for
something, Regardless of the eventual value of the by product.

;)

MickG
 
S

Stefan Ram

Mick said:
Probably so. But in answer to the claim 'Nothing has been programmed in
LISP' the answer seems to be that someone has been using it for
something, Regardless of the eventual value of the by product.

The canonical example is Paul Graham who sold his Lisp
software Viaweb to Yahoo.

http://www.paulgraham.com/avg.html
 
S

Stefan Ram

Juha Nieminen said:
If the vector has the ability to store the ints by value rather than
by reference, then you are immediately admitting that the ints are not
full-fledged objects (because they cannot be replaced with objects
derived from an int). However, if you want any kind of efficiency in
your program, that's a practical decision to make.

This seems to be what Gilad Bracha wrote about in the link I
posted recently, albeit with regard to Java: See the text

» If int is a subtype of Object (as it is in the above)
we'd expect int[] to be a subtype of Object[], ...«

http://gbracha.blogspot.com/2009/05/original-sin.html
 
M

Michael DOUBEZ

ld a écrit :
This statement is not funded. COS uses dynamic dispatch but is as fast
as C++ virtual function call.

I mean the "don't pay for what you don't use" and I don't use virtual
functions all the time (although OO guys would say I should).

I have seen the benchmark but I am usually sceptical about such exercise
between language/compiler (whatever the result).
 
R

Rui Maciel

Richard said:
Hmm. And what has AI achieved as a result, a quarter-century later?

Do you believe that the progress observed in an entire scientific domain has any relation with the use of a
certain programming language by some projects?


Rui Maciel
 
K

Keith H Duggar

The meaning of »"AI"« might have changed: For example, text
recognition (as in »Google books«) is not deemed »AI« today
I believe. A »chatbot« is not deemed AI today, nor are
computer games with a computer player (although in this case
the computer player is called »AI« by programmers).

Says who? I doubt Prof. Winston for one agrees with you. See
for example the "integrates the same way I do" story in the
second paragraph of page 291 here

http://books.google.com/books?id=ZG2Zd_EQP-EC&lpg=PP1&pg=PA291#v=onepage&q=&f=false

He went on to note this tendency people have to say a thing
is no longer "intelligent" once they are shown the details of
how it works. intelligent != mysterious

Perhaps you would like to offer what you consider to be the
modern definition of "intelligence" suitable for demarcating
what is and is not A.I.?
Maybe the outstanding project of classical AI is Cyc, I am
not aware of any impressive results yet. By its original
goals, Cyc should be reading newspapers today and learning
from it. Of course, there might be something like this today
and kept secret for some reason.

Any claim of advances in AI should be related to what
was already achieved about 40 years ago:

We are talking about a 40 year old language and responding
to a blanket statement regarding what has been done in the
language. The restriction you propose above seems quite
artificial and arbitrary and maybe begging the question.
»Person: WHAT COLOR IS IT?
SHRDLU: BY "IT", I ASSUME YOU MEAN THE SHORTEST
THING THE TALLEST PYRAMID'S SUPPORT SUPPORTS.
SHRDLU: RED
Person: HOW MANY THINGS ARE ON TOP OF GREEN CUBES?
SHRDLU: I'M NOT SURE WHAT YOU MEAN BY "ON TOP OF
"IN THE PHRASE "ON TOP OF GREEN CUBES ".
DO YOU MEAN:
1 - DIRECTLY ON THE SURFACE
2 - ANWHERE ON TOP OF ?
Person: 2
SHRDLU: THREE OF THEM.
Person: HAD YOU TOUCHED ANY PYRAMID BEFORE YOU PUT THE
GREEN ONE ON THE LITTLE CUBE?
SHRDLU: YES, THE GREEN ONE.
[...]
Person: PICK UP A BIG RED BLOCK.
SHRDLU: OK. (does it)
Person: GRASP THE PYRAMID.
SHRDLU: I DON'T UNDERSTAND WHICH PYRAMID YOU MEAN.
Person: FIND A BLOCK WHICH IS TALLER THAN THE ONE YOU ARE
HOLDING AND PUT IT INTO THE BOX.
SHRDLU: BY "IT", I ASSUME YOU MEAN THE BLOCK WHICH IS TALLER
THAN THE ONE I AM HOLDING.
SHRDLU: OK. (does it) ¬´

http://hci.stanford.edu/~winograd/shrdlu/

Lupo LeBoucher said in 2004:

»Computer science has been in a dark age since the 1970s.«

(IIRC, in »comp.lang.lisp«)

However, one should not despair, after all nowadays we have

http://google.to/search?q=number+of+horns+on+a+unicorn

and automatic weapon control:

»It appears as though the gun, which is computerised,
jammed before there was some sort of explosion, and then
it opened fire uncontrollably, killing and injuring the
soldiers."¬´

http://blog.wired.com/defense/2007/10/robot-cannon-ki.html

KHD

PS. Why do you have a problem with HTTP access to your posts?
And do you think anyone/anything is paying attention to the
extra conditions you put on the X-No-Archive attribute? The
only practical result these days (it seems to me) is to mess
up the google archives causing threads to become confusing
within a few days. What is the benefit of that?
 
J

Jerry Coffin

[ ... ]
Hmm. And what has AI achieved as a result, a quarter-century later?

AI never has, and never will achieve anything. That's not to say that
AI research is useless though -- it's just that as soon as we figure
out how to actually do something in a usable, useful fashion, it
quits being considered AI.

If you look at older books on AI (e.g. from the 1950's) you'll find
that at one time things like OCR, hand-writing recognition, and
speech recognition were all considered proper "AI" subjects. They
aren't anymore though -- as soon as somebody figured out a semi-
practical way of doing them, they weren't "AI" anymore.
 
J

Jerry Coffin

(e-mail address removed)>,
(e-mail address removed) says...

[ ... ]
Google for "Worse is Better". It was written at a time when C was
becoming more popular than LISP and gives insights on why it was so.

Mostly it gives insights into the phenomenon mostly commonly referred
to as "sour grapes". I.e. it was written by a guy who could see that
what he liked was losing out to something he didn't like. He
proceeded to proclaim, in essence, "Look, the whole rest of the band
is out of step!"
 
J

James Kanze

How often is "often"?
If you have, for example, a vector of ints, where each int is a
full-fledged object (in other words, some of the ints could actually be
objects derived from an int), then I don't think the compiler has any
way of optimizing dynamic binding checks away. It cannot prove that none
of the ints in the array are objects derived from int.

It can, and some do. Obviously, it's harder for the compiler
than optimizing around std::vector, but then, optimizing around
std::vector is harder for the compiler than optimizing around
Fortran style arrays. (C-style arrays are a problem for the
compiler, because they end up being pointers.)
Also since such ints are full-fledged objects, it means that the
vector cannot store them by value. It has to store them by reference.
Right there you just *at least* doubled the memory usage of the vector
(assuming the absolutely optimal situation; in practice, however, the
memory usage probably quadrupled, or worse).

That, again, is an optimization issue. A fairly long time ago,
I stumbled upon a page by James Gosling on adapting Java for
numeric processing, and one of the issues discussed was how the
compiler could "optimize" such arrays to avoid dynamic
allocation of each object. He actually proposed an additional
keyword (IIRC) to tell the compiler that the type met certain
constraints (which the compiler then enforced), but in
principle, the compiler could determine whether this was the
case on its own. (Given that compilation in Java normally
occurs while you're running the program, you don't want to
impose optimization techniques that are too expensive. And
given that Java uses dynamic linking everywhere, done lazily,
it's very difficult for the compiler to have a view of the
complete program, which is necessary for the best optimization.)
With a suitably designed language (no dynamic linking, for
example, C++'s const), I don't think it would actually be that
difficult to detect and optimize such cases. (The page also
defined operator overloading; since Java didn't go that way, and
Gosling implied that it would be unusable for numerics if it
didn't, the page has disappeared.)
If the vector has the ability to store the ints by value rather than
by reference, then you are immediately admitting that the ints are not
full-fledged objects (because they cannot be replaced with objects
derived from an int). However, if you want any kind of efficiency in
your program, that's a practical decision to make.

I'm not convinced that the performance issue is the key,
although it's certainly easier for the compiler to optimize if
part of the "optimization" is done by the programmer. The fact
is that in any well designed program, regardless of the
language, there are different categories of objects: value
objects do not respect the same rules as entity objects, for
example, and in a "pure" OO language, you generally have to
follow some hard rules to ensure that value objects behave as
expected. Basically, C++ favors value objects over entity
objects, pure OO languages favor entity objects, often to the
point of making value objects very difficult. In some ways, the
"pure" OO can be considered an over-reaction---earlier
languages, like C or Fortran, ignored entity objects entirely.
(They're practically impossible in Fortran.) In practice,
however, all of the applications I've seen need some of both.
(Java still has final, which, used correctly, allows something
very close to a value object. Arguably, if you're making a
significant number of classes final in Java, you aren't
programming OO. But you are writing more robust and easier to
maintain code than if you skipped the final.)
I really don't see such a huge advantage in being purist about the OO
paradigm. Purism often bites back in decreased efficiency.

Decreased programmer efficiency, above all. If all you have is
a hammer, then everything looks like a nail; but a good workman
has a variety of tools in his toolbox, and uses whichever one is
appropriate for the occasion. And using a screwdriver, rather
than a hammer, on screws, makes you more efficient.
 
J

James Kanze

»2« is a literal and and expression denoting an r-value,
»"abc"« is a literal and expression denoting an r-value
of pointer type.

Agreed for the first (and it doesn't have an address). »"abc"«,
however, is an lvalue, of type »char const[4]«.

Array types do convert to pointers in a lot of circumstances,
and this is certainly a major defect in C++ (which it inherits
from C), but this has nothing to do with OO or not; Fortran
doesn't have this problem, and I don't think you could consider
it OO.
You are right that one has to take care with the word
»object« as it means two different things in C++ and in
»object-oriented«.

Yes. That's why I felt it important to mention. However...
In this case, i intended use »object« in the sense of »an
entity that accepts messages at run-time«, but this is not
directly applicable in C++ as C++ also does not have »messages«.

That's what I more or less supposed; I think globally, it was
clear that you were speaking of objects in the OO sense---what I
would call entity objects (i.e. which have identity).

As for messages... That's really just a question of vocabulary.
Most OO languages today speak of calling methods, and not
sending messages, but it all comes out to the same in the end:
send a message, call a method or call a member function.

Note that similar issues concern the word "class". In Java,
java.lang.Math is actually more like a namespace than a class
(but not quite---it would be more appropriate to say that what
it does would be better handled by a namespace than a class).
But of course, one could just as well argue that Java isn't pure
OO, since double and int aren't classes---logically, double
should be a class, and sin a method of that class.
So, I meant to say: For a language to be called »object
oriented«, it should have »things« that can receive messages
at run time, and the traditional »values«, »objects«, and
»blocks« of procedural programing languages should become
such »things«.
I took it from Alan Kay, the one who coined it:
»OOP to me means only messaging, local retention and
protection and hiding of state-process, and extreme
late-binding of all things.«

The problem, as I said, is that while Alan Kay may have invented
the term, it has taken on a life of its own: by that definition,
neither Java nor Eiffel are OO. (Similarly, Bertrand Meyer's
definition of OO excludes Smalltalk.) Practically speaking, I
would avoid such a limiting definitions; I don't see where
anything is gained by intentionally defining a paradigm so
restrictively that only one language (the one you invented)
allows implementing it.
 
N

Nick Keighley

(e-mail address removed) writes:
H. S. Lahman in <Kf7Df.1590$0J3.367@trndny08>
      »The problem of teaching object-oriented programming (...)
      C++ fails to meet almost all requirements on our list.« [...]
H. S. Lahman in <bv6je.8995$_f7.1506@trndny01>
      »There are only two things wrong with C++,
      The initial concept and the implementation.«

I'm not familiar with any of the above people, but I'd be
interested in knowing more about the context in which they are
speaking.  

H.S.Lahman posts in comp.object. He's a "contructionist" (if I've got
the terminology right) in that he builds very detailed models from
which
code is generated. He's not really a fan of *any* 3GL.

<snip>

--
Nick Keighley

"Object-oriented programming is an exceptionally bad idea
that could only have originated in California."
Dijkstra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top