merits of Lisp vs Python

N

Neil Cerutti

["Followup-To:" header set to comp.lang.python.]
I'm looking at Python and I see that the syntax would appeal to
a newbie. Its clearer than ML which is a mess syntactically.

And if you stew it like applesauce, it tastes more like prunes
than rhubarb does.
But I don't see where the action is in Python. Not yet
anyway. Lisp syntax is easy to learn. And giving up an order
of magnitude is a high price to pay for using it over Lisp.

I find it easier to learn syntax than special forms. But either
system comes naturally enough with practice.
 
A

Aahz

I'm looking at Python and I see that the syntax would appeal to a
newbie. Its clearer than ML which is a mess syntactically. But I
don't see where the action is in Python. Not yet anyway. Lisp syntax
is easy to learn. And giving up an order of magnitude is a high price
to pay for using it over Lisp.

Speaking as someone who had been programming for more than twenty years
before learning Python (including a brief gander at Lisp), and also
referring to many years of observations of newcomers to Python: Python's
syntax also appeals to experienced programmers.

I would say that your statement about Lisp syntax is wrong. Not that it
is technically inaccurate, but that it completely misses the point, so
much so that it is wrong to say it. One of the key goals of Python is
readability, and while it is indeed easy to learn the rules for Lisp
syntax, observational experience indicates that many people (perhaps even
the vast majority of people) find it difficult to learn to read Lisp
programs.

As for your claims about speed, they are also nonsense; I doubt one
would find an order of magnitude increase of speed for production
programs created by a competent Lisp programmer compared to programs
created by a competent Python programmer.

Consider this: Lisp has had years of development, it has had millions of
dollars thrown at it by VC firms -- and yet Python is winning over Lisp
programmers. Think about it.
 
K

Ken Tilton

Bjoern said:
Ah, so *that's* what you meant ... but I don't really understand the
ease of it.

Code in the abstract exists as a tree of trees. With parens, we now have
textual markers delimiting these trees. That means I can point to any
arbitrary subtree by pointing to its left or right parens, and tell the
editor to copy or delete "that chunk of logic". And now I am
manipulating chunks of program logic instead of text.

One simple but hopefully illustrative example: suppose I have an if
statement with two big branches. My code then looks like:
(if (condition) (big-branch-1)(big-branch-2))

Please remember that any of those fakes can be arbitrarily deep nested
expressions. Now during refactoring, I decide bb-2 processing goes
elsewhere, maybe somewhere "upstream" in the logic. So I double-click
and then drag-and-drop, or cut and paste.

Then I double-click on the entire if statement, and then do a
control-click on the "then" condition, control-click happening to mean
"paste what I am clicking". Suddenly the "then" is the whole form.

(And, yes, this means my vendor took away from me the normal
copy-and-drop associated with control click <g>, but I could modify
things to get it back if I really cared.)

Of course the next question has to be, how often does that come up? When
refactoring it sometimes feels like I do nothing else. :) It turns out
that this is an insanely natural way to work with code.

Note also that after any amount of dicing I simply hit a magic key combo
and the editor reindents everything. In a sense, Lisp is the language
that handles indentation best.

hth, ken

--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm

"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
 
K

Ken Tilton

Aahz said:
Speaking as someone who had been programming for more than twenty years
before learning Python (including a brief gander at Lisp), and also
referring to many years of observations of newcomers to Python: Python's
syntax also appeals to experienced programmers.

I would say that your statement about Lisp syntax is wrong. Not that it
is technically inaccurate, but that it completely misses the point, so
much so that it is wrong to say it. One of the key goals of Python is
readability, and while it is indeed easy to learn the rules for Lisp
syntax, observational experience indicates that many people (perhaps even
the vast majority of people) find it difficult to learn to read Lisp
programs.

No programming language is easy to read, and no Lisp programmer stopped
using Lisp because they had been using it for a month and just could not
get used to reading it. So I think you are just making things up. :)
Consider this: Lisp has had years of development, it has had millions of
dollars thrown at it by VC firms -- and yet Python is winning over Lisp
programmers. Think about it.

