Home > Uncategorized > Lisp and functional languages discourage free riders

Lisp and functional languages discourage free riders

While many developers have a favorite programming language, there are a few who believe they have found the One True Language and refuse to even consider coding in another language.

Why is the One True Language invariably a dialect of Lisp or a functional language?

I think the reason is the same as why strict churches are strong, both these language families make life difficult for free riders, i.e., the casual programmer.

Superficially Lisp-like languages look unwelcoming because of all those brackets and the tiresome reverse polish notation, but once past these surface speed bumps life is not a bed of roses, there are mind bending language challenges to master at every abstraction level; developers get sucked into the community working on mastering each level (this suggests an alternative explanation that coding in Lisp is a way of continuing to play Dungeons & Dragons while appearing to work).
True functional languages don’t have global variables and certainly don’t let you create stateful information. The self-flagulation no global variable languages have a limited clientèle; its the writing of programs that don’t make use of side-effects (e.g., iteration via recursion, not explicit loops) that marks out the true community members; a short conversation with a developer is enough to tell whether they are one-of-us who joyfully tells the world of their latest assignment-free solution to an apparently intractable problem (intractable in the sense of appearing to require the use of assignment statements). There are always umpteen different ways of writing something in functional languages, providing plenty of scope for sects to splinter off by requiring disciples to follow a particular approved style.

Why have Lisp and functional programming continued to survive for so long? Some interesting research on communal societies has found a correlation between the number of costly requirements entailed by community membership and community longevity, the greater the number of costly requirements the longer a community survives. Having sunk so much time and effort into the costly signaling required for community membership, people are loath to leave it all behind.

  1. Dmitri
    October 18th, 2015 at 23:22 | #1

    Traditional Lisps, such as Common Lisp, are multi-paradigm languages that are very much imperative. In fact, CL has one of the most flexible loop[1] constructs seen in a language.

    >the tiresome reverse polish notation

    No, Lisp does not use reverse polish notation, it uses the same prefix notation as practically every other language out there. Last I checked, function name goes before the arguments in any mainstream language. The only difference is that it doesn’t have special syntax for math operators baked into it. However, it’s perfectly possible to use infix math notation in Lisp. [2]

    > there are mind bending language challenges to master at every abstraction level

    Much like there are challenges for an anglophone learning Japanese. Internalizing new concepts is indeed more work than learning superficial syntactic differences in the same family of languages. However, in no way does that imply that a language from a different family is inherently harder to work with.

    >True functional languages don’t have global variables and certainly don’t let you create stateful information.

    That’s completely and utterly false. All functional languages provide great tools for working with stateful information. The main difference is in the defaults. Functional languages default to immutability and make the scope of mutation explicit. Anybody who’s developed any non-trivial applications would understand the value in that approach.

    The main reason why you pass references around in an imperative language is because you’re working with mutable data structures. Doing a deep copy every time you need to change the data is extremely expensive. So, the developer is left having to remember where all the places a particular piece of data might be referenced.

    Functional languages provide immutable data structures that revision changes. The cost of creating a revision is proportional to the size of the change, making this approach sufficiently performant to be practical.

    This is not a constraint, but a feature. From my perspective any time I create a change it’s a local change where I make a copy of the data. I don’t have to worry where and how the original data might be used. I can just focus on what my code needs to do.

    So, what’s happening in practice that the computer is doing more work freeing the developer from having to think about it. This is akin to having garbage collection, where I no longer have to keep track of where I might have allocated something and when I need to deallocate it.

    >iteration via recursion, not explicit loops

    In practice, explicit recursion is quite rare in functional code. As the name implies functional languages allow passing functions around as parameters. This in turn allows writing iterator functions, such as map, reduce, filter, and interpose, that understand how to do a particular type of iteration and passing the domain specific logic in as a parameter.

    Again, the advantage is that it allows you to separate how something is done from what’s being done. In addition it allows you to write the code that does things like boundary checks in one place. This directly eliminates a whole class of errors.

    These things have already become common even in imperative languages, with even Java adding lambdas now.

    >Having sunk so much time and effort into the costly signaling required for community membership, people are loath to leave it all behind.

    So, how does the fact that companies like Walmart use functional languages[3]. Walmart isn’t a software shop, they certainly don’t have any stake in proving that Lisp is the one true language. If traditional approach worked then they surely would continue using it. The reason these companies are trying something different is precisely because they find current tools lacking.

    You seem to have no understanding of how functional languages actually work, so you’ve written a whole essay about why people might learn a fictional language.

    [1] http://cl-cookbook.sourceforge.net/loop.html
    [2] http://data-sorcery.org/2010/05/14/infix-math/
    [3] http://blog.cognitect.com/blog/2015/6/30/walmart-runs-clojure-at-scale

  2. October 19th, 2015 at 12:22 | #2

    The points you make about Lisp and functional languages are mostly true. I have added a link to an earlier article that discusses some of the early history of functional languages, which included a few that claimed not to support the creation of stateful information; I once pointed out to the designer of one of these languages that programs in his language could read files, wasn’t that a back door for storing stateful information (he squirmed a bit and gave an angels dancing on a pin answer).

    I am not saying that any language is good/bad or indifferent, but that some languages consistently attract developers with a Jihadi outlook on language selection and use.

  3. Dmitri
    October 22nd, 2015 at 01:09 | #3

    @Derek Jones

    Your original argument appears to imply that people feel strongly about the use functional languages primarily because they either like complexity for the sake of it or it’s a sunk cost for them. Furthermore, as I’ve detailed in the original comment, many of the arguments regarding complexity are factually incorrect.

    As somebody who developed Java for over a decade and having since moved to using Clojure, I strongly disagree with the assertion. I use it because I see practical and tangible benefits for my work, and most of these benefits stem directly from its functional nature.

    Another thing to note is that there are many different functional languages that have very different goals and properties. There are some extreme cases like Idris that focus on purity, but Lisp is at the opposite end of the spectrum in that regard.

    While it’s certainly true that there are people who enjoy languages like Haskell for the sake of the mental exercise, it’s no different than what architecture astronauts do with Java in the mainstream. In fact, the sunk cost argument very much applies to people using mainstream languages. Once you’ve sunk years into learning OOP and all the design patterns around it, it’s hard to let go of what you’re already comfortable with.

    A far simpler explanation for the phenomenon you observe is that functional languages are currently niche. People using them feel more defensive about their choice of language than those who use an accepted mainstream language. This tends to polarize people and results in what you call a Jihadi outlook.

  1. No trackbacks yet.

A question to answer *