Python is King

Started by
13 comments, last by vtwin 21 years, 1 month ago
I know zippo about Lisp, and some VERY rudimentary facets of Python, but I did check out this site comparing Python vs Lisp

What surprised me was how slow Python was...I mean...it's..slower.....than............java(sorry ). Conversely, I was surprised at how fast Lisp was. Also, it mentions that basically Python is a dialect of Lisp with one crucial feature missing....macros.

Since I don't know Lisp, and therefore don't know what macros are, I'm not exactly sure how good/bad this is. From looking at the chart comparing the syntax...Lisp syntax does seem a bit odd, but at least it seems very consistent. Since basically both Lisp and Python are brand new to me, Python seems a little more intuitive to me...but I think I could pick up Lisp pretty easily from looking at it.

I'm thinking of tackling Python next because I hear it's good as a scripting language for game usage. Python supposedly has good hooks into C++, and it's also very extensible through its modules. Does Lisp offer the same features?



[edited by - dauntless on March 12, 2003 7:59:44 AM]
The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. We have grasped the mystery of the atom and rejected the Sermon on the Mount." - General Omar Bradley
Advertisement
ur link is messed up.
need to fix it.

also some C/C++ vs. Python code would be nice.
i like a good comparison.

honestly i could care less about speed and crap. i''m more
interested in good coding style and structure.

Beginner in Game Development?  Read here. And read here.

 

quote:Original post by bishop_pass
Imitation is the sincerest form of flattery. Did you know that I made the first ultimate thread as well? Now we''re going to see King threads.


Sorry, you lose! Please play again, though.

The first ultimate thread:
The Ultimate Game Survey, started by Raz.

This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
quote:Original post by Mithrandir
Sorry, you lose! Please play again, though.

Oh well.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
quote:Original post by bishop_pass
But does this help or hinder you? Part of the idea of Lisp is to get it to modify components of its own program at runtime, which means it needs to be able to pick it apart at runtime.

quote:Original post by vtwin
Personally I''ve never needed to employ something of that nature, so Lisp''s ability to do so has no bearing on me. Like I said, I have little experience with Lisp so my opinion is purely based on my history.

What''s being talked about is introspection , which Python can do aswell. Only, it''s a lot more difficult with Python since, like all Algol-derivatives, it has a two-level syntax (or three-level, but we''re not interested in the bytecode representation). Once you have an environment which puts a layer of arbitrary syntax between you and the abstract representation of your program, anything that you want to do to manipulate the abstract representation immediately becomes an order of magnitude harder.

For example, imagine you wanted to create a class on-the-fly. In Python, internal representation of objects consists of trees built with recursive dictionaries, which is exactly synonymous with Lisp cons cell structures (a cons cell is a two-item pair, and so is a dictionary entry). So to create a class, you would have to construct the class dictionary, and instantiate the class from some metaclass. To illustrate:

  def standard_initialiser(inst, x):	inst.x = xdef foo(inst):	print inst.x	def make_class(name, methods=[]):	classdict = {}	# add methods	for method in methods:		classdict[method.func_name] = method	# add constructor	classdict[''__init__''] = standard_initialiser	# "type" is the metaclass...	return type.__new__(type, name, (), classdict)C = make_class(''C'', [foo])c = C(10)c.foo() # prints ''10''  

So, it is easy to see that the Python syntax is far removed from the internal syntax of recursive dictionaries. In Lisp, you could achieve the same thing by building an s-expression and submitting it to DEFCLASS, where the s-expression *is* the abstract representation. i.e. you build the class the same whether you do it at runtime or compile-time.

It is easy to say that the ability to do such things has no bearing on you when your language makes it hard for you to think about them. I doubt that these abilities aren''t useful to you, just that the syntactic barriers in Python makes it harder to conceptualise how they might be useful.
quote:Original post by Dauntless
What surprised me was how slow Python was...I mean...it''s..slower.....than............java(sorry ). Conversely, I was surprised at how fast Lisp was. Also, it mentions that basically Python is a dialect of Lisp with one crucial feature missing....macros.

There''s more features missing, but whether they are crucial depends on your point of view. For example, program compilation is not a standard feature of Python. Neither are declarations, which are useful for providing information to the compiler for optimisations. There''s also something extra that Python has which takes something away, and this is the extra layer of syntax I described above. Lisp''s syntax looks "funny" for a reason. To seamlessly add macros into Python, it would have to adopt a Lisp-style syntax, otherwise there would always be a syntactic barrier to building recursive dictionary structures. Since macros are about manipulating code as if it were data, you need the same representation for code and data.
quote:
I''m thinking of tackling Python next because I hear it''s good as a scripting language for game usage. Python supposedly has good hooks into C++, and it''s also very extensible through its modules. Does Lisp offer the same features?

Yes.

This topic is closed to new replies.

Advertisement