Haha, what's the score? And how much time is left in the first quarter?

:)

ken

--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm

"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
 
A

Alex Mizrahi

(message (Hello 'Bjoern)
(you :wrote :eek:n '(Fri, 08 Dec 2006 19:57:28 +0100))
(

??>> also, there's no need for operator precendence to be taken in
??>> accound -- order is explicitly defined. expressions are
??>> homogenous, they do not depend on other expressions near them
??>> (except lexical variables and side effects).

BS> Sorry, I don't get it ;) Where does Python have things like
BS> nonexplicit defined operator order?

you have an expression 3 + 4 which yields 7.
you have an expression 4 * 1 which yields 4.
if you paste 3 + 4 in place of 1, you'll have 4 * 3 + 4 = 16. as we know, *
is commutative, but 3 + 4 * 4 = 19.
so result depends on implicit operator precendence rules.

in lisp, if you paste (+ 3 4) in (* 4 1), you'll have (* 4 (+ 3 4)), and it
does not depend on order of operands, (* (+ 3 4) 4) yields same results. you
do not have to remember precendence rules -- * and + are not anyhow special
from other functions. all you need to remember is how to call functions.

certainly it's a very simple example, but it shows that generally, homogeous
lisp syntax make expressions much less dependant on context, and there are
much less rules affecting it. thus, work require by brain to understand and
write code can be reduced -- that way it's easier.

Common Lisp specification define internal languages that are not in
homogenous s-expr syntax -- that is formatter and loop macro.
like

(loop for i from 1 to 20 collect i)

or

(loop for e in list
maximizing e into max
minimizing e into min
finally (return (values min max)))

remarkable thing about that is that it's the only place which i cannot
remember and need to lookup quite frequently in the reference.
although it looks almost like plain english and looks quite easy, it's much
harder than other parts of lisp that use uniform syntax.

but certainly this uniform syntax doesn't worth much without macro
facilities.

i'll show an example from my recent experiments.
in this example we want to perform a query into a RDF database
(triplestore), SPARQL-style query, and then we format results as HTML.
here's how it looks in the SPARQL (i'm not fluent in it, so it can be
buggy). basically, we want to query information (firstname, lastname,
salary) or all users in specified departament.

PREFIX myapp: <https://mydomain.net/myapp/1.1/>
SELECT ?fname, ?lname, ?salary
WHERE
{
?user myapp:name ?uname.
?uname myapp:first-name ?fname.
?uname myapp:last-name ?lname.
?user myapp:salary ?salary.
?user myapp:department ?dept.
}

we should feed this text to the query-builder.
then we should bind ?dept to our variable departament (i'm not sure how this
is done in SPARQL, but there should be a way).
then we should iterate over results and output HTML. a python-like
pseudocode:

query = BuildQuery(query_str)
query.bind("?dept", departament)
results = query.execute()
for each rs in results:
print "<tr><td>" + htmlesc(rs.get("?fname")) + "</td><td>" +
htmlesc(rs.get("?lname")) + "</td><td>" + rs.get("?salary") + "</td></tr>"

so how uniform syntax and macros can help here? we can make a macro
rdf:do-query that will both programmatically create query, bind input
variables and then bind results into local variables. also we can wrap HTML
output in a macro too.
so here's a code:

(rdf:do-query
((?user :name ?uname)
(?uname :first-name ?fname)
(?uname :last-name ?lname)
(?user :salary ?salary)
(?user :department department))
(html :)tr
:)td :)princ ?fname))
:)td :)princ ?lname))
:)td :)princ ?salary)))))

as you can find, it's two times less code, it's less clumsy, and there's
even less quotes and parentheses there -- who says that lisp has more
parentheses? also, this code is less error-prone, because some part of
correctless can be checked during compilation time by macros, because it
operates with symbols on semantic level, but not with simple strings.
for example, if i make a type and write ?fnme instead of ?fname in the HTML
output, compiler will report a warning about unbound variable, but if this
variable will be in string-form, compiler will not be able to.
there are other benefits: RDF query language is transparently integrated
into Lisp, there's no need to learn some other language (SPARQL) syntax
additionally. and it strains my brain less when i don't have to switch
between different languages.

