Scala Macros: video and meeting topic for next Monday 28th

22 views
Skip to first unread message

Ben Hutchison

unread,
May 23, 2012, 9:29:00 AM5/23/12
to scala...@googlegroups.com
Hi all,

A reminder that the very able Ken Scambler will be presenting on Scala
2.10's upcoming macro feature at our next Scala meeting, next Monday
May 28th at our regular venue VLSCI. Arrive from 6pm, talks start at
6:30. Hope you can make it.

Macro's essentially make the compiler extendible by the application,
tool or library programmer, in a much more accessible, safe, and
reusable fashion than the older compiler plugins did.

On this topic, last night I watched the ScalaDays talk on macros, by
their creator Eugene Burmako, assisted by EPFL colleague Christopher
Vogt [http://skillsmatter.com/podcast/scala/kepler-metaprogramming-scala].
He is one very smart guy and his talk really brought home to me how
much power macros bring to the table. Even given that Scala is
littered with powerful tools, this one is a biggie. As well as noting
that already macros are already being used inside the scala compiler
codebase to simplify and reduce it, he talks about the upcoming SLICK
tool, Scala's version of LINQ. Although at face-value macros allow
application-code to execute at compile- rather than run- time, in
SLICK they are fruitfully applied to do the reverse: compile time code
is lifted via a macro into an LINQ-like "expression tree", to be
manipulated at runtime. This is the secret sauce that allows scala
code to transform into SQL queries that are sent to the database for
execution.

Macros seem to offer a much more elegant way to integrate datastore
queries into the language than the approach employed by earlier
frameworks such as Squeryl. For example, looking at this squeryl
code....

class Artist(val id: Long, val name:String) {
def songs = from(MusicDb.songs)(s => where(s.artistId === id) select(s))
}

...you might wonder

(a) Why is the where condition a function of some strange parameter 's'?
(b) Why is equality tested with '===' ?

And in seeking the answers, you'll discover that Squeryl is keeping a
straight face while inwardly going through painful contortions in
order to defer the execution of any code in the query, since it wants
to turn it all into SQL.

It was a valiant attempt, given the available technology, but macros
offer a much more elegant way to "write-as-scala", but "run-as-X",
where X might be SQL, Javascript, or GPU code.

-Ben

Bernie Pope

unread,
May 28, 2012, 3:01:56 AM5/28/12
to scala...@googlegroups.com
Hi everyone,

I might be a few minutes late to the meeting tonight, so if you arrive early (around 6pm) you might need to wait around a bit before I can let you in.

There is PA's pub directly across the road from VLSCI and a nice cafe called Animal Orchestra on Grattan Street near the intersection with Swanston Street.

I should be at the VLSCI building before 6.30 pm.

Cheers
Bernie.
> --
> You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
> To post to this group, send an email to scala...@googlegroups.com.
> To unsubscribe from this group, send email to scala-melb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/scala-melb?hl=en-GB.
>
>
>

Bernie Pope

unread,
May 28, 2012, 4:00:47 AM5/28/12
to scala...@googlegroups.com
Hi again,

It is 6pm and I am in the VLSCI office, so there is no need to wait around if you come early.

Just come in the building and ring the bell.

Cheers,
Bernie.

Eugene Burmako

unread,
May 28, 2012, 11:06:18 AM5/28/12
to Melbourne Scala User Group
Hey folks,

Great that you find macros useful! If you get any questions about
macro stuff, please, ask at scala-user/scala-internals, and I'll be
there to help asap.

One more thingie. It's flattering to be considered the father of Scala
macros, but it wouldn't be honest of me to accept this title. Sure
that was me who started pushing macros into Scala, but without
Martin's involvement and supervision (both in design and in coding)
macros simply wouldn't happen. I sincerely mean it.

Speaking of credits, I'd also like to say a huge thanks to our
reflection team: Chris, Stefan, Adriaan and Dominik. It's amazing how
many unsolvable problems have been solved during our reflection
meetings!

Oh yeah, how could I forget the early adopters?! Designing spherical
horses in vacuum is neat, but with that much feedback that we got,
making macros useful was a no-brainer.

Cheers,
Eugene
Reply all
Reply to author
Forward
0 new messages