I meant that unfortunately Clojure will not be gaining very much popularity in web development.
I agree that Rails is a much better web framework than Compojure/Ring. If you are doing web development, it makes sense to use Rails.
You can use Compojure or Enlive for straight web development if you want. But, at this point it is inferior to rails.
So I guess what I meant is, I would like Clojure to be more popular. But, it doesn't look like it will be getting any major attention in web development any time soon.
I'm a biased source, but whilst I agree that Rails is the better option for most professional web development at the moment, the gap has narrowed rapidly over the last year or two.
In my opinion, the current things that Rails framework itself does better than Clojure are:
1. Model Validations
2. Database Migrations
3. Project skeleton/generator scripts
4. Table relationship sugar (belongs_to etc.)
I don't think that's a huge list, and it's actively being worked on. I suspect that we'll have a framework equivalent to Rails sometime early 2012.
Of course, this doesn't address the Rails ecosystem, which will probably be larger and more mature than Clojure's for some time to come. However, not everyone needs the full range of plugins available for Rails, so depending on the project, there may not be any difference between using Clojure and using Rails.
At which point it comes down to whether you prefer Ruby or Clojure as a language.
I wish this had answered my question more though - what is it that I'm missing. I mean, we have been building web frameworks for every new language that comes along. So what is it about web apps that we haven't solved? What does Clojure bring to the table? How will it help me make better web sites for my clients than Rails currently does?
When I switched from PHP to Rails, I did so cos it was easy to see the benefits - in 2004 there were no serious web frameworks, there were no easy ORMS that cut out the trivial crap I had to build from a week down to a day. I could quickly get the simple stuff out of the way so I could write code for the bigger problems.
So now here I am six years later, and I'm really really intrigued by Clojure, but I'm not seeing where it fits. I don't need a different way to build web apps... I need a better way. Otherwise I'm not that interested in taking a step backwards productivity-wise.
So, I'm looking to learn, cos I do think it's a fun language, and I've learned a lot more about programming while learning it. Maybe that's its role.
This is a difficult question to answer, because it ultimately boils down to the philosophical differences between Clojure and Ruby.
Clojure favours discrete components that do one particular job. For instance, protocols were introduced to Clojure to provide efficient polymorphism, and they do not attempt to do anything more than this.
Ruby is an object orientated language, and tends to favour grouping together a wide range of functionality into indivisible components. For instance, classes provide polymorphism, inheritance, data hiding, variable scoping and so forth.
The advantage of the Clojure approach is that it tends to be more flexible. For instance, in Sinatra you can write:
get "/:name" do |name|
"Hello #{name}"
end
And in Compojure, you can write:
(GET "/:name" [name]
(str "Hello " name))
Superficially they look very similar, but their implementation is very different. The Sinatra code adds the enclosed block to a hash map in the current class, whilst the Compojure code just returns an anonymous function. The Clojure approach sacrifices some convenience for greater flexibility. For instance, in Compojure I can write:
Because each route is discrete and independent of any larger construct, I can easily take routes and use other functions and macros to group them together.
I may be wrong, but I don't think there's an easy way of doing this in Sinatra, because routes are bound to a class when they are created.
Thanks. I kinda see where that might lead. It feels much like Rails' nested routes.
There are a ton more questions I'd love to ask, but I feel like I'm taking the thread off topic, so I'll go investigate Compojure a bit more on my own.
Use the right tool for the job. Rails and PHP are pretty good options for web development, and JavaScript is a very good option for small client-side scripts.
On the other hand, if the job is to create artificial intelligence, then it is Lisp that is the right tool for the job.
I agree that Rails is a much better web framework than Compojure/Ring. If you are doing web development, it makes sense to use Rails.
You can use Compojure or Enlive for straight web development if you want. But, at this point it is inferior to rails.
So I guess what I meant is, I would like Clojure to be more popular. But, it doesn't look like it will be getting any major attention in web development any time soon.