News for hackers. Stuff that matters.
Re:Lisp is Too Powerful by raganwald on Saturday December 24, 2011 @03:08PM (#3389562)
The notion of programming languages being “too powerful” rests on fallacious assumptions.

The faulty reasoning is this: If Hacker Hortense does something with powerful language L that Newbie Nathan finds confusing, we assume that language J won’t permit Hortense to do that, and therefore if we standardize on language J, fewer bad things will happen.

This reasoning is faulty. First off, if Hortense and Nathan don’t see eye to eye on how to write programs, no language will solve the problem, because you have a disparity of experience and/or education. If what you want is code Nathan will like, and you don’t want to raise Nathan to Hortense’s level, you have to drag Hortense down to Nathan’s level with coding standards. And you could have done that in Language L just as easily as J. If you ban L, what will you do when Hortense implements Parser Combinators and Monads in J?

The first flaw is the assumption that language features introduce complexity, when in reality it isn’t the features, it’s the solution to the problem that confuses.

This indirectly leads into the second fault with the reasoning. There is a hidden assumption that Hortense is going to write so much code, and there will be so many “problems” Nathan will have with his code, and every problem we eliminate is one fewer problem in the result. This is not how software works.

Let’s say Hortense writes some code in L, and Nathan complains that there are seventeen things he doesn’t understand. Ten of them rely on features of L, seven are independent of the language. If we tell Hortense to rewrite things in J, we cannot assume that the result will have seven things Nathan doesn’t understand. It might have even more as Hortsense works around J’s deficiencies.

For a demonstration of this, look at any modern Java Dependency Injection Framework. These complex and opaque software machines are made up of of XML, interfaces, and classes. They exist in no little part because Java lacks the reflection and meta-programming of languages like Lisp or even Ruby. Are these thing simple by virtue of being written in Java instead of Lisp?

Imagine for a moment that DI frameworks don’t exist, and that Hortense had built something in Lisp with macros for dependency injection. Nathan is nonplussed, so Hortense rewrites it in Java and rolls her own DI infrastructure. Will the result really have fewer things that Nathan doesn’t understand? Or will it be even more inscrutable thanks to the accidental complexity of working around Java's limits??

The “problem” is not that some languages are too powerful, it is that people imagine that teams of programmers can work together on complex problems without communicating, and some people assume that when there is a disparity of experience of knowledge, that people can work together without educating or learning from each other.

Re:Lisp is Too Powerful by wpietri on Saturday December 24, 2011 @06:19PM (#3389986)
The more interesting situation to me isn't novice vs expert. It's the same one that bothers the person who wrote the top of the original article: pro vs pro.

A former boss of mine said that programmers are like hairdressers: whenever she changes to a new stylist, the first thing they say is, "Oh my god, what did that last person do?" That's certainly what I say when I have to examine an existing codebase. More expressive languages allow for more stylistic variation, and one's style is deeply rooted in one's values and experiences. One person's brilliance is another person's WTF.

I think the right solution to this involves developing a house style, which for my team involves zero code ownership and a lot of collaboration. Eventually the team converges on a set of idioms that work for everybody, so style issues are minimal.

But that's not always the working reality. If I have to inherit a bunch of code from a random developer, I'd much rather it be in Java than, say, Ruby. Java definitely limits brilliance, but it also limits too-clever-by-half idiocy. The downside risk with a Java code base is smaller.

Re:Lisp is Too Powerful by raganwald on Saturday December 24, 2011 @06:35PM (#3390006)
I agree about developing a house style. It is not my Java programming experience that the Java language limits the too-clever-by-half idiocy.

If you want to say that the kinds of companies that hire Java developers don’t hire clever idiots, that’s a different discussion. But I’ve seen so many convoluted architectures built out of Java that it feels to me like too-clever-by-half is a constant across all languages, and the very best thing for me is discouraging cleverness, with second best being let people do their clever things in a language that helps them, rather than making them write even more inscrutable clever code just to get away with being clever in Java.

This is my point above, and perhaps it doesn’t match your experience, namely that some clever things will be done, and Java will not prevent them from being done, but merely prevent them from being done simply and cleanly. So why not have this other “pro” do what she is going to do, but do it simply and cleanly thanks to a powerful language, rather than resorting to XML and other shenanigans?

But honestly, I fear we are now having a weird discussion where our working assumption is inheriting code from people we don’t respect. It’s far, far easier to simply work with reasonable, sane people, than to make all your choices predicated on the idea that your colleagues are psychopaths.

It makes for witty sayings, but terrible careers.

Re:Lisp is Too Powerful by wpietri on Sunday December 25, 2011 @11:41AM (#3391192)
Hmmm. I think I still maintain my preference for bad Java over bad Ruby. The AbstractSingletonProxyFactoryBeanImpl insanity is painful, but I feel like most Java problems can be solved with pruning shears. Ruby's metaprogramming, on the other hand, puts COMEFROM-style functionality into the hands of noobs, and its duck typing makes it very hard to answer basic questions about what the hell X is. In Java, I can always tug on something and figure out what it's connected to. But perhaps that's just a matter of my personal debugging style.

Broadly, though, I think you're right: it's irrelevant to the real problem. Java is the new COBOL because most large software development organizations are functionally insane. They can't tell good code from bad, and rig things in a way that bad code is almost guaranteed anyhow. So naturally they'd prefer a language in which bad code is merely painful, not fatal. Because that lets them cover up their failings for much longer periods.

My personal solution is yours: stop working with other people's shitty code. I'd like to see the problem solved across the industry, but focusing on language choice doesn't seem like it's getting us anywhere.

Re:Lisp is Too Powerful by raganwald on Sunday December 25, 2011 @10:55PM (#3392172)
Applying hordes of programmers to solving a programming problem always runs into limits governed by Conway’s Law:

http://en.wikipedia.org/wiki/Conways_Law

Re:Lisp is Too Powerful by sirclueless on Saturday December 24, 2011 @04:24PM (#3389709)
I'm not so sure I agree with you, because there is something to be said against your counterexample. In java, I can reason as follows: the Java Dependency Injection Framework is gigantic and convoluted, therefore it is going to be complex and difficult to manage.

In Java there is a sort of ceiling, one might call it an upper bound on the mindfuckery per square inch of code. In 100 dense lines of lisp, there is no a priori reason to assume that no one has written a recursive descent macro-expanding s-expression handler for arbitrary routing of network packets in a rules-based DSL. In the same amount of dense java code there are rarely more than 200 method calls, all statically checked, and rarely more than 100 variables, typed and scoped.

From John Carmack's recent article on static checking: "If you have a large enough codebase, any class of error that is syntactically legal probably exists there." Now, he is concerned with actual defects, but the same rules apply even more strongly for stylistic rules. As the size of a codebase increases, the probability that any particular language feature is absent approaches zero. And in a language like lisp, where you can write your own language features, this is moderately horrifying.

The fact that you can replicate java's dependency injection in a few orders of magnitude less code in lisp is not a comfort to me. Because the 10,000 lines of code in Java's Dependency Injection Framework is a red flag to me. The chances that someone who writes the same thing in lisp has drastically simplified the implementation are not so high.

Re:Lisp is Too Powerful by raganwald on Saturday December 24, 2011 @06:02PM (#3389960)
the 10,000 lines of code in Java's Dependency Injection Framework is a red flag to me.

We agree.

The chances that someone who writes the same thing in lisp has drastically simplified the implementation are not so high.

We disagree.

First, when I roll my own, I scratch only my own itch. I don’t need to build something that works for everyone, everywhere. It’s like Microsoft Word: MSFT boasts that most users only need 5% of what it does, but every niche of users uses a different 5% of the whole thing.

But can I roll my own? Well, I suggest that the answer is more likely to be “yes” in Lisp than in Java. First, folklore suggests that defects are constant per line of code. Therefore, if I need fewer lines of Lisp than of Java, I should have fewer defects to contend with. I assume three things. First, I need much less than the full framework’s functionality. Second, Lisp is more expressive than Java, so I need fewer lines of Lisp for any functionality than of Java. Third, I suggest that languages with meta-programming support are particularly well suited for tasks like dependency injection, reducing the amount of code I need to write even further.

Now, the big DI framework is written by someone else. So is it free? No. I need time to learn it, time to use it, I can make mistakes using it, I can get an XML configuration wrong, I can implement an interface when I am supposed to extend an abstract class, I am not immune from defects just because I am using a library.

So the net question for me is whether the chances of successfully rolling my own feature in Lisp for my project’s specific needs are greater than the chances of successfully using an existing framework in the Java world=, and parallel to that, the question is whether someone else working with my code will find it easier to decipher the XML configuration and interfaces and classes I have written to work with a Java DI framework or will find it easier to work with the smaller, simpler and more compact Lisp code written for this specific project.

Reasonable people can go either way on this, I find it hard to believe that Java is “obviously” a win, especially if they’ve used one of these big frameworks with the many gotchas (as I have).

p.s. Of course, the wild card is that there are plenty of libraries in Lisp as well. I reject the notion that every Lisp programmer reinvents everything from scratch: https://github.com/lprefontaine/Boing

Re:Lisp is Too Powerful by vannevar on Saturday December 24, 2011 @06:44PM (#3390019)
Keep in mind that a less verbose expression is not necessarily
Re:Lisp is Too Powerful by vannevar on Saturday December 24, 2011 @09:14PM (#3390249)
Sorry, I didn't see that this actually posted. What I intended to say is that a less verbose expression is not necessarily easier to understand. The article is really about the balance between elegance (or performance) and accessibility. An expert coder working with a powerful language like Lisp can implement a lot of functionality very quickly, but there is a point where less skilled programmers working with common understanding of a less flexible language can implement more functionality more quickly, simply because there are more of them working in parallel.
Re:Lisp is Too Powerful by gruseom on Sunday December 25, 2011 @12:19AM (#3390501)
This is the kind of thing we say about programming all the time without evidence. We don't know this, or anything like it.
Re:Lisp is Too Powerful by vannevar on Wednesday December 28, 2011 @05:45PM (#3401749)
Strictly speaking yes, it's a hypothesis. But the fact that the programming ecosystem looks as it does constitutes some evidence in favor of that hypothesis. Were it otherwise, you'd expect the professional programming world to be economically dominated by Lisp and a handful of super-programmers. Yet that isn't what we see. Why not?
Re:Lisp is Too Powerful by gruseom on Thursday December 29, 2011 @04:42PM (#3405519)
That's the stock objection. Here's my answer: historically speaking, we've barely started. Software is the first mass endeavor of its kind that humans have tried. It belongs to a post-industrial era that can be expected to take a long time to work itself out. Under such conditions, social proof doesn't work. Whatever the rational way of making software turns out to be, statistically speaking it hasn't been tried yet.

Will it turn out to be "Lisp and a handful of super-programmers"? I don't know. What we need is an age of experimentation. The great thing is that startup costs are now so low that we are beginning to see that happen. Emphasis on beginning.

Re:Lisp is Too Powerful by vannevar on Thursday December 29, 2011 @10:03PM (#3406405)
That argument seems a little too convenient; we are after all talking about a field (and a language, Lisp) that's been around for over 50 years. I could certainly see pockets of inefficiency persisting after such a time, but I would hardly expect the exception to be the rule at this point.

Keep in mind that I'm only suggesting that a crossover point exists, I don't pretend to know where exactly it is. In order for me to be wrong, a single superior programmer would always have to be better than two slightly inferior programmers working with a slightly less expressive language. I strongly doubt that this is true. The simplest explanation for what we observe is that in fact a team of inferior programmers working in parallel can be more efficient than a single superior programmer working alone. Not always, but often enough to prevent more expressive but less comprehensible languages from becoming dominant. What constitutes "expressive" and "comprehensible" will evolve over time, as you suggest (maybe Lisp will someday become tomorrow's Java!), but the underlying scaling law will remain.

Re:Lisp is Too Powerful by akkartik on Friday December 30, 2011 @12:40AM (#3406744)
This is a fascinating conversation. I've always had trouble working in teams, so I'd like to believe that superior programmers will out in the end. Or at least that they will in a few problem domains.

But I wonder if this is wishful thinking, if this isn't just another case of the prisoner's dilemma. Perhaps like how cities with mostly poor people would collaborate many times in history to conquer neighboring barbarians, even though the barbarians had more freedom and were thus richer. (See http://en.wikipedia.org/wiki/Fates_of_Nations.)

Then again, there's reason for hope. Perhaps the parallelizable sort of programming is more menial. It certainly seems that way with the way communication costs overtake large teams. It's almost like Vernor Vinge's zones of thought (http://en.wikipedia.org/wiki/A_Fire_Upon_the_Deep, http://www.youtube.com/watch?v=xcPcpF2M27c) - as your team grows bigger you can just watch the members grow dumber in front of your eyes as more and more of their cognitive effort is eaten up by internal communication, leaving less and less for externally-useful work. If this is true, there's hope that advances in programming will automate the low-cognition tasks and allow programmers to focus on the high-cognition ones, leveling the playing field for small, high-cohesion teams.

---

Me, I've been obsessed with something raganwald said when he spawned this tendril of conversation: exercising explicit control over the space of inputs my program cares about. My current hypothesis: eliminate fixed interfaces, version numbers, and notions of backwards compatibility. All these are like petridishes of sugar syrup for code to breed more code. Replace them with with unit tests. Lots of them[1]. If I rely on some code you wrote, and I want to pull in some of your recent changes, I need to rerun my tests to ensure you didn't change an interface. Programming this way is less reassuring, but I think it empowers programmers where abstraction boundaries impose mental blocks. Great programmers take charge of their entire stack, so let's do more of that. I'm hoping this is the way to prove small teams can outdo large ones.

[1] Including tests for performance, throughput, availability. This is the hard part. But I spent a lot of time building microprocessor simulators in grad school. I think it's doable.

Re:Lisp is Too Powerful by gruseom on Friday December 30, 2011 @12:50AM (#3406760)
I'd like to believe that superior [solo] programmers will out in the end

I think you're wrong (sorry!) because it's impossible to talk about superior programmers without talking about teams. Building complex systems is a team sport. There's no way around this. But you can't have good teams without good programmers.

The phrase "scaling complexity" has at least two axes built into it: the abstraction axis -- how to get better at telling the program to the computer -- and the collaboration axis -- how to get better at telling the program to each other. Most of this thread has been about whether we suck at the former. But I say we really suck at the latter, and the reason is that we haven't fully assimilated what software is yet. Software doesn't live in the code, it lives in the minds of the people who make it. The code is just a (lossy) written representation.

We can argue about how much more productive the best individual working solo with the best tool can be- but there's no way that that model will scale arbitrarily, no matter how good the individual/tool pairing. At some point the single machine (the solo genius) hits a wall and you have to go to distributed systems (teams). One thing we know from programming is that when you shift to distributed systems, everything changes. I think that's true on the human level as well. (Just to be redundant, by "distribution" here I don't mean distributed teams, I mean knowledge of the program being distributed across multiple brains.)

Maybe you wouldn't have trouble working in teams if we'd actually figured out how to make great teams. So far, it's entirely hit and miss. But I think anyone who's had the good fortune to experience the spontaneous occurrence of a great team knows what a beautiful and powerful thing it is. Most of us who've had that experience go through the rest of our careers craving it again. Indeed, it has converted many a solo type into an ardent collaborator. Like me.

I was originally going to write about this and then decided not to go there, but you forced my hand. :) Just as long as it's clear that when I say "team" I mean nothing like how software organizations are formally built nowadays. It's not about being in an org chart. It's about being in a band.

Re:Lisp is Too Powerful by akkartik on Friday December 30, 2011 @01:18AM (#3406824)
The phrase "scaling complexity" has at least two axes built into it: the abstraction axis -- how to get better at telling the program to the computer -- and the collaboration axis -- how to get better at telling the program to each other. Most of this thread has been about whether we suck at the former. But I say we really suck at the latter, and the reason is that we haven't fully assimilated what software is yet. Software doesn't live in the code, it lives in the minds of the people who make it. The code is just a (lossy) written representation.

Ah, you're right. I was conflating the two axes.

I'd like to be part of a 'band'. I've had few opportunities, but I've caught the occasional glimpse of how good things can be.

Since that whole aspect is outside my ken, I focus on expression. Hopefully there's no destructive interference. I would argue that what you call abstraction is about 'communication with each other' more than anything (even though it breaks the awesome symmetry of your paragraph above :)

Re:Lisp is Too Powerful by gruseom on Friday December 30, 2011 @01:30AM (#3406850)
No, you're right. They're not axes.
Re:Lisp is Too Powerful by gruseom on Friday December 30, 2011 @12:16AM (#3406692)
To me the big question is how we're going to scale up complexity. The million-line programs we have today are already an absurdity. What are we going to do, have billion-line programs? Anyone who can figure out to provide equal value with 100x less code (edit: that grows, say, logarithmically in size rather than superlinearly) is going to have an edge. Brute force won't work forever. Plus it gets extremely expensive as one approaches the limits.
Re:Lisp is Too Powerful by vannevar on Friday December 30, 2011 @10:49AM (#3407961)
Which brings us back full circle to the Mythical Man Month. While I've argued here for a crossover point where more programmers = more productivity, I acknowledge that there is a similar crossover point going the other way, where more programmers = less productivity. Finding the sweet spot in-between is the art of organization, and not yet a science.
Re:Lisp is Too Powerful by jshen on Sunday December 25, 2011 @01:14AM (#3390554)
Have you read the mythical man month? More less skilled programers do not make things go more quickly. That idea is so wrong on so many levels that I dnt know where to begin.
Re:Lisp is Too Powerful by joesb on Sunday December 25, 2011 @02:46AM (#3390671)
MMM said adding more programmer to already late project doesn't make it finished faster. It didn't say having more programmer who already understand the project will make the project finish late. If that is true then one programmer must always be the optimal number to complete any project, which is clearly wrong.

Also, "less skilled programmers" are not always "incompetent programmers" so more of the former who already understands the system may be able to complete the project faster than fewer "more skilled programmers"

Have you really read the mythical man month?

Re:Lisp is Too Powerful by jshen on Sunday December 25, 2011 @12:29PM (#3391269)
Yes I have. Do you remember why he said more programmers is a problem? Because it increases the amount of communication. Because of this, few higher skilled programmers get more done than more less skilled programmers, largely because less communication is required.

I've witnessed this directly many times over the years.

Re:Lisp is Too Powerful by j_baker on Sunday December 25, 2011 @09:53AM (#3391063)
MMM does indeed say that too many programmers do indeed make a project late regardless of how far behind that project already is. Nine women can't have a baby in a month and all. Have you really read it? The book makes this quite clear. The Wikipedia page doesn't.
Re:Lisp is Too Powerful by j_baker on Saturday December 24, 2011 @05:31PM (#3389878)
Perhaps I'm missing something here. Argument 1 seems to basically be that Java code is bigger than Lisp code. Argument 2 is that big code bases tend to use all of a language's features.

Why couldn't you solve the second problem with the first? As you've already pointed out, Lisp code is smaller. Thus, you don't have to worry about the "large code base" problem like you would with java.

Re:Lisp is Too Powerful by richardw on Sunday December 25, 2011 @04:12AM (#3390745)
A couple lines of particularly dense Perl can make life pretty terrible, e.g. compared to many thousands of lines of getter-setter Java. You can pack more language features into a smaller area with a more expressive language. It follows that a smaller area might hold more complexity and likely more opportunities for errors, and therefore bugs.

At the very least, we can say "the LOC-bug relationship doesn't necessarily hold across languages". It's a useful rule-of-thumb, not a universal law.

Re:Lisp is Too Powerful by lucian1900 on Sunday December 25, 2011 @07:36AM (#3390942)
That is only the case with actual complexity required by the problem, not incidental complexity caused by the limitations of the language (such as is common with Java).
Re:Lisp is Too Powerful by nwbrown on Sunday December 25, 2011 @10:53AM (#3391142)
While I don't agree with everything you say, I'm definitely reusing the term "mindfuckery per square inch of code".
Re:Lisp is Too Powerful by raganwald on Sunday December 25, 2011 @02:02PM (#3391403)
This is related to the One True Code Quality Metric, WTFs per minute of code review.
Re:Lisp is Too Powerful by stevecooperorg on Saturday December 24, 2011 @04:49PM (#3389782)
Isn't his point rather that Lisp goes beyond the normal definition of 'programming language'?

"Lisp is almost an interpreter builder rather than just an interpreter/compiler"

So most languages have a fixed grammar, and programs are always written in that grammar. Java functions, whatever problems they have, are at least always declared using a fixed grammar -- something like

    function ::= returnType Identifier parameterList;
So even if you don't know what a function does, at least you (and tools) can easily see functions in the source code. The same applies to loops, classes, conditionals, etc. (Same for python, BASIC, whatever.) What Lisp does goes beyond that; I can define a new conditional language construct, or looping grammar, or object system...

"This means that one can make it be just about anything they want. Thus, its culture is almost a lack of culture."

The fear is that you'll end up having to join a project using "Dave's Object System" or "Nora's Conditionals Library". And that's where Lisp has the Aw(esome|ful) power to write in wildly divergent styles -- in fact, written in whole new grammars.

I suppose there's an idea that code can be written in a 'natural' way for the language. So you have this idea in python programming of something being 'pythonic' -- not just corresponding to the the python grammar, but also in a particular, respected programming idiom. So the question is, when you have the power to write your own grammar, can you then still write in a good, predicatable style that makes the code a good form of communication for other programmers? Is there a 'lispish' way to write code? (I suppose the same question applies to things like internal Ruby DSLs.)

Honest questions; although I've given Lisp a good shot, I've never written anything longer than a few hundred lines...

Re:Lisp is Too Powerful by raganwald on Saturday December 24, 2011 @05:30PM (#3389874)
Well, it’s true that Lisp has meta-syntactic programming and Java doesn’t, however since Java doesn’t have homoiconicity, you end up with people building things where a lot of the meta-programming is baked into XML files.

So, you could argue that a large, complex Java program can’t be understood just by reading it a line at a time, you have to figure out how it is all wired together via the XML files.

I think what I’m trying to say is that large and complex systems are, well, large and complex whether in Lisp or java. But Lisp has standard libraries just like Java, e.g. CLOS. So it’s true Dave could write his own objects, and Nora her own conditionals, but I wonder whether that is more folklore than practical reality on commercial projects.

Re:Lisp is Too Powerful by pavelludiq on Saturday December 24, 2011 @05:54PM (#3389933)
Is there a 'lispish' way to write code?

Yes. If you read enough Clojure, Scheme and Common Lisp code you'll see that they have their own different styles. On a few occasions I read Common Lisp code written by schemers, it was somewhat ugly and inelegant, although the same code would have been elegant if written in scheme. Here's an example from an Erik Naggum article( http://www.xach.com/naggum/articles/3195982690560792@naggum.... ). First the Scheme in common lisp:

  (defun make-account (balance)
    (labels ((withdraw (amount)
                       (if (>= balance amount)
                           (progn
                             (setf balance (- balance amount))
                             balance)
                         (format t "Insufficient funds")))
             (deposit (amount)
                      (setf balance (+ balance amount))
                      balance)
             (dispatch (m)
                       (cond
                        ((equal m 'withdraw) withdraw)
                        ((equal m 'deposit) deposit)
                        (t (format t "Unknown request -- MAKE-ACCOUNT")))))
      dispatch))
Perfectly reasonable way to do it in Scheme, not in Common Lisp. Heres how you do it in idiomatic Common Lisp:

  (defclass account ()
     ((balance :initarg :deposit :initform 0 :accessor balance)))

  (defmethod withdraw ((account account) amount)
     (decf (balance account) amount))

  (defmethod deposit ((account account) amount)
     (incf (balance account) amount))

  (defmethod withdraw :before ((account account) amount)
     (unless (<= amount (balance account))
       (error "~A has insufficient funds to withdraw ~A." account amount)))
I'll let the code speak for itself :)

Lisp allows you to turn code like the first example into code like the second.

edit: formatting