Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

closed as not constructive by Robert Harvey, Glenn Nelson, Walter, Dynamic, Giorgio Jan 6 '13 at 1:11

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
2  
This comment doesn't address the heart of the question, but it is a factor to consider: Java-based web apps targeted at Windows users are something to stay away from. The Oracle JVM for Windows has had a lot security issues lately. As such, you may find that savvy users won't use Java-based web apps because they've uninstalled the JVM. –  poke Jan 5 '13 at 21:26
add comment

7 Answers

up vote 8 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
7  
Good answer. Of course, making sure your app works right in all the various browser versions can be a headache as well. –  Tim Goodman Nov 19 '10 at 15:51
5  
@Tim: good point. I believe browser apps are much more "test and debug everywhere" than Java desktop apps. –  Joonas Pulakka Nov 19 '10 at 18:28
5  
@Tim: +1. Getting a webapp app to work the same across all the major browsers is just as hard as getting a Java app to work the same across multiple OS's. –  Yevgeniy Brikman Nov 20 '10 at 7:57
2  
"write once, debug everywhere" is not true in my experience. as long as you are sensible and avoid platform-specific dependencies, I've had no issues running the same Java code on multiple platforms (including GUI ones). Yes of course you should test it, but I think in nearly 15 years of coding Java I only once had a real portability issue (which was my own fault for hard-coding Windows directory separators rather than using Java's helpfully cross-platform File.pathSeparator!) –  mikera Feb 14 '11 at 17:09
2  
@mikera - We've seen issues between Linux and Windows which were nothing to do with our code. They're rare but they do exist. –  Jon Hopkins Feb 14 '11 at 17:33
show 1 more comment

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

share|improve this answer
add comment

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.

share|improve this answer
    
You made an interesting error listing Skype in your examples, but this super-popular application actually was started with Delphi/Pascal on Windows and ported with C/C++ on linux and Objective-C on MacOS/iPhone –  Maksee Nov 19 '10 at 15:36
    
I think the compiled / interpreted dichotomy is a little misleading - Java is in some sense neither because it is compiled to machine-independent bytecode for distribution (i.e. no longer in source form), and then JIT compiled at a later time into native code on whatever machine you are running on. It's fully cross platform, but also gets you native performance, plus you don't have to distribute your source if you don't want to. win/win/win. –  mikera Feb 14 '11 at 17:03
add comment

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.
share|improve this answer
12  
Extremely fast? Compared to what? –  HardCode Nov 19 '10 at 22:22
13  
@HardCode: Compared to any interpreted language or most compiled languages. C and C++ can be made faster in some cases but it's hard, and keeps getting harder when number of cores grow. With Java concurrency (utilizing those multiple cores efficiently) is way easier to achieve in practice. –  Joonas Pulakka Nov 20 '10 at 6:56
4  
@HardCode, apparently the JVM is the fastest runtime available for almost any interpreted language (as opposed to the ones the language hackers made themselves) –  user1249 Jan 20 '11 at 12:45
add comment

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.

share|improve this answer
    
LLVM is not about running on a browser... Are you talking about emscripten? –  Camilo Martin 2 days ago
    
check the date. 4 years ago emscripten didn't exist. NativeClient was suppose to work (and had doom running) but it didn't. –  acidzombie24 2 days ago
    
Now I see the date, but still, LLVM was never specifically about browsers, right? –  Camilo Martin 2 days ago
    
Nope. Although I wish I could write C++ or some other language LLVM supports instead of JS... –  acidzombie24 2 days ago
    
add comment

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.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.