473,800 Members | 2,602 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 28784
Willem Broekema wrote:
Paul Rubin wrote:
Does this count as a "children of a lesser Python"?

This sounds like a quite derogatory first question.
I wouldn't take it that way: it's only a quote from an opinion piece
about alternative Python implementations (albeit a contentious one).
CLPython is not a dead and abandoned project, nor is execution speed
its main goal, nor are Python semantics bended anywhere (it can run
the Pie-thon benchmark). Sure, some recently introduced language
features are missing, but with just a little effort that's solved...
What would it take to get Python people more interested in it? I've
been monitoring the site [1] and the mailing list [2] for some time,
but nothing particularly visible seems to be happening. And wouldn't a
more prominent announcement be the first step to some real publicity? I
think it only got announced on comp.lang.lisp [3] with someone picking
up on it in comp.lang.pytho n. Perhaps getting it on the python.org
front page would attract some attention, although I accept that a lot
of Python developers would rather mess around writing C than writing
Lisp.

Anyway, I'm happy to hear that you're still working on CLPython.

Paul

P.S. Follow-ups set to comp.lang.pytho n.

[1] http://trac.common-lisp.net/clpython/
[2] http://common-lisp.net/pipermail/clpython-devel/
[3] http://groups.google.com/group/comp....ae88c5f9a59143

Dec 14 '06 #621
Actually, in English, "parenthesi s" means the bit in between the
brackets.

The various kinds of brackets (amongst other punctuation marks
including, in most english texts, commas) *demarcate* parentheses.

Wikipedia's "Parenthesi s (rhetoric)" is, at time of writing, the correct
British English definition, citing the OED:
http://en.wikipedia.org/wiki/Parenthesis_%28rhetoric%29

"An explanatory or qualifying word, clause, or sentence inserted into a
passage with which it has not necessarily any grammatical connection,
and from which it is usually marked off by round or square brackets,
dashes, or commas"

The use of round brackets to demarcate parentheses in america eventually
somehow led to round brackets themselves being called parentheses in
america, but that usage still makes little sense to many native
speakers of British (or Hiberno-) English outside the computing field.

It's like calling a quotation mark a "quote" instead of a "quotation
mark". And lo, guess who does that too...

Calling round brackets "parenthesi s marks" would be acceptable but
perhaps ambiguous in British English, probably needing further
qualification like "double quotation mark", "single quotation mark".




Dec 14 '06 #622


Ken Tilton wrote:
>

Paul Rubin wrote:
>Ken Tilton <ke*******@gmai l.comwrites:
>>Have you read On Lisp by Paul Graham? It is on-line. Just the preface
will do, I think, maybe also Chapter One where he raves on macros. Do
you think he is mistaken? Confused? Lying? Mutant?

I remember Paul Graham's piece about macros that made him sound like
someone who went nuts with them, as is certainly possible to do.


But you could have just flipped thru the rest of the pages to see if he
/had/ gone nuts with them!
> In
my experience, good coders write for clarity and that includes in
their use of Lisp macros. All in all Lisp's macro system is something
like the C preprocessor. Yes, you can obfuscate things horribly with
it, but you can also use it to make things clearer, and that's what
good programmers do.


One has to be from the US and of a certain age to remember this, but
this old line from a commercial for high-octane gasoline says it for me:
power to be used, not abused.
Here is a bit of concrete I just tossed off:

(defmacro defskill (id &body skill-info)
`(progn
,@(loop with sub-id = id
for (q . q-def) in skill-info
collecting
(ecase q
((title annotations hints)
`(defmethod ,(intern (conc$ 'skill- q)) ((tf-id (eql
',sub-id)))
,@q-def))))))

It lets me code this:

(defskill absolute-value
(title "Absolute Value")
(annotations
"Take the absolute value of #op#."
"The vertical bars around #op# mean 'the absolute value of' #op#."
"Absolute value of #strn# is the 'distance' of #strn# from zero."
"Absolute value is always zero or positive: #str|n|=n#, and
#str|-n|=n#.")
(hints
"What do those vertical bars around #op# mean?"
"Have you learned about 'absolute value'?"
"Absolute value can be thought of as the 'distance' of a value from
zero on the number line, and distance is always positive."
"The rule is:#str|-n|=|n|##str=n#. Can you apply that to #op#?"
"Some examples: #str|+42|=42#, #str|-42|=42#, and #str|0|=0#."
"To get the absolute value of a number such as #op#, we simply drop
any minus sign."))
....and get this:

(PROGN
(DEFMETHOD SKILL-TITLE ((TF-ID (EQL 'ABSOLUTE-VALUE)))
"Absolute Value")
(DEFMETHOD SKILL-ANNOTATIONS ((TF-ID (EQL 'ABSOLUTE-VALUE)))
"Take the absolute value of #op#." "The vertical bars around #op#
mean 'the absolute value of' #op#."
"Absolute value of #strn# is the 'distance' of #strn# from zero."
"Absolute value is always zero or positive: #strn=n#, and #str-n=n#.")
(DEFMETHOD SKILL-HINTS ((TF-ID (EQL 'ABSOLUTE-VALUE)))
"What do those vertical bars around #op# mean?" "Have you learned
about 'absolute value'?"
"Absolute value can be thought of as the 'distance' of a value
from zero on the number line, and distance is always positive."
"The rule is:#str-n=n##str=n#. Can you apply that to #op#?" "Some
examples: #str+42=42#, #str-42=42#, and #str0=0#."
"To get the absolute value of a number such as #op#, we simply
drop any minus sign."))

The above is how my upcoming death-defying interactive Algebra
tutor-in-a-drum ("You'll laugh! You'll cry!") will know how to coax some
befuddled teen through |-42| -42 if they get stuck. And a hundred
other subskills (so there will be a hundred of these definitions).

If I hire someone they will look at defskill and not fall to the ground
frothing at the mouth. They likely will not even macroexpand it because
it is self-explanatory. If they wonder if there are other options they
can alt-. to the source. The language has been extended, but I followed
a pattern familiar to Lispniks. Zero confusion results.

If I decide not to use generic method dispatch to "look up" the hints I
just have to change the macro and then write a DEFUN (no dispatch on
type) to, say, look up the symbol in a hash table.

hth,ken

ps. I won't mention the other benefit, which is that I want educators to
edit these if they have a better idea on how to tutor absolute value. I
am not mentioning it because I am as impatient with superfluous syntax
as a non-programmer would be. k

pps. How would Python do this? Is it possible to avoid committing to an
implementation mechanism? Compare and contrast. k

--
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 14 '06 #623
Ken Tilton <ke*******@gmai l.comwrites:
pps. How would Python do this? Is it possible to avoid committing to
an implementation mechanism? Compare and contrast. k
You'd just write a function. Python's expression syntax is comparable
to a Lisp reader (you can have nested values of mixed types etc.) so
you can use Python expressions to initialize pretty much anything.
Dec 14 '06 #624
Ken Tilton wrote:
pps. How would Python do this?
Here's one way it could look:

defskill("absol ute-value",
title = "Absolute Value",
annotations = [
"Take the absolute value of #op#.",
"The vertical bars around #op# mean 'the absolute value of' #op#.",
"Absolute value of #strn# is the 'distance' of #strn# from zero.",
"Absolute value is always zero or positive: #str|n|=n#, and #str|-n|=n#."
],
hints = [
"What do those vertical bars around #op# mean?",
"Have you learned about 'absolute value'?",
"""Absolute value can be thought of as the 'distance' of a value from
zero on the number line, and distance is always positive.""",
"The rule is:#str|-n|=|n|##str=n#. Can you apply that to #op#?",
"Some examples: #str|+42|=42#, #str|-42|=42#, and #str|0|=0#.",
"""To get the absolute value of a number such as #op#, we simply drop
any minus sign."""
]
)
Is it possible to avoid committing to an
implementation mechanism?
The defskill function could do just about anything with this.
Here's one possibility:

skills = {}

class Skill:
pass # fill in whatever methods you need here

def defskill(name, title, annotations, hints):
skill = Skill()
skill.title = title
skill.annotatio ns = annotations
skill.hints = hints
skills[name] = skill

This gives you a dictionary of Skill instances indexed by name,
each one having a title and lists of annotation and hint strings.
The rest of the system can process this however required.

--
Greg
Dec 14 '06 #625


greg wrote:
Ken Tilton wrote:
>pps. How would Python do this?


Here's one way it could look:

defskill("absol ute-value",
title = "Absolute Value",
annotations = [
"Take the absolute value of #op#.",
"The vertical bars around #op# mean 'the absolute value of' #op#.",
"Absolute value of #strn# is the 'distance' of #strn# from zero.",
"Absolute value is always zero or positive: #str|n|=n#, and
#str|-n|=n#."
],
hints = [
"What do those vertical bars around #op# mean?",
"Have you learned about 'absolute value'?",
"""Absolute value can be thought of as the 'distance' of a value from
zero on the number line, and distance is always positive.""",
"The rule is:#str|-n|=|n|##str=n#. Can you apply that to #op#?",
"Some examples: #str|+42|=42#, #str|-42|=42#, and #str|0|=0#.",
"""To get the absolute value of a number such as #op#, we simply drop
any minus sign."""
]
)
Is it possible to avoid committing to an
implementation mechanism?

The defskill function could do just about anything with this.
Here's one possibility:

skills = {}

class Skill:
pass # fill in whatever methods you need here

def defskill(name, title, annotations, hints):
skill = Skill()
skill.title = title
skill.annotatio ns = annotations
skill.hints = hints
skills[name] = skill

This gives you a dictionary of Skill instances indexed by name,
each one having a title and lists of annotation and hint strings.
The rest of the system can process this however required.
Ok, not too bad, not much syntax in there. But now I have a tougher
requirement for you, which I noticed only after posting. (I tried
running the damn thing and it whined about not knowing how to "reverse"
absolute-value (to clone one problem into a similar problem).) A
reversal must be able to yield any given a result, and sometimes must
use given operands already settled on by the larger reversing algorithm.
In the simpler case, to reverse absolute-value with result 42 we produce
either |42| or |-42|. In the more complicated case, the multiply-literal
reverser may discover 6 is an operand and 42 is the result (meaning it
does no randomization, it just supplies the (* 6 7) reversal. Why am I
telling you all this? I don't know. The point is, we need code (not just
data) in defskill (apologies for nasty formatting):

(defmacro defskill (id &body skill-info)
`(progn
,@(loop with sub-id = id
for (q . q-def) in skill-info
collecting (ecase q
((title annotations hints)
`(defmethod ,(intern (conc$ 'skill- q))
((tf-id (eql ',sub-id)))
(list ,@q-def)))
(reverse
`(defmethod tf-reverse ((id (eql ',sub-id))
resx opnds)
(declare (ignorable resx opnds))
,@q-def))))))

--------------- (Abbreviated) Example.... ------------------------------

(defskill absolute-value
(title "Absolute Value")
(annotations
"Absolute value is always zero or positive: #str|n|=n#, and
#str|-n|=n#.")
(hints
"What do those vertical bars around #op# mean?")
(reverse
(ensure-cloning resx
(make-instance 'mx-number
:value (loop with op1 = (car opnds)
with log = (max 1 (ceiling (log (abs (value op1)) 10)))
for n = (* (signum (value op1))
(+ 2 (random (expt 10 log))))
when (/= n (value op1))
return n)
:representation (representation resx)))))

-------------- Producing.... ---------------------------------
(progn (defmethod skill-title ((tf-id (eql 'absolute-value))) (list
"absolute value"))
(defmethod skill-annotations ((tf-id (eql 'absolute-value)))
(list "absolute value is always zero or positive: #strn=n#,
and #str-n=n#."))
(defmethod skill-hints ((tf-id (eql 'absolute-value)))
(list "what do those vertical bars around #op# mean?"))
(defmethod tf-reverse ((id (eql 'absolute-value)) resx opnds)
(declare (ignorable resx opnds))
(ensure-cloning resx
(make-instance 'mx-number :value
(loop with op1 = (car opnds) with log = (max 1 (ceiling
(log (abs (value op1)) 10))) for n =
(* (signum (value op1)) (+ 2 (random (expt 10
log)))) when (/= n (value op1)) return n)
:representation (representation resx)))))

How close can Python get when code is involved? The reverse function
signature is fixed, so can lambda help?

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 14 '06 #626

Ken Tilton wrote:
(apologies for nasty formatting):
;-)

- Paddy!

Dec 14 '06 #627


Paul Rubin wrote:
Ken Tilton <ke*******@gmai l.comwrites:
>>don't know. The point is, we need code (not just data) in defskill
(apologies for nasty formatting):


Man that whole thing is messy. I can't for the life of me understand
why it's so important to use a macro for that. Even in Lisp, I'd
probably set up the reverse thingie as an auxiliary function.
And when you got to skill 42 and you discovered you needed a new
optional argument to the reversal method you would throw up your hands
and register for bartending school rather than go edit the other 41.

defskill is writing my code for me. When things change, I have it write
different code. Implementation is hidden, even from the programmer. I am
one step removed from the code when writing a macro. This is the "meta"
in metaprogramming .

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 14 '06 #628
Ken Tilton <ke*******@gmai l.comwrites:
Man that whole thing is messy. I can't for the life of me understand
why it's so important to use a macro for that. Even in Lisp, I'd
probably set up the reverse thingie as an auxiliary function.

And when you got to skill 42 and you discovered you needed a new
optional argument to the reversal method you would throw up your hands
and register for bartending school rather than go edit the other 41.
I don't see the problem. Python uses keyword args sort of like
Lisp's, and the called function (if it asks) receives a dictionary
containing any keyword args not bound explicitly in the arg list.
So you can invent new args whenever you want.
Dec 14 '06 #629


Ken Tilton wrote:
>

Paul Rubin wrote:
>Ken Tilton <ke*******@gmai l.comwrites:
>>don't know. The point is, we need code (not just data) in defskill
(apologies for nasty formatting):

Man that whole thing is messy.
I do not see much difference, except that the character count is 25%
less in the macro version:

(defskill absolute-value
(title "Absolute Value")
(annotations
"Absolute value of #strn# is the 'distance' of #strn# from zero."
"Absolute value is always zero or positive: #str|n|=n#, and
#str|-n|=n#.")
(hints
"Some examples: #str|+42|=42#, #str|-42|=42#, and #str|0|=0#."
"To get the absolute value of a number such as #signed-value#, we
simply drop any minus sign.")
(reverse
(ensure-cloning resx
(make-instance 'mx-number
:value (loop with op1 = (car opnds)
with log = (max 1 (ceiling (log (abs (value op1)) 10)))
for n = (* (signum (value op1))
(+ 2 (random (expt 10 log))))
when (/= n (value op1))
return n)
:representation (representation resx)))))

(defmethod skill-title ((tf-id (eql 'absolute-value)))
(list "absolute value"))

(defmethod skill-annotations ((tf-id (eql 'absolute-value)))
(list "absolute value of #strn# is the 'distance' of #strn# from zero."
"absolute value is always zero or positive: #strn=n#, and #str-n=n#."))

(defmethod skill-hints ((tf-id (eql 'absolute-value)))
(list "some examples: #str+42=42#, #str-42=42#, and #str0=0#."
"to get the absolute value of a number such as #signed-value#, we
simply drop any minus sign."))

(defmethod tf-reverse ((id (eql 'absolute-value)) resx opnds)
(declare (ignorable resx opnds))
(ensure-cloning resx
(make-instance 'mx-number :value
(loop with op1 = (car opnds) with log = (max 1 (ceiling (log (abs
(value op1)) 10))) for n =
(* (signum (value op1)) (+ 2 (random (expt 10 log)))) when
(/= n (value op1)) return n)
:representation (representation resx)))))
Let's lose the strings and count again, since they are a fixed cost. OK,
now the macro version is 30% shorter.
> I can't for the life of me understand
why it's so important to use a macro for that.
Pythonistas, when arguing about macros, always seem to forget that one
of the primary design imperatives of Python is cleaner code. Indentation
is use to avoid single characters { and }. But when macros come up you
all suddenly become the Mavis Beacon of programmers.

And, again, perhaps the bigger thing going on here is that the 30% is
boilerplate code representing implementation, which can change.

I don't know, perhaps the best argument against macros is that no
Pythonista wants them. That is actually a damn good reason.

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 14 '06 #630

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

Similar topics

14
2194
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
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
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...
0
10036
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
9092
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
6815
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
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
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.