This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Josh Suereth
Author
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Author
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic