Java really delivers “write once, run anywhere”
Java's slogan was "write once, run anywhere". They received a certain amount of criticism but I have to say that compared to other programming languages it's really true. You can use it for:
- Background jobs (without user-interface)
- Server-side web applications (many web servers & web frameworks available)
- In the web browser (applets)
- On the desktop (using platform-independent Swing, or with native Apple UI using Cocoa)
- On some mobile phones (J2ME, Google Android) – although I haven't tested how good that really works?
Writing the previous version of a certain application website in Perl, there was no easy way to give the customer a "tool" to test out new versions of the configuration file. These files would normally be installed on the server, were multiple megabytes in size, and the Perl would parse and use them. For testing, it was not ideal to have to upload potential new files to the test server, due to their size.
The new version is in Java and also takes a configuration file, but I have written a Swing (desktop) tool which simply allows the tester to select a new potential configuration file from their local hard disk, and the desktop tool reuses all the processing logic 1:1 that the web server in production would use.
That wouldn't have been possible with the old version of the logic written in Perl. (I know there are windowing libraries for languages like Perl but they are hardly as easy to deploy – i.e. install on a Windows workstation – as a Java application – simply double-click the .jar file once Java is installed)
I am writing the web front-end for the new version in GWT so I can reuse certain (mainly user validation) code between the web browser (giving the user instant feedback in case of errors) and the web server (necessary for security in case someone bypasses the client and sends HTTP requests directly.) And simply pass Java objects between the web server and the web client, without having to worry about how that transfer works (JSON, XML, etc.)
Other mainstream candidates for languages which run on multiple places:
- Objective-C is not too bad, running on Apple desktops, Apple iPhones, and on the web server via WebObjects (does the current version of WO still use Objective-C or is it Java-only these days?) – but not in the browser
- Perhaps C#? Certainly good desktop, web server integration, no doubt IE/Windows integration via ActiveX