tags:

views:

192

answers:

3

I would like to create a set of domain objects in multiple languages, so that I can target different platforms. I have been looking at external DSLs as a way to define a language for my domain, and then potentially writing adapters that generate code for the languages I'm interested in targeting. Is this the best way to solve this problem? Or is it just simpler to maintain multiple versions of the project?

A: 

It is difficult to be helpful without understanding what you are planning to use your DSL for.

Is portability your main problem here? To succesfully target these different platforms, you will probably have to maintain plaftorm-specific layers anyway (generated or not).

If you plan to write your whole application in your DSL, then use your own compiler to transform it into runnable code for each platform, well it is most probably a bad idea, too complex and overengineered.

However, if you have a well-defined chunk of platform-independent logic, then a DSL is a good choice. Just write an interpreter for it on each target platform (provided that performance is not critical, this is also simpler and easier than generating code).

Eldritch Conundrum
The thinking was to create the well defined chunk of platform-independent logic in a DSL and then use that to generate or somehow create versions in different languages. What do you mean by an interpreter? Yes, portability would be the main concern.
Shane Fulmer
+2  A: 

I think that Apache Thrift delivers what you are asking for.

StackedCrooked
A: 

What is the best way to create multiple language versions of a domain?

This is (was?) somehow the idea of Model Driven Architecture (MDA). Quoting Model-driven architecture from Wikipedia:

The Model-Driven Architecture approach defines system functionality using a platform-independent model (PIM) using an appropriate domain-specific language (DSL).

Then, given a platform definition model (PDM) corresponding to CORBA, .NET, the Web, etc., the PIM is translated to one or more platform-specific models (PSMs) that computers can run. This requires mappings and transformations and should be modeled too.

The PSM may use different Domain Specific Languages (DSLs), or a General Purpose Language (GPL) like Java, C#, PHP, Python, etc. Automated tools generally perform this translation.

Depending on the complexity of your domain and the availability of a MDA Tool, this might be an option (with a lower implementation cost).

See also

Pascal Thivent