What is Clojure useful for?

Clojure

Clojure Problem Overview


What real world applications are people using Clojure for?

I use Groovy for glue stuff, Java for big systems, Python/Perl scripts for parsing and glue. I could see myself calling into Clojure from Java but I can't see where I would use it in its own right. It strikes me it would be easier to use almost any scripting language for adhoc tasks.

I'm not a Groovy expert or a fanboy by any means but it strikes me that it has a better support framework, tools and a lot of the language constructs (closures, functional programming). The same could be said for Scala.

Could it be that its future is as a language that is embedded in other systems?

Clojure Solutions


Solution 1 - Clojure

I've used Clojure for:

  1. Scraping web pages
  2. Shell scripts
  3. Building websites
  4. Playing around with OpenGL
  5. Writing async webservers
  6. HTML Templating
  7. Running parallel tasks (fetching multiple URLs and process in parallel)
  8. Playing around with real time audio
  9. Simulations

That's the practical / fun stuff.

But Clojure has plenty of theoretical depth as well. Ideas that will become increasingly more relevant as the mainstream comes to really understand the potential of Functional Programming.

A personal opinion, but Clojure flat out provides better language constructs for organizing software correctly (without causing undue pain for the working programmer) of all the languages I've used thus far academically and professionally - C, C++, Objective-C, Java, JavaScript, Python, Ruby.

Which isn't to say Clojure is perfect. But it seems to me that it's built on a better foundation than most of what's out there.

Solution 2 - Clojure

Maybe start with Rich Hickey's rationale.

As for real-world apps, how about this roll call of production use from the google group?

Solution 3 - Clojure

Clojure is being used extensively for processing large volumes of data. It is very well suited to data mining/commercial-AI (ie: Runa) and large scale predictions (aka WeatherBill). Clojure's concurrency story really helps in these data heavy domains where parallel processing is simply the only answer.

Solution 4 - Clojure

Well, that is a difficult question to answer. What do you want to do? There isn't a whole lot that Clojure isn't really suited for. I mean, it isn't really great for one off command-line scripts because of the JVM startup time (unless you're using cake or something similar), but that can be said for any JVM language.

Clojure is especially suited to concurrency tasks. It was built from the ground up to be an awesome language for concurrency, and it's STM system is fantastic. If you need to do some hardcore concurrency related stuff, Clojure might be especially suited to that task.

However, one must remember that Clojure is a general purpose language. It isn't only suited to certain niches, and it tends to be useful for many or all of the things that the other JVM languages might be suited to.

Clojure was designed to be a fantastic language in it's own right, and not necessarily a glue language. You can build systems from the ground up in Clojure without ever touching Java code directly. Not that it doesn't make a nice glue language, I know lots of people have used it as such.

If you have something in mind, the best thing to do is to consider what the solution would look like in whatever languages that are options. If it looks/feels better in Groovy, go with Groovy. They're both radically different languages, and they both have their purposes.

Solution 5 - Clojure

You can use Clojure anywhere you would use Groovy or java. Why would you want to do that ? Some people like lisp. Those will be choosing clojure over Groovy. Some people dislike lisp. Those will be choosing Groovy.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFortyrunnerView Question on Stackoverflow
Solution 1 - ClojurednolenView Answer on Stackoverflow
Solution 2 - ClojureCorbin MarchView Answer on Stackoverflow
Solution 3 - ClojureArthur UlfeldtView Answer on Stackoverflow
Solution 4 - ClojureRayneView Answer on Stackoverflow
Solution 5 - ClojureVagif VerdiView Answer on Stackoverflow