is it possible to construct such helper functions (or whatever) to simplify
code in Python?

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")
 
S

Stephen Eilert

Alex Mizrahi escreveu:

we should feed this text to the query-builder.
then we should bind ?dept to our variable departament (i'm not sure how this
is done in SPARQL, but there should be a way).
then we should iterate over results and output HTML. a python-like
pseudocode:

query = BuildQuery(query_str)
query.bind("?dept", departament)
results = query.execute()
for each rs in results:
print "<tr><td>" + htmlesc(rs.get("?fname")) + "</td><td>" +
htmlesc(rs.get("?lname")) + "</td><td>" + rs.get("?salary") + "</td></tr>"

I just want to add that this kind of HTML mixed with code is something
that should be avoided, no matter what language is used.


Stephen
 
K

Kay Schluehr

O.K. I agree with what you said about the generic function vs per
object dictionary dispatch.
But do the performance differences vanish when only builtin types and
functions are used to express Python algorithms?
 
C

Chris Mellon

Alex Mizrahi escreveu:



I just want to add that this kind of HTML mixed with code is something
that should be avoided, no matter what language is used.

results = doQuery(department="Accounting")
for row in results:
for field in ["fname","lname","salary"]:
print "<td>%s</td>" % htmlesc(row[field])

I hide away the binding etc in doQuery as the lisp version does. Note
that in any kind of real code most of the literals that take up the
space are likely to come from elsewhere.

Note how much more trivial it is to change the HTML output of this
version that the lisp - it's a matter of creating a format string,
which you can retrieve from just about anywhere, rather than requiring
a code refactoring. Just because you have macros doesn't mean it makes
sense to use them.
 
R

Rob Warnock

+---------------
| hankhero wrote:
| > Pythons advantages are:
| > Faster startup-time which makes it a good scripting language.
|
| ... but on my machine, SBCL starts up and runs a "Hello World"
| program a bit faster than Python, and CLisp really blows its doors off.
+---------------

On my various machines, CMUCL startup is *slightly*
faster than CLISP, but both are under 20 ms...

I use Common Lisp for scripting a *lot*!


-Rob
 
J

JShrager

Okay, since everyone ignored the FAQ, I guess I can too...

Mark said:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?

(Common) Lisp is the only industrial strength language with both pure
compositionality and a real compiler. What Python has is stupid slogans
("It fits your brain." "Only one way to do things.") and an infinite
community of flies that, for some inexplicable reason, believe these
stupid slogns. These flies are, however, quite useful because they
produce infinite numbers of random libraries, some of which end up
being useful. But consider: Tcl replaced Csh, Perl replaced Tcl, Python
is rapidly replacing Perl, and Ruby is simultaneously and even more
rapidly replacing Python. Each is closer to Lisp than the last; the
world is returning to Lisp and is dragging the flies with it.
Eventually the flies will descend upon Lisp itself and will bring with
them their infinite number of random libraries, and then things will be
where they should have been 20 years ago, but got sidetracked by Tcl
and other line noise.
 
F

Fred Gilham

A suggestion is to mention Dylan as a possibility to people who think
Lisp syntax is too funky but want to see something Lisp-like.

--
Fred Gilham (e-mail address removed)
Progressive (adj): Value-free; tolerant; non-judgemental.
E.g. traditional archery instruction methods spent tedious hours
teaching the archer to hit a bulls-eye. Progressive methods achieved
better results by telling the student archer to shoot in the manner he
or she found most comfortable, then calling whatever the arrow hit the
bulls-eye.
 
P

Paddy

Mark said:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?

Note I'm not a Python person and I have no axes to grind here. This is
just a question for my general education.

