Live data from Hacker News

Ask PG: Lisp vs Python (2010)

news.ycombinator.com

181–190 of 200 posts

Re: Ask PG: Lisp vs Python (2010)

#181
post #29

Earlier quoted context omitted.

> Obviously not having macros is a given in anything but Lisp At least these languages (that I know of) have macros: http://boo.codehaus.org http://nemerle.org http://www.perl6.org

True, but the syntax for all three of these is pretty hairy. Lisps might not be the only languages with macros, but they're the only ones with elegant and easy to use macro systems. You could argue of course this is a moot point, since even Lispers only write macros infrequently. So who cares if it's hard to write one on the rare occasion you need to?

I am amazed that people say Lisp is about macros. I think it's about being homoiconic. You can make some ugly form of macros in ANY language. Homoiconic-ness is what makes you want to make macros with Lisp. But it is much more than just about macros. Language REBOL is for example fully homoiconic.

  >> a: [ 300 3 ]
  >> insert a 'add
  >> probe a
  [ add 1 2 ]
  >> print first a
  add
  >> do first a 100 1
  == 101
  >> do a
  == 303
  >> f: func [] a
  >> f
  == 3
  >> change second :f 'subtract
  >> f
  == 297
all code is data (blocks of words and values).

From * Io * example below I would say it's a little different. It's more like it has a runtime api to change/generate it's runtime. I think SmallTalk has something similar to this.

