Why I switched to Clojure: LispCast
It seems that clojure has managed to bring a breath of fresh air into the world of Lisp. As an occasional dabbler and onlooker who really really likes a lot of things about Lisp, I have to say that clojure brings some compelling features to the table.
First, let's get the things I didn't particularly get excited about out in the open. Clojure compiles to java byte codes and runs directly on the jvm. After being a huge fan of java for a period of time in the 90's and being disappointed with the performance to the point where I gave up on it, it is hard for me to get excited about anything that runs on the jvm. Java has always felt very much like a heavy weight environment. I'm sure many would contend that with the performance improvements both in the jvm as well as in modern hardware have helped to mitigate this somewhat.
As an example, I have one java application I use on a regular basis that is 1.6MB on disk. On my relatively modern laptop, it takes about 10-15s seconds from starting the application until the user interface appears and I can start using it. And this isn't just a single instance. Eclipse another high profile application takes a similar amount of time to startup. And I could give other examples of course.
Now, granted, startup time is only one aspect when looking at performance of an application. The actual performance while using the application has improved to the point that once the application is started up, most of the time I don't notice sluggishness. Until at least they've gobbled up all available memory (I'm looking at you eclipse) and your computer starts swapping.
I've read all the documentation on the performance of the jvm and how it has improved to even best C code in certain situations. Unfortunately from this users perspective, it's hard to get excited about the jvm when the examples I have used seem to really feel sluggish. In all fairness this probably has as much to do with how the code is written rather then the environment. You can write slow assembly and you can write fast PHP code. It all comes down to knowing the tool and using it well.
Well, getting back to clojure. Because of the baggage I personally have with java, the fact that it runs on top of the jvm was a damper to my excitement. Yet, there is some brilliance in this move. Let's look at a couple of the really good things that clojure gets out of running directly on the jvm.
First, and probably the biggest limiter on all new languages is the library support. You can have the best language in the world, but if it can't talk to anything, what you can do with it is severely limited. By running on the jvm, clojure is able to take advantage of all the libraries already written for java and can become immediately relevant and useful. Most other languages have to go through a growing period where the modules and libraries available to it get written to the point where there is a critical mass of developers who can do useful work in it. Until that point it is simply a curiousity and something to hack around on for most people.
The various forms of lisp have been around for a long time, but it has been my impression that finding libraries to do what you need to do when interfacing to the outside world can be challenging at times. If the library wasn't written for your dialect of lisp, you may need to patch it, etc. It doesn't help that Lisp really doesn't seem to have a well done library or module system. There are some promising projects, but there is currently nothing like cpan or java jar files that give you the ability to plug libraries in quickly and easily. Because in many cases your modifying the language itself as you add functionality, it's harder to have the ability to add modules in a clean way that will work well.
The second huge win for clojure is it's focus on concurrency. We as developers are slowly waking up to the fact that our languages need to be able to understand and handle concurrency well. Oh, and concurrency is really, really hard to do right. In all my reading about lisp and lisp like languages, only scheme really seems to have an interesting concurrency story. And even scheme doesn't seem to have a lot of work being done to push out the concurrency story today. Common lisp (sbcl in particular), doesn't seem to have anything useful without an awful lot of work. And the current developers don't seem to see that as a big problem. If I'm wrong about that, I hope someone will point me to work being done in SBCL related to concurrency.
By building on top of the jvm and focusing on concurrency, clojure has a really compelling concurrency story. The data types have been built with concurrency in mind, which makes writing applications that take advantage of multiple cores that much easier. To me, only erlang really has a possibly more compelling concurrency story. As indicated in an email by Rich Hickey (author of clojure), clojure and erlang take different tactics towards approaching concurrency. He notes "In Erlang the concurrency model is (always) a distributed one and in Clojure it is not." Clojure is more focused on taking advantage of all the cores in a machine in an efficient manner using data structures that can be safely shared. Erlang's approach is to focus on a distributed, shared nothing architecture that focuses on efficient message passing. Both are interesting approaches and probably would be best applicable to different problem domains.
The third win for clojure with the decision to go with the jvm is that it can immediately be accepted into businesses that will accept java based solutions. It's hard to write major infrastructure in something like sbcl if your sys-admins don't know how to manage it. It may be the best thing since sliced bread, but they won't be excited about it if they don't know how to manage it. As crufty as java can be with signing jar files, etc, at least people know how it's done. So, as long as there is buy in to host java apps, then there are no problems with writing major pieces of code in another language that runs on top of the jvm. To everyone else, it appears to be just another java app.
The final item that I see has a huge win for clojure is marketing and community. Lisp has a reputation as being a community that is unfriendly to newbies. I'm sure we could argue whether this is deserved or not. But, Clojure seems new and exciting and something that is actively being marketed in a good way. They are activiely looking for new people to start using it. There is an excitement and a buzz in the community that is reminiscent of the Ruby on Rails phenomenon. The level isn't quite to that fever pitch yet, but don't underestimate the usefulness of getting people excited about a language. Excitement is infectious. You see somebody else excited about something, so you go check it out. If it really is exciting (you have to pass this critical step), then you get excited and pass it on to people you know.
In conclusion, I think that clojure has a strong chance of becoming the "New Lisp" that people have been clamoring for, for years. It has strong library support (via java), it has a concurrency story, it's usable in a business setting and it's got developers excited about it. Clojure really has the opportunity to introduce a whole new generation of hackers to the coolness that is lisp without a lot of the baggage that comes along with other lisp variants. It will be really interesting to see where clojure goes in the years ahead.
So, if you haven't already, go check it out. See if clojure is the lisp you've been looking for.
It seems that clojure has managed to bring a breath of fresh air into the world of Lisp. As an occasional dabbler and onlooker who really really likes a lot of things about Lisp, I have to say that clojure brings some compelling features to the table.
First, let's get the things I didn't particularly get excited about out in the open. Clojure compiles to java byte codes and runs directly on the jvm. After being a huge fan of java for a period of time in the 90's and being disappointed with the performance to the point where I gave up on it, it is hard for me to get excited about anything that runs on the jvm. Java has always felt very much like a heavy weight environment. I'm sure many would contend that with the performance improvements both in the jvm as well as in modern hardware have helped to mitigate this somewhat.
As an example, I have one java application I use on a regular basis that is 1.6MB on disk. On my relatively modern laptop, it takes about 10-15s seconds from starting the application until the user interface appears and I can start using it. And this isn't just a single instance. Eclipse another high profile application takes a similar amount of time to startup. And I could give other examples of course.
Now, granted, startup time is only one aspect when looking at performance of an application. The actual performance while using the application has improved to the point that once the application is started up, most of the time I don't notice sluggishness. Until at least they've gobbled up all available memory (I'm looking at you eclipse) and your computer starts swapping.
I've read all the documentation on the performance of the jvm and how it has improved to even best C code in certain situations. Unfortunately from this users perspective, it's hard to get excited about the jvm when the examples I have used seem to really feel sluggish. In all fairness this probably has as much to do with how the code is written rather then the environment. You can write slow assembly and you can write fast PHP code. It all comes down to knowing the tool and using it well.
Well, getting back to clojure. Because of the baggage I personally have with java, the fact that it runs on top of the jvm was a damper to my excitement. Yet, there is some brilliance in this move. Let's look at a couple of the really good things that clojure gets out of running directly on the jvm.
First, and probably the biggest limiter on all new languages is the library support. You can have the best language in the world, but if it can't talk to anything, what you can do with it is severely limited. By running on the jvm, clojure is able to take advantage of all the libraries already written for java and can become immediately relevant and useful. Most other languages have to go through a growing period where the modules and libraries available to it get written to the point where there is a critical mass of developers who can do useful work in it. Until that point it is simply a curiousity and something to hack around on for most people.
The various forms of lisp have been around for a long time, but it has been my impression that finding libraries to do what you need to do when interfacing to the outside world can be challenging at times. If the library wasn't written for your dialect of lisp, you may need to patch it, etc. It doesn't help that Lisp really doesn't seem to have a well done library or module system. There are some promising projects, but there is currently nothing like cpan or java jar files that give you the ability to plug libraries in quickly and easily. Because in many cases your modifying the language itself as you add functionality, it's harder to have the ability to add modules in a clean way that will work well.
The second huge win for clojure is it's focus on concurrency. We as developers are slowly waking up to the fact that our languages need to be able to understand and handle concurrency well. Oh, and concurrency is really, really hard to do right. In all my reading about lisp and lisp like languages, only scheme really seems to have an interesting concurrency story. And even scheme doesn't seem to have a lot of work being done to push out the concurrency story today. Common lisp (sbcl in particular), doesn't seem to have anything useful without an awful lot of work. And the current developers don't seem to see that as a big problem. If I'm wrong about that, I hope someone will point me to work being done in SBCL related to concurrency.
By building on top of the jvm and focusing on concurrency, clojure has a really compelling concurrency story. The data types have been built with concurrency in mind, which makes writing applications that take advantage of multiple cores that much easier. To me, only erlang really has a possibly more compelling concurrency story. As indicated in an email by Rich Hickey (author of clojure), clojure and erlang take different tactics towards approaching concurrency. He notes "In Erlang the concurrency model is (always) a distributed one and in Clojure it is not." Clojure is more focused on taking advantage of all the cores in a machine in an efficient manner using data structures that can be safely shared. Erlang's approach is to focus on a distributed, shared nothing architecture that focuses on efficient message passing. Both are interesting approaches and probably would be best applicable to different problem domains.
The third win for clojure with the decision to go with the jvm is that it can immediately be accepted into businesses that will accept java based solutions. It's hard to write major infrastructure in something like sbcl if your sys-admins don't know how to manage it. It may be the best thing since sliced bread, but they won't be excited about it if they don't know how to manage it. As crufty as java can be with signing jar files, etc, at least people know how it's done. So, as long as there is buy in to host java apps, then there are no problems with writing major pieces of code in another language that runs on top of the jvm. To everyone else, it appears to be just another java app.
The final item that I see has a huge win for clojure is marketing and community. Lisp has a reputation as being a community that is unfriendly to newbies. I'm sure we could argue whether this is deserved or not. But, Clojure seems new and exciting and something that is actively being marketed in a good way. They are activiely looking for new people to start using it. There is an excitement and a buzz in the community that is reminiscent of the Ruby on Rails phenomenon. The level isn't quite to that fever pitch yet, but don't underestimate the usefulness of getting people excited about a language. Excitement is infectious. You see somebody else excited about something, so you go check it out. If it really is exciting (you have to pass this critical step), then you get excited and pass it on to people you know.
In conclusion, I think that clojure has a strong chance of becoming the "New Lisp" that people have been clamoring for, for years. It has strong library support (via java), it has a concurrency story, it's usable in a business setting and it's got developers excited about it. Clojure really has the opportunity to introduce a whole new generation of hackers to the coolness that is lisp without a lot of the baggage that comes along with other lisp variants. It will be really interesting to see where clojure goes in the years ahead.
So, if you haven't already, go check it out. See if clojure is the lisp you've been looking for.


0 comments:
Post a Comment