473,841 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python vs. Lisp -- please explain

Hi, I've been thinking about Python vs. Lisp. I've been learning
Python the past few months and like it very much. A few years ago I
had an AI class where we had to use Lisp, and I absolutely hated it,
having learned C++ a few years prior. They didn't teach Lisp at all
and instead expected us to learn on our own. I wasn't aware I had to
uproot my thought process to "get" it and wound up feeling like a
moron.

In learning Python I've read more about Lisp than when I was actually
trying to learn it, and it seems that the two languages have lots of
similarities:

http://www.norvig.com/python-lisp.html

I'm wondering if someone can explain to me please what it is about
Python that is so different from Lisp that it can't be compiled into
something as fast as compiled Lisp? From this above website and
others, I've learned that compiled Lisp can be nearly as fast as C/C++,
so I don't understand why Python can't also eventually be as efficient?
Is there some *specific* basic reason it's tough? Or is it that this
type of problem in general is tough, and Lisp has 40+ years vs Python's
~15 years?
Thanks
Michael

Feb 19 '06 #1
118 6771
DH
63*******@sneak email.com wrote:
A few years ago I
had an AI class where we had to use Lisp, and I absolutely hated it,
having learned C++ a few years prior. They didn't teach Lisp at all
and instead expected us to learn on our own.
CS classes haven't changed, I see.
In learning Python I've read more about Lisp than when I was actually
trying to learn it, and it seems that the two languages have lots of
similarities:

http://www.norvig.com/python-lisp.html

I'm wondering if someone can explain to me please what it is about
Python that is so different from Lisp that it can't be compiled into
something as fast as compiled Lisp? From this above website and
others, I've learned that compiled Lisp can be nearly as fast as C/C++,
so I don't understand why Python can't also eventually be as efficient?
Is there some *specific* basic reason it's tough? Or is it that this
type of problem in general is tough, and Lisp has 40+ years vs Python's
~15 years?