* Factor * has compile time macros. At runtime it has quotations, which are blocks of code (separate from it's other data strucures I think, but don't shoot me if I'm wrong) that can be modified and executed by your code with few specific words like curry and compose. This means you have a little less freedom than in rebol where block of code is in no way different than a block of data. What is awesome about factor is that it also compiles quotations at runtime.

Otherwise Factor is very very cool, and I envy some runtime features of Io a lot.

And Python has as little to do with lisp as Visual Basic. Python is the world's best dynamic Imperative lang IMHO :)

Re: Ask PG: Lisp vs Python (2010)

#182
post #105

Earlier quoted context omitted.

A function definition is, in general, far away from the function call. If you think this problem is more severe for macros than for functions, then you should articulate why. You may well have a very valid point in your mind but I think it needs to be expressed somewhat more specifically.

For non-hygienic macros, it's essentially the variable capture problem. For hygienic macros, I don't know of a good argument that they are inherently more difficult to understand separately from their invocation than a function. (I'm not personally arguing against macros - or global variables for that matter - just trying to state the argument).

I think it should be obvious that you use programming constructs only when difficulty of understanding it is less than the difficulty of understanding code without it (over the whole program). This applies to functions, classes, macros, frameworks etc.

Full macros (like in CL where they are just functions that don't evaluate their arguments) give the programmer same power as compiler writer or programming language designer.

ps. To really get benefit from Lisp macros, you would need to standardize code walker. Without code walker, macros can't reach their full potential.

Re: Ask PG: Lisp vs Python (2010)

#183
post #180

Earlier quoted context omitted.

Macros can be used in python. There are a few libraries that help make it easier(so you do not need to manipulate the ast yourself). For example: @macro def macroname(arg1, arg2): ... macro contents ... There's some current information for you old time lispers, so next time you don't sound so dated in your Battles with Trolls in the great never ending language war flames ;)

Even if that happened to work correctly (which I don't believe), you would still be missing a bunch of macro-related stuff that makes CL the programmable programming language it is, and Python isn't: -reader-macros -symbol-macros -compiler-macros -macrolet -symbol-macrolet EDIT: Fixed layout

Well, those kinds of claims are kind of par for the course for the Python community. I remember that it was commonly claimed that Python 1.5 had the "full power of the lambda calculus", when all it had was anonymous function definitions, and not true higher order functions.

Re: Ask PG: Lisp vs Python (2010)

#184
post #29

Earlier quoted context omitted.

True, but the syntax for all three of these is pretty hairy. Lisps might not be the only languages with macros, but they're the only ones with elegant and easy to use macro systems. You could argue of course this is a moot point, since even Lispers only write macros infrequently. So who cares if it's hard to write one on the rare occasion you need to?

I am amazed that people say Lisp is about macros. I think it's about being homoiconic. You can make some ugly form of macros in ANY language. Homoiconic -ness is what makes you want to make macros with Lisp. But it is much more than just about macros. Language REBOL is for example fully homoiconic. >> a: [ 300 3 ] >> insert a 'add >> probe a [ add 1 2 ] >> print first a add >> do first a 100 1 == 101 >> do a == 303 >…

From Io example below I would say it's a little different. It's more like it has a runtime api to change/generate it's runtime. I think SmallTalk has something similar to this.

In Io, all code is data. Below is an example of changing a functions behaviour (from addition to subtraction):

    Io> plus := block (a, b, a + b)
    ==> method(a, b, 
        a + b
    )
    Io> plus call (1, 2)
    ==> 3
    Io> plus message next setName ("-")
    ==> -(b)
    Io> plus
    ==> method(a, b, 
        a - b
    )
    Io> plus call (1, 2)
    ==> -1
ref: Io Has A Very Clean Mirror (WayBackMachine copy) - http://web.archive.org/web/20080212010904/http://hackety.org...

Re: Ask PG: Lisp vs Python (2010)

#185

Earlier quoted context omitted.

I am amazed that people say Lisp is about macros. I think it's about being homoiconic. You can make some ugly form of macros in ANY language. Homoiconic -ness is what makes you want to make macros with Lisp. But it is much more than just about macros. Language REBOL is for example fully homoiconic. >> a: [ 300 3 ] >> insert a 'add >> probe a [ add 1 2 ] >> print first a add >> do first a 100 1 == 101 >> do a == 303 >…

From Io example below I would say it's a little different. It's more like it has a runtime api to change/generate it's runtime. I think SmallTalk has something similar to this. In Io, all code is data . Below is an example of changing a functions behaviour (from addition to subtraction): Io> plus := block (a, b, a + b) ==> method(a, b, a + b ) Io> plus call (1, 2) ==> 3 Io> plus message next setName ("-") ==> -(b) Io…

Very cool!

There are few properties about concurrency, coroutines, embed-ability, and I suppose nice process of making bindings that I value really a lot and Io HAS. Looking at your example, I will definitely look again at Io. Thanks!

Re: Ask PG: Lisp vs Python (2010)

#186

Earlier quoted context omitted.

What about Qi? What about Typed Racket?

One question I've had about Typed Racket since I first saw it: why all the colons? Seems to mess with the elegance of Lisp, and especially Scheme. There has to be another friendlier syntax for typing, no?

why not ? colons are used to denotes values type in ML

Re: Ask PG: Lisp vs Python (2010)

#187

Earlier quoted context omitted.

> I haven't used much CLOS, since ITA avoids it. Interesting. Is it for performance reasons?

...actually, I don't know. When I started, I was told we don't use it; I don't remember whether I was told a reason. If I was, it was performance; anything else would have been surprising enough to remember.

I wonder if it's similar to why Jane St doesn't make a lot of usage of the O in Ocaml (from what I've gathered at least, I don't work there.....yet). Object systems can be nice but they tend to make understanding your code all the harder since you have all the dispatching. I don't know anything about CLOS but this is pointed out as a reason against using Java and the object system in Ocaml in the Caml Trading video.

Re: Ask PG: Lisp vs Python (2010)

#188

Earlier quoted context omitted.

The problem with the Blub paradox is that there's no total ordering. I do Common Lisp and C++ at my day job (ITA), and I do much of my personal hacking in Python. In Python and C++ I miss macros; in Lisp and Python I miss RAII and strong typing; in Lisp and C++ I miss dictionary literals. And, in all of them, I miss algebraic datatypes.

What about Qi? What about Typed Racket?

Typed Racket combines all the inconvenience of type declarations with all the performance provided by a dynamic language.

Re: Ask PG: Lisp vs Python (2010)

#189
post #43

This question sounds like it's from 2005 rather than 2010. Lisp seems to have become fashionable again now, thanks to Clojure. I'm sure Python has very good libraries, but I would find it constraining to program in a language without proper macros.

The Python philosophy is that macros do more harm than good, making it harder for someone to read/understand your code in the long term. These and other "constraints" make the code more accessible to others and even yourself.

I wish there was a language called harmless which common folk could use to express common thought without any fear. It would go like this:

do this do this and that and that too do this amen

No branching nor decision trees as not to confuse common folk. Now programming is a socially acceptable activity!

Re: Ask PG: Lisp vs Python (2010)

#190
post #23

Peter Norvig here. I came to Python not because I thought it was a better/acceptable/pragmatic Lisp, but because it was better pseudocode. Several students claimed that they had a hard time mapping from the pseudocode in my AI textbook to the Lisp code that Russell and I had online. So I looked for the language that was most like our pseudocode, and found that Python was the best match. Then I had to teach myself eno…

> But Python has the edge (with a large number of students) when the main goal is communication, not programming per se. Communication is increasingly the more important part of programming. Engineering is only really useful if its well communicated, or in a binary you trust.

Yeah, there'll come a time when to build systems all you need is a bunch of people talking to reach a consensus: how much to pay for a third party to write it for them.

oops, it seems it already happens today...

Post reply on HN