Another question over on SO introduced me to Oxygene, formerly Chrome before the browser of the same name came to prominence. It’s in the Pascal syntax family, but brings in a lot of object-oriented grammar and elements from the C family, notably Java/C#. One of its big advertised strengths is that the language is implemented as runtime-independent; programs written in Oxygene can target .NET, J2EE, Android, or Cocoa, making it a memory-managed language almost as portable as C/C++ is in unmanaged-land.
However, my question is whether that kind of independence is really useful, given that the frameworks and environments it targets are so different (and incompatible). There are a host of problems inherent in writing one program that can be compiled as-is to target all three of these runtimes, and a common language is only the tip of the iceberg. Java doesn’t have a System.Windows.Forms namespace; it has java.swing, and the classes underneath are totally different. Similarly, Java’s database interop is via JDBC, while .NET has the ADO.NET sub-framework. While having a common language is nice, being fluent in a “language” is as much (more, IMO) about being fluent in the targeted libraries as it is with the syntax of the language.
Does anyone have a common example of where runtime-independent languages have been leveraged to create truly portable programs across all supported runtimes?
6
I’m not familiar with Oxygene but from time I spent looking into Fantom and similar other languages that do what you’re referring to, what I found was that they weren’t as you’re suggesting requiring you to know the different libraries.
The killer functionality they have is a single library that translates to the independent separate ones; so you write code against the Fantom library using their UI functions, and it will translate it to Swing or WinForms depending on whether you compile it to .NET or Java. In this way you don’t need to know anything about either the .NET or Java libraries, you know one library and it will handle the translation for you on those standard things like DB access, GUI, networking, et al.
4
You’re assuming the language is designed to be able to compile the exact same program as-is for different platforms. That doesn’t appear to be the case. It’s portable in the same way as C and C++ are portable. Your core language is the same on all platforms, but you target the native runtime environments. In other words, the language is cross platform, not the application.
Even for cross platform applications, maintaining different sets of platform-specific code is fairly common. Even if you can’t reuse the platform-specific code, using the same language allows a lot of code reuse, if you structure your application properly.
For example, I maintain a program for both Java/Swing and Java/Android, for which 75% of the code is reused between platforms, even though both apps are completely native. That’s not as nice as 100%, but it sure beats the 0% of common code I would get if I ported to Objective C/iOS.