473,813 Members | 3,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

merits of Lisp vs Python

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

Dec 8 '06
852 28832
Juan R. wrote:
I see no dinamism on your example, just static overloading.
There's nothing static about it:

q = raw_input()
if q == "A":
a = 1
b = 2
else:
a = "x"
b = "y"
c = a + b

There is no way that the compiler can statically
determine what the + operator needs to do here.

--
Greg
Dec 13 '06 #561
Espen Vestre wrote:
Paul Rubin <http://ph****@NOSPAM.i nvalidwrites:
there is a huge amount of
state scattered all through a running Python program, that the
application can modify at random

That's what I call /kludgy/, not /dynamic/ ;-)
I think "kludgy" is a bit unfair, since this is a
result of doing things in a very simple and uniform
way -- rather a Lispy concept, I would have thought. :-)

--
Greg
Dec 13 '06 #562
Paul Rubin wrote:
I think the Lispies see "more dynamism" as a good thing and are
therefore defending their language from suggestions that Python is
even more dynamic than Lisp. I mean "dynamic" in a less good way--
Indeed, Python has sometimes been described
as "pathologic ally dynamic". All that dynamism
is handy sometimes, but it does get in the
way of improving efficiency.

Often discussions take place on python-dev
about ways to selectively limit the dynamism
to make some optimisation possible.

--
Greg
Dec 13 '06 #563
George Sakkis wrote:
I'm sure there should be more convincing examples for macros, but
neither this nor the 'unless' syntax sugar cuts it.
Also, the new 'with' statement and associated
protocol covers much of the ground that was left
out by the existing constructs.

--
Greg
Dec 13 '06 #564


Markus Triska wrote:
Ken Tilton <ke*******@gmai l.comwrites:

>>I think all-rules-all-the-time Prolog is the poster boy for paradigm
slavery. (I did try for a famous two months to use Prolog as a
general-purpose programming language.)


Don't expect to learn Prolog properly in so little time.
Lawdy, no, but I had all those Art of Prolog and Craft of Prolog and a
couple other books and I was staring at pages of intense code just
trying to do basic stuff. I had not learned prolog, but I could see the
masters writing hairy code to basic stuff so I concluded...run away! run
away! :)

I think the other thing that got me was cuts, which I translated as "did
we say unification all the time? sorry..." :)

To your
previous question whether the ~180 lines of Lisp code in some online
book constitute an "industrial strength" Prolog: only if the following
~180 lines of Prolog code implement an "industrial strength" Lisp.
<snip lisp-in-Prolog>

Way cool.

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
Dec 13 '06 #565


Robert Uhl wrote:
"Stephen Eilert" <sp******@gmail .comwrites:
>>So, let's suppose I now want to learn LISP (I did try, on several
occasions). What I would like to do would be to replace Python and
code GUI applications. Yes, those boring business-like applications
that have to access databases and consume those new-fangled
web-services and whatnot. Heck, maybe even code games using DirectX.


GUIs are a weak point, or were last I looked.
LW comes with CAPI, portable across the big 3. ACL has Common Graphics
on win32, and I think they have Gtk bindings elsewhere (just guessing,
really). Everyone has Ltk, Cells-Gtk, and Celtk. (Two Tks, one Gtk if
that is not clear).

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
Dec 13 '06 #566
On 2006-12-13, hit_the_lights <la********@gmx .atwrote:
Neil Cerutti schrieb:
> a[i] = b[n]

with

(setf (aref a i) (aref b n))

and the attractions of Python may make more sense.

Here Python and Lisp are equal, 7 tokens vs 7 tokens, but in
Python one has to write less since "[]" are 2 chars while
"aref" are 4, plus the setf. But from counting the brain
units which I regard as an important factor they are both
equal.

A comparison of brain units of the above snippets is
irrelevant, since the snippets are not equivalent.

The Python snippet will work for any object a that provides
__setitem__ and any object b that provides __getitem__.

I don't know what an equivalent Lisp snippet would be (or even
exactly how close the above snippet comes to matching the
Python code), but whatever it is would be a better foundation
for comparing brain units with the above Python.

It would be exactly like the example given, just "aref"
replaced with something else. An example implementation:

============== =============== =============
(defgeneric $ (container key))
(defgeneric (setf $) (value container key))

;;; Implementation for arrays

(defmethod $ ((container array) (key integer))
(aref container key))

