Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM/CLR Source-compatible Language Options

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?

like image 205
Nathan Voxland Avatar asked May 01 '09 17:05

Nathan Voxland


People also ask

What is CLR and JVM?

The Common Language Runtime (CLR) and Java Virtual Machine (JVM) are both process virtual machines. That means that rather than executing an entire operating system, they are specifically designed to run a process or program without being dependent on the platform environment.

What is the equivalent to the CLR in Java?

NET framework's Common Language Runtime (CLR) is much similar to Java Virtual Machine (JVM), in terms of garbage collection, security, just in time compilation (JIT).

Can C# run on JVM?

You can use a source-to-source compiler to translate C# into a language than runs on the JVM. For example, there are several C# to Java converters that would allow C# applications to run on the JVM after being translated into Java.

Is CLR better than JVM?

The Common Language Runtime (CLR) offers important functionalities like memory management, thread management, garbage collection and exception handling. Although Common Language Runtime (CLR) and JVM are similar in many respects, most developers reckon CLR is the hands-down winner.


1 Answers

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.

like image 132
Corbin March Avatar answered Sep 19 '22 20:09

Corbin March