It is by design. Python is dynamically typed. It is essentially an
interpreted scripting language like javascript or ruby or perl, although
python fans will be quick to tell you python is compiled to byte code.
They'll also be quick to tell you:
-python has true closures (although nothing like ruby's blocks)
-is beginner friendly (despite being case sensitive and 3/4==0, for example)
-is not, in fact, slow at all (despite benchmarks as you noted showing
otherwise).
Judge for yourself.

There are projects that combine static typing + the python syntax, which
result in dramatically faster code, but perhaps only 80% of python's
functionality and less flexibility you get from dynamic typing.
Projects like shedskin. But some python fans don't think 80% cuts it,
even if you do get a 100 fold speed increase.
Feb 19 '06 #2

<63*******@snea kemail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
In learning Python I've read more about Lisp than when I was actually
trying to learn it, and it seems that the two languages have lots of
similarities:

http://www.norvig.com/python-lisp.html

I'm wondering if someone can explain to me please what it is about
Python that is so different from Lisp that it can't be compiled into
something as fast as compiled Lisp? From this above website and
others, I've learned that compiled Lisp can be nearly as fast as C/C++,
In order to be that fast, some of the dynamism of intepreted Lisp must be
given up. In particular object code is not list data. Python with
type-dynamism eliminated can also be translated to decent C/C++ and then
compiled. See PyRex and Weave. There is also Psyco, which I believe
translates directly to machine code.
so I don't understand why Python can't also eventually be as efficient?
Is there some *specific* basic reason it's tough? Or is it that this
type of problem in general is tough, and Lisp has 40+ years vs Python's
~15 years?


Yes, *much* more work has gone into Lisp than Python. (At least 10x, I am
sure. and maybe up to 100x) During the 1980s, there was a Lisp/AI
boom/bust something like the dot.com boom/bust of the last 1990s with
perhaps a billion invested in Lisp/AI companies. I presume some of that
went into Lisp itself (as opposed to AI applications thereof).

Terry Jan Reedy

Feb 19 '06 #3

63*******@sneak email.com wrote:

I'm wondering if someone can explain to me please what it is about
Python that is so different from Lisp that it can't be compiled into
something as fast as compiled Lisp? From this above website and
others, I've learned that compiled Lisp can be nearly as fast as C/C++,
so I don't understand why Python can't also eventually be as efficient?
Is there some *specific* basic reason it's tough? Or is it that this
type of problem in general is tough, and Lisp has 40+ years vs Python's
~15 years?


i'm not sure it'll answer question, but Brett cannon's thesis is good
background

http://www.ocf.berkeley.edu/~bac/thesis.pdf

Feb 19 '06 #4
On Sat, 18 Feb 2006 23:35:27 -0600, DH wrote:
I'm wondering if someone can explain to me please what it is about
Python that is so different from Lisp that it can't be compiled into
something as fast as compiled Lisp? From this above website and
others, I've learned that compiled Lisp can be nearly as fast as
C/C++, so I don't understand why Python can't also eventually be as
efficient? Is there some *specific* basic reason it's tough? Or is it
that this type of problem in general is tough, and Lisp has 40+ years
vs Python's ~15 years?
It is by design.


You make it sound like Guido sat down to design a language and
deliberately put "Slow" first on his list of desired attributes. Why such
a negative tone to your post?

Python is not slow by design. Python is dynamically typed by design, and
relative slowness is the trade-off that has to be made to give dynamic
types.

The Python developers have also done marvels at speeding up Python since
the early days, with the ultimate aim of the PyPy project to make Python
as fast as C, if not faster. In the meantime, the question people should
be asking isn't "Is Python fast?" but "Is Python fast enough?".
Python is dynamically typed. It is essentially an
interpreted scripting language like javascript or ruby or perl, although
python fans will be quick to tell you python is compiled to byte code.
You make it sound like Python fans are bending the truth. That Python
compiles to byte-code is an objective fact which can be learnt by anyone,
not just "Python fans". In that regard, Python is closer to Java than Perl
or Javascript. Only without the slow startup time of the JRE.

They'll also be quick to tell you:
-python has true closures (although nothing like ruby's blocks)
They're also nothing like Pascal's with statements either. Why make the
comparison with Ruby's blocks when the original poster is comparing Python
to Lisp?

-is beginner friendly (despite being case sensitive and 3/4==0, for
example)
Case sensitivity isn't beginner unfriendly. It is sloppy thinker
unfriendly. Whether you have been programming for thirty days or thirty
years, if you don't know the difference between foo and FOO you have a
serious problem. As they say, case is the difference between "I helped my
Uncle Jack off a horse" and "I helped my uncle jack off a horse."

As for the difference between integer division and true division, yes,
that was an unfortunate design decision. Fortunately it is being rectified
in the least painful way possible.

-is not, in fact, slow at all (despite benchmarks as you noted showing
otherwise).


I've asked this question before, but obviously there is a particular
mindset that just doesn't get it. Slow compared to what? Slow to do what?

For those who don't understand the difference between "faster" and "fast
enough", perhaps a simple analogy will bring enlightenment. For most
people, under most circumstances, an ordinary car (top speed around 75
mph or so) is fast enough, more convenient, and much better value for
money than the significantly faster F-15 fighter plane (top speed around
1850 mph).

On modern hardware, for the vast majority of applications, the execution
speed of the language is not the limiting factor. I/O or the algorithm is
usually the limiting factor. "Change your algorithm" is often better
advice than "change your language".

That's not to say that Python isn't objectively SLOWER (note the
relative term, not absolute) than some languages. But execution speed is
rarely the most important factor in choice of a language.

For those tasks that language speed is a limiting factor (say, writing
devise drivers, operating systems, and similar), Python may not be fast
enough. But they are the exception rather than the rule, and there are no
shortage of ways around that: Psycho, C extensions, or even "choose
another language".

--
Steven.

Feb 19 '06 #5
> what [is it] about Python that is so different from Lisp that it
can't be compiled into something as fast as compiled Lisp?


IMO, it's the lack of competing implementations .

LISP has a very well-defined ANSI specification. Lots of different
people have written LISPs, from Franz to Steel Bank to GNU to... etc.
Each of these competes with the others on different grounds; some are
purely interpreted (ala CLISP), some are compiled (CMUCL), some are...
etc. They all implement substantially the same language, but the
plethora of different implementations has been a tremendous boon for
the development of efficient compilers, interpreters and garbage
collectors.

By comparison, Python lacks anywhere near as many competing
implementations .

In some respects the lack of competing implementations is a Good Thing.
In some respects it's a Bad Thing. On balance it's just a thing.

Feb 19 '06 #6
The question about the speed is interesting. Generally the more dynamic
and flexible your language is, the slower are the programs it produces.
Lisp is almost unique in such matters (and in this regard it's maybe
better than CPython) because it allows the programmer to mix and blend
different levels of how much dynamism and how much optimized a part of
the program has to be. When you want to speed up a part of a Lisp
program (often developed starting from a slow but flexible code) you
start to use more specific functions, unboxed variables, simple arrays
of unboxed data, statically typed variables, etc. It's not easy, but if
you have some experience, often than one year, in that way you can
write programs only 20% or 50% slower than ones written in C, so for
most purposes they become fast enough. On the other hand you can
develop the program using an interactive shell and a dynamically typed
language, that speeds you a lot the prototyping, etc. You can have the
best of both things.
Python allows to mix various blends too (Psyco, Pyrex, ShedSkin, Weave,
SWIG, glues for Fortran and C/C++, etc), but in Lisp such blending
seems much more natural, finer grained, integrated in the language.
I think this isn't a limit of the language itself, because with enough
work two tools like Psyco and ShedSkin can become integrated in the
language itself (I think Psyco and SS are enough for 98% or purposes)
producing something not far from the "optimizati on flexibility" of
Lisp. Psyco compiles just in time some code, ShedSkin is more
aggressive, but if it becomes developed enough it can produce programs
fast as C/C++ ones with the same syntax of Python (some things aren't
supported). So then you can develop a program like in Lisp, where some
parts aren't optimized, some parts are compiled just in time, and other
critical parts are type inferenced and statically compiled for the max
speed (this requires to join ShedSkin with something like Swig, to
allow a natural, fully automatic and pythonic joining of .PYDs produced
by SS and CPython programs). PyPy can probably solve such problems in
similar ways or better, we'll see.

Bye,
bearophile

Feb 19 '06 #7
DH <no@spam.com> wrote:
-python has true closures (although nothing like ruby's blocks)


What is a "true closure"? Or, maybe what I'm asking is what kind of
closure wouldn't be a true closure? Is there some kind of ersatz closure
other language try to pass off, in violation of truth in closure laws?
Feb 19 '06 #8
"Robert J. Hansen" <ci********@gma il.com> wrote:
LISP has a very well-defined ANSI specification. Lots of different
people have written LISPs, from Franz to Steel Bank to GNU to... etc.
Each of these competes with the others on different grounds; some are
purely interpreted (ala CLISP), some are compiled (CMUCL), some are...
etc. They all implement substantially the same language, but the
plethora of different implementations has been a tremendous boon for
the development of efficient compilers, interpreters and garbage
collectors.


It's been a while since I've dabbled in lisp, but my recollection is that
the plethora of different implementations has also meant that portability
is a fantasy.

I dread the day that competing Python implementations spring up.
Feb 19 '06 #9
Hallöchen!

Roy Smith <ro*@panix.co m> writes:
[...]

It's been a while since I've dabbled in lisp, but my recollection
is that the plethora of different implementations has also meant
that portability is a fantasy.

I dread the day that competing Python implementations spring up.


Even worse: In one of them Microsoft is involved.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus ICQ 264-296-646
Feb 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
34362
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
303
17868
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
6
2621
by: Simo Melenius | last post by:
Hi, I'm wondering (after a bit of googling) whether there exists a Python binding to any open source Lisp environment (like librep or some Scheme or Common Lisp implementation) that could be recommended for non-toy use? My intention would be to use the Lisp environment to augment and help my Python programming (and/or conversely: have access to the wealth of Python libraries and Python code from a lispy language), which yields
0
1096
by: Simo Melenius | last post by:
I'm posting a self-followup to my post in last December about Python and Lisp integration: <URL:http://groups-beta.google.com/group/comp.lang.python/msg/ff6345845045fb47?hl=en> Now, just yesterday I just stumbled upon Lython: <URL:http://www.caddr.com/code/lython/> It's a bit edgy but it can be made to work :-). It does do simple
37
2912
by: seberino | last post by:
I've been reading the beloved Paul Graham's "Hackers and Painters". He claims he developed a web app at light speed using Lisp and lots of macros. It got me curious if Lisp is inherently faster to develop complex apps in. It would seem if you could create your own language in Lisp using macros that that would be quite an advantage.... I realize that Python has operator overloading and OOP so I'm not sure.
12
1512
by: Tolga | last post by:
Hi everyone, I am using Common Lisp for a while and nowadays I've heard so much about Python that finally I've decided to give it a try becuase Python is not very far away from Lisp family. I cannot believe this! This snake is amazing, incredible and so beautiful! You, Pythonists, why didn't you tell me about this before? :-)
267
10912
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at http://www.artima.com/weblogs/viewpost.jsp?thread=147358
21
1731
by: Alok | last post by:
While posting a comment on http://www.reddit.com I got an error page with the following curious statement on it. "reddit broke (sorry)" "looks like we shouldn't have stopped using lisp..." See screenshot at http://photos1.blogger.com/blogger/1773/1980/1600/reddit-broke.jpg Whether they truly repent not using lisp or otherwise, their site
852
29025
by: Mark Tarver | last post by:
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
0
9709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5694
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4085
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3140
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.