4 ms·
I have been thinking about getting into Clojure, but time is precious. It doesn't seem like there are that many jobs out there, but I could be wrong. For those
by tesmar2 14y ago
I have been thinking about getting into Clojure, but time is precious. It doesn't seem like there are that many jobs out there, but I could be wrong.
For those of you in the industry, why would I want to use Clojure? What would be a good project to try it on? A Web app? Why is it worth learning it?
- paolovictor 14y agoThis post is specially relevant for me, since last weekend I've decided to take a quick look at Clojure, as one of my personal goals this year is to get acquainted with a Lisp dialect. From my _very_ short experience (I've started coding a simple game), here are my two cents: - If your application is heavily dependent on state, which changes continuously and must be maintained during most of the execution time - like a game - it may not be a good fit. You'll waste a lot of working around the fact that each modification results on new objects. - If your application comprises mainly of short requests that may create some state that will most certainly be discarded shortly after - like a web application - then I think it's a good fit and you'll probably enjoy it better. Once again, I've just got started with it, so take this with a grain of salt :)
- tesmar2 14y agoThanks for this. I'd hate to start down the road of writing a game in clojure.... I may try the blog/webapp idea with Clojure.
- jrheard 14y agoProgramming a game in Clojure might not be such a bad idea - mikera has some really great thoughts at http://stackoverflow.com/questions/9755882/are-functional-programming-languages-suitable-for-graphics-programming http://stackoverflow.com/questions/9755882/are-functional-pr... . Also, you might find this series of blog posts interesting: http://briancarper.net/blog/520/making-an-rpg-in-clojure-part-one-of-many http://briancarper.net/blog/520/making-an-rpg-in-clojure-par...
- EastCoastLA 14y agoDon't forget: The Caves of Clojure - steve losh http://stevelosh.com/blog/2012/07/caves-of-clojure-01/ http://stevelosh.com/blog/2012/07/caves-of-clojure-01/
- aphyr 14y agoI'd like to contrast this: if your application is heavily dependent on state, especially state which is shared between threads, Clojure offers a concise, safe, and uniform way to understand and organize state transformations--at the cost of performance. Where fast mutability is required, it's easy to drop down to explicit locks, atomics, java.util.concurrent collections, et al. I find the majority of my time in writing stateful programs goes towards reasoning about safety, and having access to STM lets me write correct code with less thinking. Then I focus on optimizing the parts where performance is critical.
- billsix 14y agoAt ILC 2009, Guy Steele asked Rich Hickey how Clojure's STM interacted with I/O. To which, Rich replied that it doesn't. No further discussion continued on the subject. I have found that this rarely enters discussions regarding Clojure, although the STM is frequently lauded. GHC's STM also does not work with the IOMonad, which is clear because of the types, and is articulated in books such as such as Real World Haskell. http://book.realworldhaskell.org/read/software-transactional-memory.html http://book.realworldhaskell.org/read/software-transactional... Are people really getting benefits from transactions which do not involve I/O?
- jrheard 14y agoThat's odd, that seems a little inaccurate to me. Clojure's agents are useful for encapsulating I/O-related resources, and are integrated with the STM system. Per http://clojure.org/agents http://clojure.org/agents - Agents are integrated with the STM - any dispatches made in a transaction are held until it commits, and are discarded if it is retried or aborted.
- craigching 14y agoI'm a clojure newb myself, but I thought STM transactions weren't allowed to have side-effects and IO would be a side-effect, no?
- 14y ago
- julsonl 14y agoFor games, Chris Granger and his team have coded up a prototype game in Clojurescript using the Entity-Component-System architecture, which seems to be a good fit for functional languages. It might be worth checking out: http://www.chris-granger.com/2012/12/11/anatomy-of-a-knockout/ http://www.chris-granger.com/2012/12/11/anatomy-of-a-knockou...
- Tuna-Fish 14y agoActually, in my experience the practises in the high-end AAA game industry are now much closer to FP than the rest of the industry. The current-gen consoles have lots of really weak threads, and to get any decent performance you have to use a lot of them. So, modern games do things like double-buffer the entire world state to allow efficient multithreading. Of course, everyone there is doing FP in C++.
- jrheard 14y agoI 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 agoWhat kind of job are you trying to get? If you want to start your own venture, using a powerful language like Clojure might give you an edge. http://www.paulgraham.com/avg.html http://www.paulgraham.com/avg.html Learning a powerful, less main stream language like Clojure can also signal to smart, innovative software companies you might be the kind of person they should hire. http://www.paulgraham.com/pypar.html http://www.paulgraham.com/pypar.html