473,788 Members | 2,744 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 28749
André Thieme <ad************ *************** *@justmail.dewr ites:
But there would be even more tokens, the lines going between the
nodes
in the trees, for example.

These are painted by the editor.
If you have to tell the editor where to put them, they are tokens.
Dec 16 '06 #721
André Thieme <ad************ *************** *@justmail.dewr ites:
How complicated ss it to say "cmp(a, b)" compared to "a cmp b"?
It gets worse when the expressions are nested.

So instead of
cmp(foo(a, b, c), bar(x, y, z)) you would prefer
foo(a, b, c) cmp bar(x, y, z) ?
Don't be silly. Some operators are more natural as infix and others
as functions. It's just like in natural language. People have an
innate ability to make such distinctions and it's fine for a
programming language to use it.
Dec 16 '06 #722
In article <7x************ @ruckus.brouhah a.com>,
Paul Rubin <http://ph****@NOSPAM.i nvalidwrote:
Don't be silly. Some operators are more natural as infix and others
as functions. It's just like in natural language. People have an
innate ability to make such distinctions and it's fine for a
programming language to use it.
I don't think you can really make this case. In English, German and
Spanish noun-verb order is flexible to accommodate differences in
mood, tense, and emphasis:
"Add 2 and 2." imperative.
"The sum of 2 and 2" noun phrase.
"2 was added to 2." passive voice.

Personally, I've always preferred use the imperative to describe
basic math rather than the passive. This would seem to map better to
RPN than infix.

