

Getting started with Scala's new macros - richdougherty
http://scalamacros.org/documentation/gettingstarted.html

======
lucian1900
Every now and then I look around for ways to write native Android apps with
something other than Java, and the only reasonable answer is still Scala.

But its syntax is so ridiculous! What on earth were they thinking?!

~~~
daniel_solano
Yes, Scala is currently the best alternative to Java for Android development,
but I am hoping that Clojure can close the gap significantly.

The main drawback to Clojure is still the start-up time, but that's getting
better. For example, the metadata elision introduced in Clojure 1.4.0 speeds
things up a bit and makes a significant cut in Clojure’s heap use.

However, one thing that Clojure gives you that Scala cannot, is the ability to
do REPL-driven Android development, i.e. sending code directly from your
editor to a running application and seeing nearly instantaneous results.

One thing I hope will help Clojure significantly is that it has a Google
Summer of Code student who is going to be working on improving the tooling
support for Android and Clojure. This should make it much easier for Clojure
developers to start creating Android applications.

~~~
cageface
My understanding is that Clojure also relies heavily on some of the advanced
Hotspot optimizations that aren't available in Dalvik so it's often much
slower on Android than it is on the standard JVM.

~~~
daniel_solano
Really? I haven't heard of that.

In my experience, most of the alternative compiled JVM languages, i.e. Scala,
Clojure, Mirah, and JRuby, seem to run fairly comparable to each other once
they have started. The biggest differentiator between them with respect to
performance seems to be in the way of start time and heap overhead ranging
from none (Mirah) to substantial (JRuby).

~~~
cageface
Naively written Clojure is going to run a lot slower than Scala because it's
doing a lot more dynamic dispatch. With the right type annotations you can
probably get them fairly close.

------
islon
These are scala's macros? Lisp/clojure/scheme guys are probably laughing right
now. I have nothing against scala but they really need to shoehorn every
possible feature in the language?

~~~
kenbot
Scala's feature-space is admittedly crowded, but there is a method to the
madness.

Scala's core design is generally to use a small number of rules to create a
wide range of possibilities; the macro design they've chosen fits right in.

At the cost of almost no extra syntax, a whole range of things that would have
required compiler plugins, special language features, or been flat-out
impossible are enabled. It's (probably) a cheap win in this case.

~~~
islon
I agree, macros are a nice addition to the language and I would choose scala
over java anytime. What bothers me is that scala has so much syntactic sugar
one can die of diabetes just by looking at some source code.

~~~
soc88
Care to explain? I have not experienced that. From which language do you come
from? It certainly has less syntactic sugar than Java...

