5 ms·
I started learning Clojure because it seemed to be the logical next step for me. In the few years that I've been programming full-time, I've noticed some patter
by jrheard 14y ago
I started learning Clojure because it seemed to be the logical next step for me. In the few years that I've been programming full-time, I've noticed some patterns: in general, imperative code with lots of side effects in it is difficult to reason about and hard to test, and pure functions are easy to reason about and trivial to test. The same rule seems to hold for code that uses mutability vs code that deals only with immutable things.
Over the past couple of years, I've learned Common Lisp by working through Conrad Barski's Land of Lisp[0] and dabbled in Haskell via Learn You A Haskell[1]. I had a great time learning both, but I found that Common Lisp had a decent number of warts (e.g. four different kinds of equality) that seemed to be primarily due to backwards-compatability concerns, and I had a really hard time getting up and running when trying to write a simple webapp in Haskell. In addition, I've gotten spoiled by how batteries-included Python (which I use at my day job) is; the library scene for both of those languages seemed lacking in comparison.
What I like about Clojure is that it gives me fast immutable data structures, has a really strong emphasis on functional programming, and has access to a really huge amount of useful libraries.
So - I've mainly been learning Clojure as a nice treat for myself; the amount of jobs that exist that employ programmers to code specifically in Clojure didn't even really occur to me as something worth thinking about. It's just really a lot of fun to program in. Also, with any luck, I'll be able to transfer any lessons I learn from Clojure to my daily work in Python.
(Haskell still has a very special place in my heart [I do frequently find myself wishing I had types], I'm not trying to dis Common Lisp nor Haskell, I'm just trying to honestly answer the question of why I thought it was worth learning Clojure).
[0] http://landoflisp.com http://landoflisp.com
[1] http://learnyouahaskell.com http://learnyouahaskell.com
- tesmar2 14y agoWhat do your superiors think about implementing new, small projects in Clojure? When you say "has a huge amount of useful libraries" but then say that Python is "batteries included", which libraries in Clojure are particularly useful? Which ones did you wish it had?
- jrheard 14y ago1) Remains to be seen :) 2) I used those two phrases interchangeably - I consider both Clojure and Python as "batteries-included" languages. Case in point - before I was aware that Clojure Toolbox existed, I was able to google "clojure http request" and find several libraries that let me perform HTTP requests programmatically that I could include in my project.clj and start using right away. My memory's a little fuzzy, so apologies if this is completely wrong, but I don't recall having as easy a time doing that in e.g. Common Lisp or Haskell. As far as which libraries in Clojure are particularly useful - Ring and Compojure are fantastic, and core.logic[0] is extremely interesting; I'll write a blog post showcasing core.logic (and using it for my first time ever) at some point. Midje is great for writing unit tests. I've only been using Clojure for a few months, so I can't point to too many others that have really been extremely useful for me, but I definitely recommend checking out the Clojure Toolbox[1] for a more thorough list of the main contenders. [0] https://github.com/clojure/core.logic/wiki/A-Core.logic-Primer https://github.com/clojure/core.logic/wiki/A-Core.logic-Prim... [1] http://www.clojure-toolbox.com http://www.clojure-toolbox.com
- jimbokun 14y agoIf you don't find a Clojure library meeting your needs, you can always find a Java library for that purpose and "wrap the crap". http://news.ycombinator.com/item?id=1883043 http://news.ycombinator.com/item?id=1883043
- straws 14y agoTo me, this is the smartest part of using Clojure in your projects. If you're a company with an enormous Java stack, it's trivial to add things like Clojure or Scala and use them as scripting languages. Or break out a library and rewrite it using one of the two, if that problem would be better solved more functionally. Basically it makes it easy to convert projects without tearing down your infrastructure, ie, easy to convince your boss.
- TheMiller 14y agoI realize this is quite off the main topic, but I thought it was interesting and worth passing on. If you really think that "four different kinds of equality" in Common Lisp is a wart, then I recommend that you read "The Best of Intentions" (http://www.nhplace.com/kent/PS/EQUAL.html http://www.nhplace.com/kent/PS/EQUAL.html) by Kent Pitman. The article explains why that situation is quite intentional, and why it is very rational, and why it is in fact ill-advised to expect a single meaning for "equal" ... or, in fact, other "obvious" concepts like "copy" ... to be sufficient. That article was one of the many over the years that helped me refine the way I think about programming and programming languages.
- jrheard 14y agoThanks for the recommendation, I'm looking forward to reading the article!