And on top of that, some languages are even more flexible in regard
to word order, preferring to communicate relationships through the
modification of noun stems. In such a language, "He* her- the ring+
gave," is just as valid as "Her- the ring+ gave he*" and "He* gave
her- the ring+." ("+/-/*" signifying modifications which do not
exist in modern English.)

At any rate, I find this argument to be weak given that English
doesn't always use the same word order. And English is just one
language out of hundreds.
Dec 16 '06 #723
Kirk Sluder <ki**@nospam.jo bsluder.netwrit es:
Personally, I've always preferred use the imperative to describe
basic math rather than the passive. This would seem to map better to
RPN than infix.
For writing down complicated, nested expressions too? That's very
unusual. E.g.

n! = (n/e)**n * sqrt(2*pi*n) * (1 + (1/12n)) * ...

vs. the same thing in Lisp notation, and that's not even so complicated.
Dec 16 '06 #724
Ken Tilton wrote:
McCarthy: "Is code also data in Python?"
Norvig: "No."
I don't think that was the right answer. He should have
said "Yes", and then shown McCarthy eval() and exec.

Code isn't quite as *convenient* to work with as data
in Python as it is in Lisp, but that doesn't mean it
can't be done.

(I agree that the proffered example was not an instance
of "code is data", though.)

--
Greg
Dec 16 '06 #725


greg wrote:
Ken Tilton wrote:
>McCarthy: "Is code also data in Python?"
Norvig: "No."


I don't think that was the right answer.
Norvig is a smart guy. He was talking to John McCarthy. He gave the
right answer. :)
He should have
said "Yes", and then shown McCarthy eval() and exec.
No, in those cases the Python interpreter is still dealing with the
code, not the user's application code. As a meta-developer (to coin a
word) I want to be able to write code that takes apart other code I
write to do useful things with it /without writing a parser for my
chosen language/. I just found a bug in ACL that might be instructive.

The defskill macro I have been writing might be coded like this:

(defskill abs-value
(category "Algebra I" "Real Numbers")
....)

(I am kinda mirroring defclass here, which looks like:

(defclass <name<superclas ses>*
(<slot-defs>*)
...and then optional sub-specs each keyed by the first symbol..
(:documentation "chya")
(:metaclass...)
(:default-initargs)))

Come to think of it, I might have made /my/ options :keywords just to
make the resemblance stronger (and yes I am digressing into the bit
about how Lispniks by convention stay recognizable with new syntax).

Anyway, I decided to do a little auto QA and add an assertion to make
sure I did not inadvertently leave out the category option (long story,
I am not usually so anal), so defskill starts like this:

(defmacro defskill (id &body skill-info)
(assert (find 'category skill-info :key 'car))...

That is just normal list code. The macro signature destructures the code
I write inside the defskill invocation into an id and a list of
following code ("&body skill-info" says "bind the rest of the code to
the local variable skill-info as a list"). the (find ... :key 'car)
walks down the list taking the car (first) of each list and comparing
against that which is being sought. Simple ol' Lisp.

I then expand the (somewhat) validated data/code:

(loop with sub-id = id
for (q . q-def) in skill-info
collecting
(ecase q
(category <return desired Lisp code>)
...etc...)

q for "quality" or "attribrute ". Not "o" for option. :) Again, using
standard loop destructuring on the option code/data.

Y'all need to get over it: we really are writing code that eats
code/data to produce code. Unaided by any parser other than the same
destructuring mechanisms we use on data.

ken

ps. I forgot the bug. I coded in the end:

(defskill |Absolute Value| ...etc..)

Where |absolute value| should be treated as a single symbol, and is by
the ACL compiler. An interactive macroexpand, however, misses that that
is one symbol and defskill (if you followed the Lisp) dies trying to
take the car of the atom VALUE (a symbol). k
Dec 16 '06 #726
Ken Tilton wrote:
I think your brain is stuck on flaming.
Sorry, I didn't mean to come across as flaming, far
from it. I'll take a deep breath before posting from
now on, I promise. :-)
I did explain the last little fun bit (where reverse code miraculously
got a case-specific "signed-value" parameter bound to exactly the right
bit of math structure).
I didn't mention that because it was addressed by
another poster. The signature of the user's reverse
function can be made extremely flexible if you have
the foresight to define it as something like

def reverse(resx, opnd, **kwds):
...

Then you can later change it to

def reverse(resx, opnd, signed_value, **kwds):
...

and any existing reverse functions will just absorb
and ignore the extra argument.

However, rather than add an ever-increasing number
of arguments to the signature, I think I would do it
a different way: pass a single object with attributes.
For the want of a better name, let's call it "env"
for "environmen t". The signature is then

def reverse(env):
...

and the body can refer to env.resx, env.opnd,
env.signed_valu e, or whatever else is required.

If this still doesn't cover the requirements, please
explain and I'll try to adapt it accordingly.

--
Greg
Dec 16 '06 #727
André Thieme wrote:
(aif (timeConsumingC alculation)
(use it))
I think the answer is that you just wouldn't do
that in Python at all. Having magic variables
spring into existence in your local namespace
as a side effect of calling something is just
not Pythonic. (It is very Perlish, on the other
hand.)

The closest you might come is using the new
"with" statement like this:

with aif(timeConsumi ngCalculation() ) as it:
use(it)

where the object returned by aif(x) has an
__enter__ method that raises an exception which
aborts the whole with statement if x is None,
thus avoiding executing the body. But that's
so horribly convoluted that any sane programmer
would just write it out the straightforward
way to begin with.
There's a Haskell builtin called 'seq' which forces evaluation but
again I'm not sure precisely how to apply it here.

So in some languages that support functional programming one needs to do
extra work to get lazyness, while in Haskell one gets extra work if one
doesn't want it.
Sort of, but it's more so that you can write code
that does things like I/O in what looks like a
procedural style, even though it's still purely
functional. Read about "monads" if you want to
know more -- it's truly mind-expanding (and
possibly head-exploding:-) stuff...

--
Greg
Dec 16 '06 #728
André Thieme wrote:
The thing with most (if not all) programming languages other than Lisp
is: these abstractions are leaky.
They have a low level knowledge leak. Users of aif need to know how to
pass in arguments. As you see he had do embed the code that needs execution
into a block (anon function) and then use this special syntax for x.
Yes, but all the standard looping constructs, etc.
in Ruby are expressed like this too. So it's
perfectly consistent with the rest of the language.
It's not something new that the user needs to learn
just to use this function.

This is even more evident in Smalltalk, where
*all* control structures, without exception, are
expressed in terms of code blocks, possibly
with parameters. And Smalltalk has no macros,
either, btw.

--
Greg
Dec 16 '06 #729
André Thieme wrote:
So instead of
cmp(foo(a, b, c), bar(x, y, z)) you would prefer
foo(a, b, c) cmp bar(x, y, z) ?
Incidentally, someone once came up with an fiendishly
clever hack that lets you write things in Python like

foo(a, b, c) |kmp| bar(x, y, z)

i.e. effectively define your own infix operators. And
it doesn't even require a macro. :-)

(Finding the trick to implementing this is left as an
exercise for the googler.)

--
Greg
Dec 16 '06 #730

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

Similar topics

14
2190
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
9498
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
10177
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
10118
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
9969
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
8995
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...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5403
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...
1
4074
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
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.