File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Scala and the fly likes DSLs in Action: Is Scala a good choice to define DSLs? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Scala
Bookmark "DSLs in Action: Is Scala a good choice to define DSLs?" Watch "DSLs in Action: Is Scala a good choice to define DSLs?" New topic

DSLs in Action: Is Scala a good choice to define DSLs?

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 434
I see this book appears in the week of Scala. So I suppose this book is related with Scala, isn't it? What are the languages do you usually use to define DSLs? What's the advantage of Scala with other languages based on JVM?

To be or not to be. It's a question.
Josh Suereth

Joined: Jan 24, 2013
Posts: 15
I know lots of people coming to scala to define DSLs. There's even a research group using Scala as a host language for highly-parallel C++ backends -> Delite.

I've done quite a few DSLs in scala. I'm starting to think less of them as "DSLs" and more "Well written libraries". A good library should be as close to the domain (and the mindset of the person in the domain) as possible. Scala's flexible syntax makes this easier. However, sometimes people go overboard to make everything look like english. I personally feel there's a line between "Elegant library/DSL" and "Overboard on the syntactic sugar".

In any case, yes, Scala is a great langauge for DSLs. My first 20% projects at google was a Scala DSL around MapReduce/Flume that I was quite proud of: Scala Distributed Parallel Collections
Debasish Dg Ghosh

Joined: Jan 24, 2013
Posts: 4
I am the author of DSLs In Action. In real terms DSL should use an implementation language that best suits the modeling of the problem domain at hand. It can be embedded within a host language like Scala, Ruby, Groovy or Clojure or it can be an external DSL where you build your syntax ground up using parsers and scanners. The book discusses bot these approaches using a host of languages - Java, Ruby, Groovy, Clojure and Scala. The Scala sections are the most comprehensive ones where it discusses embedded as well as external DSL design using Scala. Regarding embedded DSL design in Scala it discusses how the syntax and the type system of Scala can make your DSL expressive as well as succinct. In external DSLs, it discusses how parser combinators make DSL design composable and functional. There are lots of examples in both the topics and many of them are quite non trivial and relates to a specific domain. But in addition to Scala I discuss lots of examples with other languages including a comprehensive chapter on parsers, scanners and ANTLR based DSL design.

Let me know if you need details on any of these specific topics.

I agree. Here's the link:
subject: DSLs in Action: Is Scala a good choice to define DSLs?
It's not a secret anymore!