Experts for Domain Specific Languages?  DSL Help

Posted on 2011-04-27
Last Modified: 2012-08-14
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.

Question by:Jgreer2011
    LVL 26

    Expert Comment

    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.


    Author Comment

    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?
    LVL 26

    Accepted Solution

    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.


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now