Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?!



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)


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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: