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

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.