• 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

Questions on Clojure

 
Ranch Hand
Posts: 258
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have some questions regarding Clojure.
1) What are the main differences of Clojure, Groovy and Scala? where
- Clojure and Scala are general purpose programming language
- Groovy and Clojure are dynamic typed
- they are Functional Programming run on JVM
2) Does Clojure have good support on IDE (e.g. Eclipse, IntelliJ)?
3) What would be the greatest challenges for people to learn Clojure from Java?

Thanks
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Tong wrote:1) What are the main differences of Clojure, Groovy and Scala? where
- Clojure and Scala are general purpose programming language
- Groovy and Clojure are dynamic typed
- they are Functional Programming run on JVM


I've used all three for production systems so I'll jump in here.

I like Groovy a lot as a "better Java" because it's a very easy transition but gets rid of all the "noise" in Java. It's performance isn't great (but it's improving) but productivity is excellent, especially if you're using Grails for web development. I wouldn't really say it was a functional programming language but it offers some FP features. It's definitely the most approachable if you're coming from Java and my old team really enjoyed using it.

I initially liked Scala a lot. I liked the conciseness. I liked the functional programming aspects. It was painful to go thru the 2.7 to 2.8 transition (with binary incompatibilities in almost every new build, requiring a full rebuild of everything). The compiler is slow. IDE support wasn't great (but has improved a lot, at least in the Eclipse plugin). I attended Scala conferences and increasingly got the feeling that it was being driven by academics and not focused enough on practical usage in the enterprise (again, I know they're trying to address this). Overall, I found the type system to be too pedantic and frustrating and that a lot of the concision came at the price of hard to read code, with implicit type conversions - necessary for so much of Scala's power - making things very hard to debug. It's also a weird hybrid of OOP and FP styles and that leads to very inconsistent code, IMO. Getting my team up to speed on Scala was going to be painful so we gave it up. For all that it's promoted as a "better Java", it's really quite a different beast.

And that team has switched to Clojure. It's a smaller, simpler, more consistent language. It doesn't have a baroque type system to learn / wrestle with. Despite being dynamically typed, it compiles down to (mostly) "static Java" style code so it's very fast. It's a (mostly) pure functional language with immutable data by default - unlike Scala - and clean, consistent semantics for collections / sequences. Clojure is very concise and powerful - when we converted our Scala code to Clojure, we saw about a 2-3x reduction in the code, even following the same overall functional design, and you'll find it probably 10x more concise than Java.

2) Does Clojure have good support on IDE (e.g. Eclipse, IntelliJ)?


I can't speak to the IntelliJ plugin since I don't much like that IDE but I've heard folks say it's decent. The Eclipse plugin is great and constantly improving. Chas will be able to speak to that in more detail as he's involved with the project. I switched from Eclipse/CCW to Emacs/Swank back in October 2011 and I'm very happy with that (but then I no longer code in Java at all).

3) What would be the greatest challenges for people to learn Clojure from Java?


The biggest challenge is shedding the OOP mindset. Where I've seen Java developers struggle is that they're so used to putting state in objects and mutating it by calling methods on those objects, when you take away mutability and (Java-style) encapsulation, they lose all their reference points. Learning Clojure, if you're heavily steeped in Java's way of doing things, can be a real challenge. But, as Chas said in another thread, once you go FP, you never go back. Once you've internalized a functional style of solving problems, your approach to OOP changes and you'll find yourself writing simpler, more maintainable Java too. Even if you never write a line of production Clojure code, learning Clojure will make you a better Java programmer.
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sean Corfield wrote:

Raymond Tong wrote:

3) What would be the greatest challenges for people to learn Clojure from Java?


The biggest challenge is shedding the OOP mindset. Where I've seen Java developers struggle is that they're so used to putting state in objects and mutating it by calling methods on those objects, when you take away mutability and (Java-style) encapsulation, they lose all their reference points. Learning Clojure, if you're heavily steeped in Java's way of doing things, can be a real challenge. But, as Chas said in another thread, once you go FP, you never go back. Once you've internalized a functional style of solving problems, your approach to OOP changes and you'll find yourself writing simpler, more maintainable Java too. Even if you never write a line of production Clojure code, learning Clojure will make you a better Java programmer.



I asked a question related to this part as a supplementary question to the list of questions I asked here I am quoting it below:

Palak Mathur wrote:

One question that comes to my mind is how to change your thought process to grasp functional programming and code as data concepts for programming. How should one approach a problem. Right now, I think about problems in terms of objects. How to change this thought to be inline with Clojure or FP?



 
author
Posts: 27
Clojure
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raymond Tong wrote:Hi,

I have some questions regarding Clojure.
1) What are the main differences of Clojure, Groovy and Scala? where
- Clojure and Scala are general purpose programming language
- Groovy and Clojure are dynamic typed
- they are Functional Programming run on JVM
2) Does Clojure have good support on IDE (e.g. Eclipse, IntelliJ)?
3) What would be the greatest challenges for people to learn Clojure from Java?

Thanks



There are obviously millions of differences between those languages; they're really so different that it's easier to talk about their similarities.

* Clojure and Scala do emphasize functional programming, though to different degrees, and with different philosophies.
* Clojure is dynamically typed, whereas Scala is statically typed. At this point, Groovy allows you to opt for static or dynamic typing as you prefer.
* Groovy really doesn't encourage functional programming at all, at least to the extent that it does not emphasize immutability or programming using pure functions. It very much works to be a "better Java" in every way, and probably does very well at that.

Clojure has excellent support on Eclipse via Counterclockwise, which I use daily. There is definitely a supported plugin for IntelliJ, though I haven't used it in a while.

I actually think that functional programming is fairly straightforward to grasp, presuming you're willing to think outside of your comfort zone for a bit. The largest challenges IMO are more around the fact that Clojure is a 5-year-old language, and not 15 or 20 years old:

* People have less experience writing Clojure code and applications, so there's less certainty about what "good Clojure code" looks like. Also contributing to this is the fact that Clojure code very frequently takes the shape of its problem domain first and foremost; because there is little subterfuge involved in writing Clojure, there is rarely any boilerplate or repeating patterns in the shape of a codebase (such things would be a sign that a well-placed macro or other higher-level abstraction is likely needed). This is quite different compared to Java apps where the shape of an application is dictated by the architecture of the framework being used, e.g. a servlet webapp has to be one-class-per-servlet.

* Finding the right library and the right function to solve a given problem can be tricky; there are great tools around in the community that are working to address this, including ClojureDocs, Clojure Toolbox, Clojars, and my own addition, Clojure Atlas.

--
(coauthor of Clojure Programming from O'Reilly; creator of Clojure Atlas)
 
Chas Emerick
author
Posts: 27
Clojure
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Palak Mathur wrote:
I asked a question related to this part as a supplementary question to the list of questions I asked here I am quoting it below:

Palak Mathur wrote:
One question that comes to my mind is how to change your thought process to grasp functional programming and code as data concepts for programming. How should one approach a problem. Right now, I think about problems in terms of objects. How to change this thought to be inline with Clojure or FP?




Just so others know, I posted a response to Palak's question on moving from object-oriented thinking to functional programming.

--
(coauthor of Clojure Programming from O'Reilly; creator of Clojure Atlas)
reply
    Bookmark Topic Watch Topic
  • New Topic