views:

338

answers:

3

I have an open source Java database migration tool (http://www.liquibase.org) which I am considering porting to .Net.

The majority of the tool (at least from a complexity side) is around logic like "if you are adding a primary key and the database is Oracle use this SQL. If database is MySQL use this SQL. If the primary key is named and the database is Postgres use this SQL".

I could fork the Java codebase and covert it (manually and/or automatically), but as updates and bug fixes to the above logic come in I do not want to have to apply it to both versions. What I would like to do is move all that logic into a form that can be compiled and used by both Java and .Net versions naively.

The code I am looking to convert does not contain any advanced library usage (JDBC, System.out, etc) that would vary significantly from Java to .Net, so I don't think that will be an issue (at worst it can be designed around).

So what I am looking for is:

  • A language in which I can code common parts of my app in and compile it into classes usable by the "standard" languages on the target platform
  • Does not add any runtime requirements to the system
  • Nothing so strange that it scares away potential contributors

I know Python and Ruby both have implementations on for the JVM and CLR. How well do they fit my requirements? Has anyone been successful (or unsuccesful) using this technique for cross-platform applications? Are there any gotcha's I need to worry about?

+3  A: 

Check out the Fantom programming language. It has its own Java-like/C#-like syntax but can target either the Java VM or .NET CLR.

Their "Why Fantom" page gives a high-level overview of their approach to portability versus dynamic languages running on a VM.

Corbin March
I think Fan does seem to be the best option. Jython on Java looks like it hasn't been worked on for a while, while IronRuby on CLR is just at version 0.3. I'll have to learn more Fan to know if this is what I would really want to to do or if it is easier to just do the fork.
Nathan Voxland
The latest release of Jython was in November, and it seems quite active, although I agree that Fantom is a better fit in this case.
Yishai
+1  A: 

You might have some luck using IKVM.NET. I'm not sure on its exact status, but it's worth a try if you're insistent on running Java code on the .NET Framework. It includes a .NET implementation of the Java base class library, so it seems reasonably complete.

The only other option I might suggest is porting the code to the J# language, a full .NET language (although not first class in the sense that C# or VB.NET is). The language was designed so that the differences with Java were minimal.

Noldorin
I did think of both those options, but my concern with IKVM was adding a dependency, and my concern with J# was being mocked by .net developers...
Nathan Voxland
@Nathan: Quite understandable... though I don't think you're going to find an "ideal" solution in the way you want it within the mainstream technologies. Most projects maintainers will port the entire code base to another language (with the help of others perhaps) and make any changes/fixes to the code parallel across all ports. I personally think you're going to run into more problems than it's worth in attempting to use the same code base for the JVM/CLR versions - maintaining a separate port is more effort, but worth it in my mind.
Noldorin
A: 

If you are thinking about an emdedded approach, you might look at Lua.