But before I do I thought I’d ask everyone out there (who are interested in such a book), what would you like to see in it?
One possibility I’ve been tossing around is to turn it into a techniques or cookbook-style book. I’ve been reading through “Designing Interfaces” by Jennifer Tidwell. In this book she organizes the interface solutions into different sections and goes through each one with an example and what it solves and when to use it. I really like this idea (but others might not). Originally my book was a “How do I get started designing DSLs?” and “What in the world are they and why should I care?”.
Another thing I’ve been thinking about is ditching the Java part and making it Groovy only. This appeals to me because I feel that Groovy is much cleaner to implement an Internal DSL than Java is. Can you do DSLs in Java? Of course you can, but I’m not sure that I can give it the best treatment because it isn’t what I’m passionate about.
So, sound off in the comments, let me know what topics you’d like to see covered, what challenges have you faced in writing a DSL (or API/Framework) that you would have liked someone to trailblaze for you to show the dead-ends first?
Related Posts:
Naturally, I think it’s a good idea; DSL’s really are starting to get on a wider radar for people, though I think there’s still a lack of clarity about them. And in the DSL materials I’ve seen, there’s typically a dearth of good examples. The questions of why to use certain DSL techniques, the advantages and disadvantages of, say, metaprogramming over higher order functions, doesn’t really get covered. In short, I think there’s a market.
As for dumping Java…again, I agree. Just yesterday, I was writing something in Ruby for my 99%-Java job and had to remember “Hey! I don’t have to write a complicated method call here; I can just send in a closure.” Which is to say, the techniques which Python, Ruby, and yes, even Groovy make so easy and clear are simply out of mind when typically writing Java. Java just isn’t expressive enough to cleanly support a wide array of DSL techniques, and there’s really no point in attempting to ignore it for the sake of a larger market. Good examples are much more important than language choice in that regard.
In short, I definitely think the book is worth a second look.
Mainly the areas I’ve always wanted to be able to use DSL are in configuration where I have to deal with lots of XML.
DSLs to replace some of the following:
Spring / Camel / xBean / Hibernate
a cookbook style where I can pick up examples and use them would be very helpful to me.
First off, don’t bother with DSLs in Java. That’s pretty much a dead-end. If I’m gonna write a DSL, it’s going to be in Groovy. Second, please continue writing. There’s very little info out there about how to formulate a DSL. I would love to see a book walk through an example of an actual business problem and walk me through how to build out a DSL that addresses the problem while working with rich domain objects. Nobody talks about this shit (not even Neal Ford) and until somebody figures it out, DSLs won’t really go anywhere (or they will be horribly designed). This technology is in it’s infancy so there’s a huge opening here for someone to come in, figure it out, and kick some ass.
@Sam
What kind of business problems would you like to see covered? I ask as there are alot that could be covered, but not everyone would be interested.
@James and @Richard
What I was thinking is that this would be not necessarily cookbook style but one that would show different types of DSL techniques and where their application makes sense given a specific problem. Not sure if this fits in with what Sam was thinking about. Each technique would probably be given a good 4-5 pages to go over and might look something like this:
- Technique
- Problems it addresses
- Example of implementing the technique in Groovy for a specific problem
- Related techniques
Each technique would then be grouped into an overall category for easy relating. What those groups are I’m not sure yet. What I may do is start this out as a Wiki so that everyone can see what I’m thinking and comment on it.
It will be nice to have some book about DSL in Groovy. I think it should compare Groovy solutions with “real” DSL in Java (I mean JavaCC or ANTLR).
For me personally it will be good to read about some DSL solution which could replace XML. Currently I’m using a lot of XML binding. In this solution I can have full cycle of using some external files: it can be created by human (developer), loaded into application and changed into Java Beans, changed by application by user (in GUI or in other way), saved to disc again as XML, etc.
I never come to any DSL solution which will be similar. It looks like it is only half way when creation, and parsing is considered, but not serialization.
By the way you are aware about this coming book: http://www.martinfowler.com/dslwip/
@Arek
Yep, very aware of the Martin Fowler book, but he doesn’t cover Groovy at all.