News for hackers. Stuff that matters.
Re:Leaving Microsoft by vorg on Thursday November 22, 2012 @09:59PM (#4820812)
Scala and Clojure, the two leading alternative languages for the JVM, certainly have different strengths:

* Scala is statically typed, even using parametric types, while Clojure is dynamically typed

* Scala enables auto-currying when methods are defined in the Haskell style, while Clojure focuses on variadic functions

* Scala has easy-to-read syntax, with easy-to-remember operator precedences, while Clojure has syntactic macros instead

* Scala uses actors for concurrency, while Clojure uses its other approaches

Perhaps we shouldn't be considering them competitors but instead look for ways to more easily use them together, utilizing the strengths of each.

We could use Clojure macros to generate Scala source, e.g.

  (defn object-main [s]
    (str "object " pgm-nm "{\r\ndef main(args: Array[String]){\r\n" s "}\r\n}\r\n"))
  (defn println [s]
    (str "println(" s ")\r\n"))
  (defn call-method [obj meth p1]
    (str "(" (str obj) ")." meth "(" (str p1) ")"))
  (object-main
    (println
      (call-method 1 "+" 2)))
We could create a whole library of such Clojure functions to generate Scala code, which would give us syntactic macros for the Scala ecosystem.

And when Scala AST macros are mature, we could use them to generate Clojure code.

Using Scala and Clojure together would bring the best of both worlds to the JVM. Wouldn't that just be the grooviest?!

Re:Leaving Microsoft by bowyakka on Saturday November 24, 2012 @02:59PM (#4826275)
Your macro argument is a terrible one, you can do exactly the same thing with any sane language (and indeed I have done, getting python to create boilerplate java)

You dont need macros for this (which your post shows since I cant see any defmacro used there)

Re:Leaving Microsoft by vorg on Sunday November 25, 2012 @03:12AM (#4827638)
The first half I wrote (i.e. the 4 comparisons) was really the main point of my comment, rather than the "get started if you're eager" example code.