Mark
I've never programmed in Lisp but I have programmed in Cadence Skill a
Lisp inspired language with infix notation as an option. I found Skill
to be a very powerful language. At the time I new only AWK, C, Pascal,
Forth, Postcript, Assembler and Basic. Skill was superior and I came
to love it.
But that was a decade ago. Now, I'd rather a company integrate Python
into their product as I find Python to be less 'arcane' than Skill;
with more accessible power, and a great community.
..
Analogy time!
You need Pure Maths, but more mathematicians will be working applying
maths to real-world problems. You need research physicists, but more
physicists will be applying physics in the real world. It seems to me
that Lisp and its basis in maths makes people research and develop a
lot of new techniques in Lisp, but when it comes to applying those
techniques in the real world - switch to Python!

Lisp has a role to play, but maybe a language tuned to research and
with its user base would naturally find it hard to compete in the roles
in which dynamic languages such as Python are strongest.

- Paddy.
 
K

Klaas

Aahz said:
As for your claims about speed, they are also nonsense; I doubt one
would find an order of magnitude increase of speed for production
programs created by a competent Lisp programmer compared to programs
created by a competent Python programmer.

Lisp can be compiled into an executable that has c-like speeds. It can
be much faster than python.

-MIke
 
T

tayssir.john

Aahz said:
I would say that your statement about Lisp syntax is wrong. Not that it
is technically inaccurate, but that it completely misses the point, so
much so that it is wrong to say it. One of the key goals of Python is
readability, and while it is indeed easy to learn the rules for Lisp
syntax, observational experience indicates that many people (perhaps even
the vast majority of people) find it difficult to learn to read Lisp
programs.

I think this holds true for experienced programmers, who often report a
difficult unlearning process with Lisp. However, for people without
preconceptions, the difference is likely less -- after all, many have
painful memories of poorly-taught math and computer classes in school.
So Python's similarity to gradeschool math may not be such a plus.

Richard Stallman explained about a Lisp variant:

"Multics Emacs proved to be a great success -- programming new editing
commands was so convenient that even the secretaries in his office
started learning how to use it. They used a manual someone had written
which showed how to extend Emacs, but didn't say it was a programming.
So the secretaries, who believed they couldn't do programming, weren't
scared off. They read the manual, discovered they could do useful
things and they learned to program."
<http://www.gnu.org/gnu/rms-lisp.html>

But of course this is anecdotal evidence.

Consider this: Lisp has had years of development, it has had millions of
dollars thrown at it by VC firms -- and yet Python is winning over Lisp
programmers. Think about it.

Even now, Lisp still contains radical concepts (as in latin's radix
meaning "root"), and overly radical ideas tend not to dominate in the
marketplace. So we see an incremental progression towards Lisp ideas.

Guy Steele, a central figure in Java, claimed:

"And you're right: we were not out to win over the Lisp programmers; we
were after the C++ programmers. We managed to drag a lot of them about
halfway to Lisp. Aren't you happy?"
<http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg04045.html>

But speaking of the marketplace, there's at least one Lisp company
sustaining itself by asking for a cut of its customers' revenues... The
last Lisp implementation I used "merely" asked for thousands per head
per platform. ;)


(Personally, I used Python before being aware of Lisp. Now I use Common
Lisp all the time, though I will recommend Python when I consider it
more appropriate. A few months ago, I missed the Condition System most
when using Python, and also lexical scope. However, it is nice to work
with friends, who know Python and not Lisp.)


Tayssir
 
P

Paddy

Okay, since everyone ignored the FAQ, I guess I can too...



(Common) Lisp is the only industrial strength language with both pure
compositionality and a real compiler. What Python has is stupid slogans
("It fits your brain." "Only one way to do things.") and an infinite
community of flies that, for some inexplicable reason, believe these
stupid slogns. These flies are, however, quite useful because they
produce infinite numbers of random libraries, some of which end up
being useful. But consider: Tcl replaced Csh, Perl replaced Tcl, Python
is rapidly replacing Perl, and Ruby is simultaneously and even more
rapidly replacing Python. Each is closer to Lisp than the last; the
world is returning to Lisp and is dragging the flies with it.
Eventually the flies will descend upon Lisp itself and will bring with
them their infinite number of random libraries, and then things will be
where they should have been 20 years ago, but got sidetracked by Tcl
and other line noise.