(defmethod (setf $) (value (container array) (key integer))
(setf (aref container key) value))
============== =============== =============

And usage:

============== =============== =============
CL-USER(3): (defparameter a (vector 1 2 3 4 5))
A
CL-USER(4): ($ a 0)
1
CL-USER(5): (setf ($ a 0) 9)
9
CL-USER(6): a
#(9 2 3 4 5)
============== =============== =============

The nice thing is, that you *can* dispatch on the container,
the key and the value.
That's cool. Thanks for posting the code.

Is the above 'duck-typing' idiom considered very useful to a
Lisper? It seems logical to me that duck-typing works best in an
environment where it is ubiquitous. If users have to implement
accessors specifically to use your library, it is not as good as
if they had already implemented one as a matter of routine.

--
Neil Cerutti
Dec 13 '06 #567

Bjoern Schliessmann wrote:
Robert Uhl wrote:
Because it's the language for which indentation is automatically
determinable. That is, one can copy/paste a chunk of code, hit a
key and suddenly everything is nicely indented.

Cool, so in other languages I need to set block marks like () and {}
and also indent the code for readability, and in Python I indent
only. From my POV that's less work.
Try reading again. In Lisp, you use () and *your editor* automatically
indents according to the universal standard, or you leave it sloppy
until other folks reading your code convince you to get a proper
programming editor. Indentation does not get out of sync with semantics
because the editor virtually never misses parentheses that the Lisp
compiler sees. Expressions keep the same meaning even if you have to
start breaking them across lines, etc.

In Python, you group in your mind, and press indentation keys to make
it happen in your editor. The editor cannot help that much, because it
cannot read your mind. White space screwups in copy-paste cannot be
fixed by the editor automatically, because it cannot read the original
programmer's mind, and you have to fix it manually, and risk screwing
it up.

Dec 13 '06 #568
Robert Uhl wrote:
"JS******@gmail .com" <JS******@gmail .comwrites:
I have the code here (probably not the latest bcs I left the company
when it was acquired), let's do a little experiment, for what it's
worth: 89727 lines of Lisp code in 131 modules (lisp code files), 3306
"(defun" (by grep|wc), and 261 "(defmacro" . [We did NOT use macros as
functions!] [Note that lines of code doesn't really matter in Lisp.]

Wow--my emacs install has 1,152,598 lines of code in 1,570 files, 29,244
defuns and 1,393 defmacros. This really doesn't prove anything
whatsoever (as I imagine that your stuff was a _lot_ more complex),
except maybe how great the FSF is for giving away this sort of thing for
free.
Let us note that it's not FSF that gives this stuff away for free -- or
if it is them proximally, it is not them ultimately -- ultimately it's
the engineers who did all that work that gave it away for free.

Dec 13 '06 #569
On 2006-12-13, jo************@ hotmail.com
<jo**********@g mail.comwrote:
Try reading again. In Lisp, you use () and *your editor*
automatically indents according to the universal standard, or
you leave it sloppy until other folks reading your code
convince you to get a proper programming editor. Indentation
does not get out of sync with semantics because the editor
virtually never misses parentheses that the Lisp compiler sees.
Expressions keep the same meaning even if you have to start
breaking them across lines, etc.
Yes, it's the same way in Python. Of course, not everything is an
expression in Python, so it's not saying quite as much.
In Python, you group in your mind, and press indentation keys
to make it happen in your editor. The editor cannot help that
much, because it cannot read your mind. White space screwups in
copy-paste cannot be fixed by the editor automatically, because
it cannot read the original programmer's mind, and you have to
fix it manually, and risk screwing it up.
It is very easy a manual process, possibly as simple as selecting
the correct s-expr and pasting it into the right place in your
code.

--
Neil Cerutti
Dec 13 '06 #570

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

Similar topics

14
2196
by: Paddy3118 | last post by:
This month there was/is a 1000+ long thread called: "merits of Lisp vs Python" In comp.lang.lisp. If you followed even parts of the thread, AND previously used only one of the languages AND (and this is the crucial bit), were persuaded to have a more positive view of the other language; (deep breath, this is a long, as well as grammatically incorrect sentence), THEN WHY NOT POST ON WHAT ARGUMENTS PERSUADED YOU.
0
9607
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,...
1
10417
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
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9220
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
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
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
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
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
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.