[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 450
  • Last Modified:

Experts for Domain Specific Languages? DSL Help

I need help in developing a simple domain specific language using java. I have a state model and DSL sample code. The problem is it is in the GRoovy language, I need to convert it to the Scala or Java language.

Any ideas??
Here is the URL for the sample code to convert to Java..
Help Please..
Paste to browser.

http://code.google.com/p/dsl-book-sample/source/browse/trunk/dsl-book-sample/?r=4#dsl-book-sample%2Fsrc%2Fjp%2Fne%2Fhatena%2Fd%2Fdigitalsoul%2Fmissgrant

0
Jgreer2011
Asked:
Jgreer2011
  • 2
  • 2
1 Solution
 
dpearsonCommented:
I think you need to be a bit clearer about what your goals are here.

Java doesn't really directly support building DSLs in the normal sense of a DSL - where you're writing code using a new language built up from Java primitives.  In Java if you want your DSL to allow "Do X" you need to write it as "Do(X)" which doesn't look very like a DSL.  Instead, you'd need to first build a scripting language within Java and then implement the DSL in that scripting language.  This will let you write "Do X" in the scripting language.  Indeed you could do exactly that by using Groovy as the scripting language and running the sample code that you have within Groovy, within any Java application.  This is possible since Groovy already runs on the same JVM as Java.

If you're thinking of Scala then that's a much better fit for building a DSL since it allows for the sort of redefining of method names, types and flexible syntax that lets you write "Do X" in Scala and process this as a method call Do(X).  But that's an entirely different problem than building the same solution in Java.

Doug
0
 
Jgreer2011Author Commented:
Ok, so Scala is the best fit. But when testing a DSL using assert or assertEqual is there any return value (Success, Failure) or just a void? How can you test it works?
0
 
dpearsonCommented:
If you're writing tests with assert() and assertEqual(), they'll throw an exception if the test fails, so they don't need a return value.

Doug
0
 
Jgreer2011Author Commented:
Thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now