What is it about Lisp that despite doing everything first, way before
any other language, people don't stop using anything else and
automatically turn to Lisp? Maybe there is more to this everything than
the Lisp community comprehends.
Maybe Lisp is to science, as Python is to engineering - with a slight
blurring round the edges?

- Paddy.
 
S

smallpond

Mark said:
How do you compare Python to Lisp? What specific advantages do you
think that one has over the other?

Note I'm not a Python person and I have no axes to grind here. This is
just a question for my general education.

Mark

cmp `which clisp` `which python`
/usr/bin/clisp /usr/bin/python differ: byte 25, line 1

HTH

--S
 
G

George Sakkis

Okay, since everyone ignored the FAQ, I guess I can too...



(Common) Lisp is the only industrial strength language with both pure
compositionality and a real compiler. What Python has is stupid slogans
("It fits your brain." "Only one way to do things.") and an infinite
community of flies that, for some inexplicable reason, believe these
stupid slogns. These flies are, however, quite useful because they
produce infinite numbers of random libraries, some of which end up
being useful. But consider: Tcl replaced Csh, Perl replaced Tcl, Python
is rapidly replacing Perl, and Ruby is simultaneously and even more
rapidly replacing Python. Each is closer to Lisp than the last; the
world is returning to Lisp and is dragging the flies with it.
Eventually the flies will descend upon Lisp itself and will bring with
them their infinite number of random libraries, and then things will be
where they should have been 20 years ago, but got sidetracked by Tcl
and other line noise.

I know we shouldn't feed the trolls, but this one was particularly
amusing to resist the urge. The joke about lisp's world domination in
some unspecified point in the future never fails to bring a good
chuckle. I heard it's scheduled right after strong AI and before time
travel, is this still the plan? A quick look at
http://www.tiobe.com/tpci.htm may be helpful as a reality check before
you go back to your ivory tower (interesting how close in ratings and
growth is the "Lisp/Scheme" entry with another dinosaur, Cobol).
 
K

Ken Tilton

George said:
I know we shouldn't feed the trolls, but this one was particularly
amusing to resist the urge. The joke about lisp's world domination in
some unspecified point in the future never fails to bring a good
chuckle. I heard it's scheduled right after strong AI and before time
travel, is this still the plan? A quick look at
http://www.tiobe.com/tpci.htm may be helpful as a reality check before
you go back to your ivory tower (interesting how close in ratings and
growth is the "Lisp/Scheme" entry with another dinosaur, Cobol).

And it interesting that VB is almost three times "better" than Python,
and that a Honda could kick a Lamboghini's ass for it at Laguna Seca:

http://www.googlefight.com/index.php?lang=en_GB&word1=lamborghini&word2=ford

Come on, COBOL is a great language, even has macros (copy ... replacing)
and the worlds greatest case statement, evaluate. We are proud to be its
neightbor.

ken

--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm

"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
 
D

Duane Rettig

Paddy said:
I've never programmed in Lisp but I have programmed in Cadence Skill a
Lisp inspired language with infix notation as an option. I found Skill
to be a very powerful language. At the time I new only AWK, C, Pascal,
Forth, Postcript, Assembler and Basic. Skill was superior and I came
to love it.

Remember; Lisp is a program-language programming language. Sometimes,
one programs in Lisp without really knowing it:

http://www.franz.com/careers/jobs/outside/cadence03.21.06.lhtml
 
G

George Sakkis

Ken said:
And it interesting that VB is almost three times "better" than Python,
and that a Honda could kick a Lamboghini's ass for it at Laguna Seca:

Didn't say better, not even in quotes (and btw, if you're only doing
GUI apps in MS, VB is the path of least resistance in many cases, as is
PHP for quick'n'dirty web apps). What was funny in the GP's post was
the pomposity about "flies eventually descending upon Lisp itself", as
if language popularity (or any popularity for that matter) is
determined solely by theoretical computer science metrics.

George
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top