Skip to main content

How can I transition from Java to Clojure?



After discovering Clojure I have spent the last few days immersed in it.





What project types lend themselves to Java over Clojure, vice versa, and in combination?





What are examples of programs which you would have never attempted before Clojure?


Comments

  1. Clojure lends itself well to concurrent programming. It provides such wonderful tools for dealing with threading as Software Transactional Memory and mutable references.

    As a demo for the Western Mass Developer's Group, Rich Hickey made an ant colony simulation in which each ant was its own thread and all of the variables were immutable. Even with a very large number of threads things worked great. This is not only because Rich is an amazing programmer, it's also because he didn't have to worry about locking while writing his code. You can check out his presentation on the ant colony here.

    ReplyDelete
  2. If you are going to try concurrent programming, then I think clojure is much better than what you get from Java out of the box. Take a look at this presentation to see why:

    http://blip.tv/file/812787

    I documented my first 20 days with Clojure on my blog

    http://loufranco.com/blog/files/category-20-days-of-clojure.html

    I started with the SICP lectures and then built a parallel prime number sieve. I also played around with macros.

    ReplyDelete
  3. What project types lend themselves to using Java over Clojure, vice
    versa, or in combination?

    A project where a GUI-building tool
    (such as Matisse in Netbeans) is
    needed would be a case where Java may
    still be required. Anything done in
    Java can be done in Clojure quite
    readily, with proxy and gen-class if
    needed, or just accessing Java as
    needed (., doto, new, etc.). This
    allows Clojure projects to easily use
    Java libraries or legacy Java code.

    Which programs which you would have never attempted before Clojure ?

    Before I found Clojure, I was
    contemplating a project that required
    JDBC, would run in a servlet
    container, and I anticipated doing a
    lot of iterative development because
    it wasn't clear what methods would
    work for the data I needed to analyze.
    I put it on the back burner because I
    didn't have the time or patience for
    the compile-debug- deploy-validation
    cycling that Java requires. I've now
    written the application in Clojure,
    and I'm very pleased at the ease of
    making changes on the fly and being
    able to examine the results
    immediately. Not to mention the joy
    of lock-free programming and being
    liberated from having to develop (and
    refactor) class hierarchies.

    - "MikeM" via the clojure@googlegroups.com mailinglist

    ReplyDelete
  4. What project types lend themselves to Java over Clojure, vice versa, and in combination?


    If you want to develop a framework that is to be consumed by Java and Clojure, I've found writing the main abstractions (interfaces ad base classes) in Java to be preferable over writing them in Clojure (I find Clojure's gen-class to be somewhat tedious and rather use proxy).

    If you're a user of Hibernate or any other framework that makes heavy use of Java-annotations without offering a programmatic alternative, you'll have some trouble, since it's not trivial to emulate annotated POJOs with Clojure's data structures.

    Apart from that, I've experienced no use cases for which Clojure is less appropriate than Java; you have to cope with the loss of static typing, of course, which feels somewhat disconcerting at first, but tends to go away.

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex