• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Benefits of Learning Clojure?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently, I've been looking to Clojure and I've found information like: "What is Clojure Useful For?". While it appears Clojure can do 'everything' why would/should one learn/use Clojure? What does it have to offer over any other JVM (or otherwise) based language? Also, my background is with Java, Groovy, Ruby, and more recently Scala, how difficult will it be for me to pickup Clojure? What hurdles do you think I will encounter? Thanks.
 
author
Posts: 20
Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've responded to another thread which may help answer some part of this question: https://coderanch.com/forums/posts/list/539123#2446065
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amit Rathore wrote:I've responded to another thread which may help answer some part of this question: https://coderanch.com/forums/posts/list/539123#2446065



The answers in the other thread were helpful. I do have a follow-up question however. Being as that I'm new to functional programming, does it make sense to start my learning with Clojure or some other 'functional' language?
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While there's a lot more "classic" information out there based on Scheme and/or Common Lisp (e.g., SICP, On Lisp), I think if you're coming from Java and you're happy to work from any one of the great new books on Clojure, then Clojure is a natural choice to learn functional programming. One of the benefits in my mind is that you can mix little bits of Clojure into your day-to-day Java work, which you can't do with older functional languages.
 
Ranch Hand
Posts: 100
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan King wrote:does it make to start my learning with Clojure or some other 'functional' language?


Yes!
There is a wealth of freely available high quality lispy and functional learning materials online, you might really like one of them.
http://learnyouahaskell.com/ is fun, and there are other sources available from haskell.org
For something more academic, I just discovered http://www.ccs.neu.edu/home/matthias/HtDP2e/
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Corfield wrote:While there's a lot more "classic" information out there based on Scheme and/or Common Lisp (e.g., SICP, On Lisp), I think if you're coming from Java and you're happy to work from any one of the great new books on Clojure, then Clojure is a natural choice to learn functional programming. One of the benefits in my mind is that you can mix little bits of Clojure into your day-to-day Java work, which you can't do with older functional languages.



Keeping benefits in mind, under what situations does Clojure excel/shine? For example, while I could use Groovy for 'everything', I often use it when prototyping, creating GUIs, or developing web apps since (in my opinion) it makes completing the task(s) considerably easier.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Clojure really shines in concurrent and parallel programming, but it is a general programming language though.
 
Sean Corfield
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan King wrote:Keeping benefits in mind, under what situations does Clojure excel/shine? For example, while I could use Groovy for 'everything', I often use it when prototyping, creating GUIs, or developing web apps since (in my opinion) it makes completing the task(s) considerably easier.


I used Groovy extensively in 2008 and it's a great language as a "better Java" if you want something that's very similar to Java but works like a dynamic scripting language with some very useful features that Java doesn't have. My team built a Spring / Hibernate application with Groovy that acted as the back end to a desktop collaboration application and a mobile web app. But Groovy really isn't that different to Java so you get most of the same "problems" that are inherent in OO systems: mutable state, painful concurrency, conflation of state and identity and so on (assuming you accept there are downsides to OO, of course )

I find Clojure very productive for prototyping since I can work with code at the REPL, directly inside my IDE, and build solutions iteratively and quickly - treating Clojure as a dynamic scripting language, no doubt much like you use Groovy.

Where I find Clojure shines is when working across data sets where I can leverage map / reduce / filter and the easy composition of small, reusable functions and, in particular, high-order functions. I'm finding that the expressiveness makes me more productive than when working with other languages yet the Java interop makes it easy to leverage, and work with, existing Java code and libraries. Immutable data means easy concurrency and easier testing as well.

Like Groovy, Clojure is intended to be a general purpose programming language, as John notes in his response.
 
Dan King
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Corfield wrote:I find Clojure very productive for prototyping since I can work with code at the REPL, directly inside my IDE, and build solutions iteratively and quickly - treating Clojure as a dynamic scripting language, no doubt much like you use Groovy.

Where I find Clojure shines is when working across data sets where I can leverage map / reduce / filter and the easy composition of small, reusable functions and, in particular, high-order functions. I'm finding that the expressiveness makes me more productive than when working with other languages yet the Java interop makes it easy to leverage, and work with, existing Java code and libraries. Immutable data means easy concurrency and easier testing as well.

Like Groovy, Clojure is intended to be a general purpose programming language, as John notes in his response.



Sean, you've convinced me of the benefits of learning Clojure; now that you have, can you suggest how I should go about it? Should I use clojure 1.2 RC3 or 'clojure box'? Based on tools/plugins available should I go with eclipse, netbeans or another? Any other suggestions you may have are appreciated.

By the way, thanks for all the well thought-out and expressed answers; they've been very helpful.
 
Sean Corfield
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan King wrote:Sean, you've convinced me of the benefits of learning Clojure; now that you have, can you suggest how I should go about it? Should I use clojure 1.2 RC3 or 'clojure box'? Based on tools/plugins available should I go with eclipse, netbeans or another? Any other suggestions you may have are appreciated.


The easiest way to get up and running in my opinion is via Leiningen which is a Clojure build tool that wraps Maven. Installation is just a matter of:
  • Download the lein script, make it executable and put it on your path
  • Run lein self-install once to fetch the later Leiningen JARs
  • Run lein new myprojectname to create a Clojure project in the folder myprojectname
  • Inside that folder, lein deps will pull down the appropriate libraries (Clojure 1.2.1 by default), lein test will run any tests you've written, lein run should run your main Clojure program

  • As for IDE choices, I'd stick with whatever Java IDE you like and just add the Clojure plugin for it. NetBeans, IntelliJ and Eclipse all have plugins that are being actively developed. I use Eclipse and CounterClockWise and really like that (esp. in Strict Structural Mode so it takes care of balancing parentheses for me). I've tried IntelliJ and NetBeans but I just couldn't get settled with them so I can't comment on how slick their Clojure plugins are.

    For downloads in general, the main Clojure downloads page has a list of the official versions (although it's missing Clojure 1.2.1 - but Leiningen will handle that for you). That page also shows how to configure the dependencies for Leiningen. FWIW, I'm running 1.3.0 Alpha 7 because I like life on the bleeding edge (and I'm relying on some 1.3.0 features - as well as being the maintainer for clojure.java.jdbc, the 1.3.0 equivalent of clojure.contrib.sql from earlier versions).

    If you do decide to jump to 1.3.0, you'll need to deal with the "contrib" libraries in a different way. Feel free to start a new thread or contact me directly if you go that route and need some guidance.

    By the way, thanks for all the well thought-out and expressed answers; they've been very helpful.


    I'm glad folks are finding it helpful. I feel like I'm swamping the forums right now but I want to make sure everyone gets their questions answered and I'm a huge fan of the JVM ecosystem (even if I'm not such a fan of the Java language itself).
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic