BT

InfoQ Homepage Presentations What Sucks about Clojure...and Why You'll Love It Anyway

What Sucks about Clojure...and Why You'll Love It Anyway

Bookmarks

Bio

Chas Emerick is a coauthor of Clojure Programming from O'Reilly, and a contributor to Clojure itself and dozens of Clojure projects. He's been deploying Clojure in production since 2009 — primarily to solve various document extraction problems — having adopted it as his primary language the year before. He writes about software development, entrepreneurship, and other passions at cemerick.com.

About the conference

Clojure/West is a new conference bringing the Clojure community together to discuss techniques, tools, and the state of the Clojure ecosystem March 16-17th for three tracks of sessions. Prior to the conference, register for three days of training by the Clojure experts.

Recorded at:

Jun 19, 2012

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Sorry but it has an awful syntax !

    by Serge Bureau /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Plus I find Scala much more powerful for abstraction.

    It might be my difficulty with the syntax, but I had difficulty with Scala, but I find it has incredibly more "features" than Clojure. And the extensibility of DSLs is much more natural to use.`

    So I see very little use case for Clojure.

  • Re: Sorry but it has an awful syntax !

    by Timothy Baldridge /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    And I found the opposite. After working with the simplicity of Clojure, the last thing I want is a complex type system, or even a strongly typed language at all.

    I think this is where the debate ends up. If you love statically typed languages, then you'll love Scala. If you detest them (as I do) then you'll love Clojure.

    And as someone who used to think Lisp was impossible to read, I have to say, I don't even notice the parens anymore.

  • Re: Sorry but it has an awful syntax !

    by Serge Bureau /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    And I found the opposite. After working with the simplicity of Clojure, the last thing I want is a complex type system, or even a strongly typed language at all.

    I think this is where the debate ends up. If you love statically typed languages, then you'll love Scala. If you detest them (as I do) then you'll love Clojure.

    And as someone who used to think Lisp was impossible to read, I have to say, I don't even notice the parens anymore.


    I suppose I do agree, I do like Statically typed system.
    I love the Object/Functional mixture.

    I do feel like Clojure has no structure, it can be considered freedom I suppose. But structure brings stability.

    As for parens, I gladly leave them to Clojure programmers.

    Clojure syntax makes using DSL's very unnatural

  • Re: Sorry but it has an awful syntax !

    by paul iannazzo /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    with clojure you are programming at the AST level. that's why the syntax is the way it is. there is no real difference when writing a function or DSL in clojure.

    personally i find the lack of syntax in lisps to be very nice, as I can focus more on solving my problems than learning a language.

    clojure has typing too, though i haven't used it.


    the main things that draw me to clojure are the problems it solves and the way it does so. strong immutability (not as strong as haskell/erlang, but much more so than scala/groovy). also i was very interested in persistent data structures and agents.

    also, from what i've heard of scala, code bases for problems in it and clojure seem to be of similar sizes, so scala must be doing something very right, also i heard that scala has pattern matching, which is super cool.

  • Re: Sorry but it has an awful syntax !

    by Paul Anders /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Serge Bureau,

    do you know what some times help? A little humility helps (IMHO).
    How many time have you spend with Scala or Clojure? Each 3 Month, 6 ? 1 year or more? Have you used in a commercial project? Read some papers which discus
    On DSL Syntax
    Scalas point free style is IMHO very limited and there are corner cases lurking everywhere..l
    On Syntax
    Clojure Syntax reads so much nicer (IMHO) because you use only white space and parens (no ; . etc.) Plus macros can clean up a lot of things, which leads me too...
    Features
    Lisp/Clojure have deep concepts(macros and many more) which allow for more, many more "features".

    Thats not to say Clojure doesn't have its mistakes (like flatten doesn't keep collection types)

    Plus I find Scala much more powerful for abstraction.
    So I see very little use case for Clojure.
    <- Little too much I for me IMHO :D

    So my advise: try to observe very carefully. Listen to people why they like or dislike the one or other language. And then maybe again you can share you thoughts and other people can take value form that judgement.

  • Re: Sorry but it has an awful syntax !

    by Serge Bureau /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I know more about Scala than Clojure.

    But sorry, a Lisp by another name is still lisp.
    It has always been very good at what it does.

    But sorry, a syntax based on "Clojure Syntax reads so much nicer (IMHO) because you use only white space and parens (no ; . etc.) " is not simple but anemic.
    Having to write a DSL where I will have parens everywhere is not a selling point at all for me.

    The whole point of a DSL is to make the user feel like he is almost not programming and immerse him in is domain. Having an artificial syntax is far from reaching that goal.

    As far as features, I think you underestimate Scala a lot.
    I of course know less about Clojure.

    People talk about the fact that Scala does not enforce immutability as a great weakness, I disagree for practical reasons. And I find that Clojure not enforcing types is a much greater weakness.
    I live in the real world, and bugs pops very often, an enforced type system is essential.

  • Re: Sorry but it has an awful syntax !

    by Paul Anders /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Serge,
    I don't know if you heard, but Lisp is a very powerful concept. So powerful indeed that it can provide features via libraries that are actually 'backed' into other languages.
    Just to give you two examples from clojure:
    pattern matching is not supplied with the language but as a library: core.match (implemented via macros) see github.com/clojure/core.match

    You also mention static typing. You can actually supply that too as a library:
    github.com/frenchy64/typed-clojure

    So think about it how is that possible?

    You mention to disregard immutability for practical reasons. I disagree with that strongly. Please read papers : 'No Silver bullet' and 'Out of the Tar pit' it is worth, I Promise.
    If you struggle with functional programming I suggest a video with Neal Ford: Functional Thinking, it is a really good introduction and explains e.g. why it takes some time if your used to something different.
    Using the three principles suggest here you can develop on a new level:
    twitter.com/debasishg/status/215456651199787008

    I hope this stuff gets you started, if you are interested in improving your programming it certainly will.

    Finally I wanted to say I hope my last post didn't sound to harsh, I somehow felt a strong urge to answer it xkcd.com/386/ ;)

  • Re: Sorry but it has an awful syntax !

    by Serge Bureau /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I have read one of the article and will read the others.
    Many of the functional benefits are really extremely good, and this is why Scala is attractive, but the mixture with objects and more is even more interesting.

    If Clojure is so magnificent, why Lisp that is Clojure from the 50's never really became mainstream ?

    Syntax comes to mind, and having a lot of things in library is nice, but optional by design.

    Optional type system is to be left in the hands of programmers, I am more confident in the compiler.

    It remembers me of XML before the schemas, they said why should we need types ? They soon understood their mystique.

    Can you do a DSL without parenthesis in it ? What an incredible limitation.

    As far as extending by library, so is Scala. But the XML DSL for example looks like XML, not like XML with a mix of parenthesis.

    Clojure I am sure is powerful, but no forced type system, no objects and so much more.
    You say you can build it after, well I could also say that assembler is the ultimate in flexibility ; but I won't use it in any of my projects.

    So it is not for me, but I am sure learning more about functional programming. But I am not in adoration with it.
    I prefer the mix of paradigm provided by Scala.
    Functional is nice, but functional with objects and Akka is tremendous.

    So have fun, I am sure I will too ;-)


    Having a language that can modify itself is powerful, but impossible to secure.

  • interesting self-critique

    by Arturo Hernandez /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    It is very interesting to hear the experiences of a programmer after a good time of using it. I think the ideas in Clojure go well beyond Clojure or Lisp itself. I do think Chad arguments that STM and macros are hard, and maybe there should be some safeguard in the manner of extra complexity, was unfortunate. As an analogy we can do many things with our money. It is a very simple thing to use. Although we all know of those amazing Namibian entrepreneurs that scam people from their money. We would not place barriers on international transaction to save people for unwittingly risking their money. Chad's advice should be enough. I've heard horror stories of concurrent program debuting, and Chad's story just did not sound as bad. Concurrency is just hard. Making advanced features more accessible is a real plus.

  • Re: Sorry but it has an awful syntax !

    by Sergio Diaz /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Serge.

    If Clojure is so magnificent, why Lisp that is Clojure from the 50's never really became mainstream ?

    Syntax comes to mind


    Well that is an argument used by many people who just don't like Lisp. I don't know how you use it. If being mainstream is so important, why don't just stay with Java. Is certainly more mainstream than Scala. I think the reason why lisp it isn't mainstream is the same reason for Smalltalk, because with old hardware it was slow. And lisp got trapped as a AI niche language. Functional programming is taught after 3+ courses of imperative programming, so after you crossed the chasm from math in k-12 to imperative programming & going back to math-like thinking (FP) is not so easy.

    Optional type system is to be left in the hands of programmers, I am more confident in the compiler.


    If type systems are so great about catching errors, why you get bugs with those languages, including Haskell. I don't know Scala, but Can you define a type that will help you catch a memory leak at compile time?. I don't think so. There are many classes of bugs that are orthogonal to a type system. You get bugs anyway, type systems never helped me to catch any error, because it is not in my mind set. I caught them by reading my code as i type it, thats the best way to do so. If you get used to your compiler catching errors, your ability to read code won't be as sharp as it can get. Types are really useful for performance, nothing more.

    By the way, thank god i never found a blogpost i read a month ago about monads with Scala when i started to study them. Because i would've quit. It's funny you said clojure has an awful syntax, that is the first thing it comes to my mind when i here the word "Scala", sorry i don't like it. The type syntax for a stuff like Monad trait or Functor trait is really awful. Haskell syntax, even it's error messages are less cryptic than Scala's (IMHO).

    Can you do a DSL without parenthesis in it ? What an incredible limitation.


    Yes you can, see the loop macro from Common Lisp, no parens. As for parenthesis, Clojure has less than any other Lisp. And parens in any lisp code have a greater density but in total counting, I think you'll have less parens than an equivalent library in Java or even Scala (IMHO) we can try & do the counting. To me is not a limitation, to make a DSL look like is part of my language, that is a plus.

    As far as extending by library, so is Scala. But the XML DSL for example looks like XML, not like XML with a mix of parenthesis.


    In this case, its noise to me, like reading HTML mixed with javascript.

    So, have fun and try to be more open about the parens & syntax, any programming language is artificial after all. :)

  • Re: Sorry but it has an awful syntax !

    by Serge Bureau /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Smalltalk and isp had one common flaw.
    It can modify itself, while interesting for academic reasons, remember that Smalltalk was distributed with no warranty for that reason, they could not support a language that could have been changed by the user ! Spped for Smalltalk was an issue for the machines at the time because of the integrated bitmap graphics, this part was not an issue for Lisp I believe.

    So your view on Type systems is that if it does not catch all errors it is not needed ? Your serious ?
    I prefer infinitely more catching error at compile time than at run time like dynamic languages.
    I fact unit testing has mainly become popular because it is essential for dynamic languages, but much less efficient than strictly typed system. Although for preventing errors, both have their use.

    As far as Scala complexity, it includes facility for all level of users: programmers, analyst, library designer's, ... The complexity is on an as needed basis. Java for example is good for regular programmers, but totally lacking for advanced user's.

    You said: """ To me is not a limitation, to make a DSL look like is part of my language, that is a plus.""". You must be joking. Please read what I wrote on the previous message again. The goal of a DSL is to serve people from a certain domain of expertise, not to bring this new domain to the host language ! It does not make sense otherwise.

    You also mentionned: """In this case, its noise to me, like reading HTML mixed with javascript."""
    Another strange comment, the goal for this is to allow people fluent in XML to transparently use it in their code, if you do not need it the do not use it ?
    But I want the same with SQL or even shell script for example. The point is to bring the most transparently possible another domain language.

    And in many cases to improve on it, like Squeryl for an ORM between Scala and SQL or the same for bringing Java SWING. In those case you are more diminishing the impedance between the host language and anothe domain.

    Parens and syntax are anoying but not the real issue (although for DSL it is). The main issue is self modification (even if it can be amusing) and no enforce type systems: I cannot compromise on that.

    But I am all for people having fun, life is short !

  • Re: Sorry but it has an awful syntax !

    by Arturo Hernandez /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Nobody can argue against catching errors. You are presenting a false dichotomy, strong typing vs dynamic languages. And strong typed languages will catch errors at compile time. For many programmers that is a good option. I'll exaggerate a little bit here but would you rather cut wood with a saw or a swiss army knife. The army knife is much safer but in an effort to finish on time you may cut yourself with it. That is just the right tool vs safety part or the argument. I personally have seen perfectly typed checked systems that don't work because they update data incorrectly, so in this way Clojure would be "safer" to use.

    PHP has more than proved that adoption is not a function of quality. So any references to the adoption record of many languages are a hard buy.

    What I would like to see is more static checking of dynamic languages. And there are already such projects under way for Clojure.

  • Re: Sorry but it has an awful syntax !

    by Sergio Diaz /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    My point about type systems is, they are overrated. And the point you love to made, it really has no strength at all, "I prefer infinitely more catching error at compile time than at run time like dynamic languages." When you said that, it seems so absolute, like theres one unic window of time when the code will run, only in production, as if you love to compile and ship it, and never actually run before a user does. Type systems are good, but not the super awesome perfect tool you blindly believe they are.

  • Re: Sorry but it has an awful syntax !

    by Greg Tewalt /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    If you can approach with an open mind, and read Chapters 2 and 3, of this book:
    www.cs.cmu.edu/~dst/LispBook/

    It will become clear why the syntax is the way it is.

    Shortly thereafter, with the help of any decent editor that has Paren matching, the parenthesis will disappear.

  • Re: Sorry but it has an awful syntax !

    by Val Waeselynck /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Theoretical comparisons of languages based on features are systematically dead-ends. The empirical factors are just too significant.

    Your best options to actually make a good comparison are:

    1. Try both options (giving them equal chances)
    2. (not as good): ask someone who has tried both options.

    I personally was used Scala for several months before learning Clojure, was very enthusiastic about it, and what you're saying totally echoed with my mindset of this time, I could totally imagine myself saying it too. Then I learned Clojure.

    And now, reading your comment, I think : "... nah, that's just not the way it works". I deeply prefer Clojure in the general case, including its syntax, and have found all your arguments invalid for reasons you can never understand until you give Clojure a fair try.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.