News for hackers. Stuff that matters.
Re:Lisp vs Python by j_baker on Sunday February 20, 2011 @04:07PM (#2243082)
> Lisp seems to be optimized for writing code; Python seems to be optimized for reading it.

Urgh... A hundred times no. I really do appreciate that the author seems to have given Lisp a try. But this is simply wrong.

Why does Lisp provide macros? Because they make code easier to read. I say stop focusing on what language abstraction (f x) represents and focus on figuring out what the code is doing.

Oh well, at least he didn't complain about lisp having too many parenthesis.

Re:Lisp vs Python by Teckla on Sunday February 20, 2011 @04:27PM (#2243148)
"Oh well, at least he didn't complain about lisp having too many parenthesis."

Humans are visual creatures. It really is easy to get lost in Lisp's parentheses.

Languages whose blocks are easier to identify at a glance really are easier to read.

The attitude of far too many Lisp developers seems to be that Lisp has failed to dominate after all these many decades because people are just too stupid to realize how great Lisp is.

If Lisp hasn't dominated by now, rather than arrogance and superiority, it would be better to think about why Lisp continues to fail to dominate.

By the way, I'm not suggesting you're one of those people.

Re:Lisp vs Python by silentbicycle on Sunday February 20, 2011 @04:49PM (#2243219)
> Languages whose blocks are easier to identify at a glance really are easier to read.

Which is why conventions for indenting Lisp code to show block structure have been established for decades. This problem has been solved for longer than Python has even existed. I don't know why people keep bringing it up. Lisp isn't perfect, sure, but this is a very weak criticism.

Besides, what about mismatched delimiter problems in languages like C that have shift-reduce conflicts? Dangling else problem (http://en.wikipedia.org/wiki/Dangling_else), anyone? It seems disingenuous to complain about mismatched parens in Lisp when those are trivially handled by most decent editors, and the problem is in no way unique to Lisp.

Re:Lisp vs Python by Locke1689 on Sunday February 20, 2011 @06:19PM (#2243480)
Python would argue that if the primary operating factor in readability is block structure and indentation one should simply add block structure and indentation as a mandatory part of the language and then remove cruft which is no longer necessary.
Re:Lisp vs Python by euccastro on Sunday February 20, 2011 @07:10PM (#2243620)
Python doesn't mandate block structure and indentation in lines within brackets and parens. Ask yourself why is that and you'll have the reason why it makes sense in Lisp.

I'm very familiar with Python and hack occasionally in Scheme. After a really short time, parens really are no problem. They are an asset. In big functions where indentation stops being obvious at a glance (and in smaller ones, what's the problem?), I can more easily see/check the extent of a block in Scheme (with editor paren matching) than in Python. The editor is better able to help me select and operate on such blocks. Moving blocks around (e.g. for refactoring) is easier, faster and feels safer.

If I still use Python more often than Scheme it has nothing to do with parens. Much on the contrary, that's one of the reasons I wish I could spend more time in Scheme.

Re:Lisp vs Python by Locke1689 on Sunday February 20, 2011 @07:27PM (#2243652)
Python doesn't mandate block structure and indentation in lines within brackets and parens. Ask yourself why is that and you'll have the reason why it makes sense in Lisp.

Because they screwed up? I think indentation like the following should be mandatory across multiple lines:

  fun_a(long_arg_a,
        long_arg_b,
        long_arg_c)
Re:Lisp vs Python by euccastro on Sunday February 20, 2011 @08:50PM (#2243884)
And does that remove the need for parentheses? ;)

Because actually, it gets more complicated than that. Sometimes it makes more sense to say:

  def open_window(x, y
                  width, height,
                  resizable=True,
                  caption="")
Without parens, is x, y a tuple or two separate arguments? And do I want to remember that?

Also, what's inside the parens could have been a generator expression, which could have been conceivably partitioned in more than one sensible way, and which could have subexpressions with parens or brackets itself.

Sounds contrived? I do it all the time and it often looks and reads just fine.

I'm not arguing against your indentation rule, which is the one I use, and not even against the proposal of making it mandatory (although I'm not sure that in the heat of refactoring I'd appreciate the unnecessary SyntaxErrors), but about the point that making it mandatory would make parens unnecessary.

Re:Lisp vs Python by Locke1689 on Sunday February 20, 2011 @10:01PM (#2244069)
True, although Haskell does show we can do function application without excessive parentheses.

I think you're definitely right about Python, though. Fundamentally, Python is still a procedural, block style language. If it were written in the same functional style as Lisp it would probably be just as complex.

Re:Lisp vs Python by silentbicycle on Tuesday February 22, 2011 @12:15AM (#2248859)
The ML and APL families also do function application without excessive parens.

I don't think Lisp's grouping rules are complex. There are a few functions with special grouping, particularly let and cond, but anybody doing real programming in Lisp gets used to them pretty quickly. (Lisp is hardly the only language with special cases in its syntax!) User-added functions seldom have elaborate nesting schemes, or at least have a damned good reason.

Re:Lisp vs Python by silentbicycle on Sunday February 20, 2011 @06:46PM (#2243570)
I'm not convinced that block structure and indentation are primary readability factors, just noting that Lisp programmers established conventions to address that problem long ago.
Re:Lisp vs Python by Locke1689 on Sunday February 20, 2011 @07:17PM (#2243633)
That's fair. I'm not saying Python's way is better or Lisp's way is better. I'm a long-time Python programmer but I'm also working on the Racket code base. I was simply pointing out a difference in philosophy, not taking sides. I mostly believe that the debate is a minor stylistic one and there are trade-offs in both directions. This is fundamentally similar to the way I see arguments for and against Python syntactical whitespace vs. Ruby-esque blocks.
Re:Lisp vs Python by stcredzero on Sunday February 20, 2011 @04:51PM (#2243229)
Languages whose blocks are easier to identify at a glance really are easier to read.

IMO, it's really pointless to toss about theories having to do with readability for this reason or that. Programming languages are also (sub)cultural entities. It doesn't matter how many clever reasons we come up with explaining why people don't like this or that about whatever language. Most of those things are unsubstantiated, so who gives a flying expletive?

What matters is that languages attract audiences of the size they attract. It's a fact of life. It's all we know until some serious psychological/linguistic research happens. Frankly, I'm not sure if enough people care enough about what coders think for it to happen. Maybe they should. In the meantime, we should just shut up and code. (Starting with me. Why did I write so many comments today?)

Re:Lisp vs Python by cesarm on Sunday February 20, 2011 @07:59PM (#2243753)
in lisp one ends up reading code by indentation - much like python. the parenthesis fade into the background after just a couple of days of using lisp. matter of fact i use a light blue background in emacs, and make the parenthesis a light gray. barely see them.
Re:Lisp vs Python by lwat on Sunday February 20, 2011 @06:19PM (#2243479)
Why does Lisp provide macros? Because they make code easier to read.

To the person writing the code, yes. To the next coder maintaining the code, not likely.

Re:Lisp vs Python by pavelludiq on Sunday February 20, 2011 @06:36PM (#2243542)
Do you have any data(even if anecdotal) to back up your claim? My experience is that macros don't obfuscate code at all(unless misused, I'm talking about idiomatic use of course). If i have the code loaded i just type (documentation 'macro-or-function-name 'function) to get its docstring. Slime can also show me its documentation and its argument list. Not to mention that a good macro(like any other well written code) is obvious. On the internet Lisp is the most unmaintainable language, in practice its pretty maintainable.
Re:Lisp vs Python by cesarm on Sunday February 20, 2011 @08:03PM (#2243765)
true, but i still find the loop macro confusing.
Re:Lisp vs Python by lwat on Sunday February 20, 2011 @07:57PM (#2243745)
Here's an anecdote from the other day:

http://news.ycombinator.com/item?id=2240461

On another note, why do you think lisp isn't more widely used?

Re:Lisp vs Python by cesarm on Sunday February 20, 2011 @08:05PM (#2243774)
Re:Lisp vs Python by rayiner on Sunday February 20, 2011 @10:04PM (#2244075)
Why isn't Smalltalk, Prolog, Modula, ML, Eifel, FORTRAN, Ada, APL, etc, more widely used? Because there can only be a couple of "mainstream" languages, and C/C++ took up all the mindshare in that period.

In fact, a more useful question is: "why is Lisp even used as much as it is?" The current Common Lisp standard is 20 years old, and yet it supports a pretty active if small user community, which is more than can be said of most of its contemporaries.

Re:Lisp vs Python by euccastro on Sunday February 20, 2011 @09:48PM (#2244035)
Well, that anecdote talks about some people _fearing_ powerful, expressive languages.

In a previous job I had workmates arguing for banning "nested" Python list comprehensions. And as an example of such horrible nesting he proposed something like:

  some_list = [some_function(blah)
               for blah in some_other_function()
               if some_condition(blah)]
What this says to me is that this guy didn't get list comprehensions at all and didn't want to. Sure enough, there's no nesting whatsoever going on here. He was just scared by non-C++-like syntax.

My point is: popularity, though desirable in itself, is a poor measure of anything else. Most people run away from good things for no valid reason.

(Not saying there are no valid reasons why Lisp is not more popular, only that none would really be needed. Obscurity is quite a stable default.)

Re:Lisp vs Python by pavelludiq on Sunday February 20, 2011 @08:52PM (#2243891)
Others already pointed out the AI winter. Reading about the history of lisp is very interesting, it almost feels like you are reading about a lost civilization, so ahead of its time. On the other hand, the AI winter is in the past, why isn't lisp used NOW? I think its getting better, the scheme people are working on sorting out their issues, and of course theres Racket, which is awesome. You have the clojure people attracting a lot of java and ruby developers(among others) to at least give lisp a chance. And even the Common Lisp world is on the rise. The biggest problem IMHO is that there are too many non lisp programmers with strong opinions on lisp that spread FUD, even though all their lisp experience can be summarized as "read a scheme tutorial, and wrote a recursive factorial function".
Re:Lisp vs Python by rayiner on Sunday February 20, 2011 @09:56PM (#2244053)
Look through some really old Lisp code sometime. SBCL is highly readable despite being: 1) 25 years old and touched by tons of different people since then; 2) a program that does some really complicated things in a pretty small space (~60 KLOC for the arch-independent portion).

When you see (def-ir1-transform ...) in the SBCL source, it's immediately obvious what is about to come along (at least if you know about compilers). Similarly old C code (eg: GCC) is completely incomprehensible in comparison.

Re:Lisp vs Python by flatline on Sunday February 20, 2011 @06:58PM (#2243595)
Isn't this true of all forms of encapsulation? Deeply nested type hierarchies, event chains, and even method calls can be nearly impossible to decipher, even with a graphical debugger, syntax highlighting and static typing. Writing maintainable code is a skill in any language. Lisp offers a lot of advantages to this end.
Re:Lisp vs Python by lwat on Sunday February 20, 2011 @07:04PM (#2243611)
Isn't this true of all forms of encapsulation?

Yes it is.

Re:Lisp vs Python by gnosis on Sunday February 20, 2011 @06:33PM (#2243533)
Have you ever actually programmed in Lisp? Macros can and often do hide all sorts of ugliness that would otherwise make the code a hundred times more unreadable. Much of Lisp's syntax sugar is built with macros.