21

When I started using Java in the nineties, it was all "Write once, run anywhere!" from day one. That was probably all true then and I was a part of the choir as well.

I am not sure what to think about that anymore, considering all the other languages using multi platform runtimes (python, flash, perl, html, php...). But I am still seeing lots of arguments that says you should use Java because it is supposedly better for cross platform development.

So, Is that still true today? Is Java still the language of choice for multi platform development?

  • Please be specific with focus on cross platform aspects.
  • I am not asking for general language feature comparisons.

Update: Great responses so far! Most answers seems to be favoring Java or web. Any input from the script crowd?

7 Answers7

18

While Java may not be the or the only viable cross-platform tool, it has some strengths:

  • It's extremely fast.
  • It's extremely robust.
  • It's extremely portable (e.g. bytecode compiled 10 years ago in Windows 95 runs fine in OS X today).

and some weaknesses:

  • Core GUI libraries (Swing...) are showing their age (3rd party additions help here).
  • The language itself could be less verbose (e.g. checked exceptions...).
  • Startup time could be snappier (although it's improving all the time).

When talking specifically about Java the platform, there's one point more:

  • There are quite a few languages that run on the JVM and interoperate with Java.
15

It's as true today as it was back then - that is to say not entirely. Java is write once, test and debug everywhere. Sure that's a lot less work than a completely fresh port but it's generally more work than the initial hype had us believe.

Our product has a Java server which will run on either Windows or Linux but we have seen OS specific issues with it and make sure we have both Linux and Windows servers available for support / testing if needed. Java UIs tend to have more issues than the servers (though many are cosmetic and therefore potentially can be ignored depending on the application).

While not strictly a language for me the web is the cross platform platform of choice. An HTML / JavaScript front end means that your application will run on pretty much any client platform and in most instances that was the real goal - not having to worry whether it was a Mac or a PC, which OS version and so on.

Of course you'll generally still be dictating the server platform but when it's just that people become a lot more flexible, particularly these days when most companies already support a mix of Windows and Linux servers.

Jon Hopkins
  • 22,774
10

scripting style languages such as python also make cross platform development easier. Now, whether you like Python (or other such languages) depends on you, and we probably don't need to start that debate here.

Java tries to force you to write code which will run portably, while python allows you to write portable code. The actual python language itself will run portably, but external libraries may or may not. Additionally, python will freely give access to platform specific services.

Does Java an advantage there? I think in either case you can write the portable code with similar ease. That is, you can write code and it will usually work on different platforms. But you cannot get away with just writing code and assuming it will work everywhere. I've worked on a python project which produced version for Windows, Linux, and Mac and we ran into very few cross platform issues. (The only one I remember was due to a bug in the library we were using pygame, which caused drawing issues on Linux. This was fixed by upgrading the version of pygame we used)

Another issue is deployment. If you want to distribute standalone programs that run your code you will have to produce different versions for different platforms. For Java you can distribute one version and assume that the user has Java installed or can install it. In this case Java probably wins in the simplicity of deployment department.

In the end, I think it comes down to what language you like working with and what kind of deployment you need to perform.

Winston Ewert
  • 25,052
9

Personally, I'd say that Java is still the cross platform language of choice, and likely to remain there for some time (alongside web applications). I wrote some more on the topic in this post on Java as a platform of choice, but on the cross platform front in particular:

  • As long as your are careful with your dependencies (e.g. avoiding libraries that use JNI to interface with native code) then Java can be written run unmodified on all the major JVM platforms

  • Beacuse Java is usually distributed as machine-independent bytecode, you can run without recompilation on any JVM (since the local JVM itself handles JIT-compilation to native code). For example, I've succeeded in getting a reasonable complex GUI app to run first time on a Mac after developing in Windows - with the same jar file. Contrast that to most other cross-platform languages, which typically require different libraries or a recompile for a different platform.

  • A lot of the core libraries you need (GUI, networking, IO etc.) are part of the standard runtime and written in a cross-platform way. So you don't need to go hunting for and testing cross-platform libraries, you are guaranteed that pretty much everything you need is already there in the runtime environment.

mikera
  • 20,777
3

I think you have those choices:

1) use either a

  • compiled or
  • interpreted language.

2) How will you package and deliver your code?

  • One "front-end", one binary/script?
  • One "front-end", multiple binaries/scripts?
  • Multiple "front-ends", multiple binaries/scripts?

Those choices affect performance, soure code visibility and distribution.

Do you mind giving away your source code? Compiled languages might be for you. Compiled languages seem to perform better in micro-benchmarks than interpreted (even JITed) languages. Also if you depend on a runtime environment like Java, Python, Ruby etc your code might be harder to distribute.

I found that most popular cross-platform desktop applications go for "One front-end, multiple binaries" using C/C++ and a crosss-platform widget library, e.g.Audacity, Blender, Firefox, Google Earth, OpenOffice, Skype, Songbird, Stellarium, VLC.

0

I'll say no. python and ruby are used a lot and so is javascript for both client and server side. I personally use .NET and have no problems getting it to run on mac and linux (while developing on windows)

-edit- i hear LLVM is becoming popular but is still extremely small. That will allow you to use cross platform C++ in a single binary. Apparently it will be executed on browser but i havent seen an example where it allows you to modify the dom or call javascript.

-1

If you bring mobile platforms into the mix then you'd also at least need to include recompile. E.g. android, j2me.

Conor
  • 1,972