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.

If I were to begin writing an application using Java with the intention of porting it to other platforms with little or no modification, would it be wise to consider using the .Net framework instead?

I have no specific targets in mind with respect to platform. At a minimum, Windows/Mac/Linux support would be nice. Also ease-of-use for the end-user is a consideration.

share|improve this question

closed as too broad by gnat, Bart van Ingen Schenau, GlenH7, Kilian Foth, MichaelT Oct 27 at 18:25

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

    
@InSane: I haven't begun it yet. –  Nathan Osman Dec 27 '10 at 5:15
    
@InSane: Yes. That's it exactly. –  Nathan Osman Dec 27 '10 at 5:59
3  
I would prefer Java over .net (if they are the only choice). –  kadaj Dec 27 '10 at 8:16
    
@jase21: Can you please explain why? –  Nathan Osman Dec 27 '10 at 8:22
    
Mono is playing catchup with the official release versions of .net. JVM is more mature, stable, and faster. It has more language supports which can be cross-compiled to the JVM. For me learning a language means learning it deep. From the VM to the language. In that case Java is better and broader. Also I don't want to be enslaved (I know there is Mono). I don't know what Oracle will do with Java. Though in my opinion, go for Python or Ruby. Qt's cross platform nature is really awesome. –  kadaj Dec 27 '10 at 12:27

8 Answers 8

I wouldn't go with .Net. Mono is not bad, but if you use some obscure corner of C# or the .Net library that Mono does not support, then you're screwed. This is way less likely to happen in Java because Sun stands behind full runtime implementations of Java for Windows, Mac and Linux.

share|improve this answer
1  
There are many more java implementations than sun's (and that's oracle these days...) –  Nils Dec 27 '10 at 9:12
    
Also there seemed to be a problem with Mono's garbage collector: flyingfrogblog.blogspot.com/2010/09/… –  LennyProgrammers Dec 27 '10 at 9:35
1  
Sun was acquired by Oracle. –  Nathan Osman Feb 6 '11 at 21:54

For cross-platform compatibility .net is not the answer... and don't give me any "but mono..." nonsense. Mono's just isn't up-to-date w/ current framework class libs.

share|improve this answer
    
I agree that Mono is somewhat lacking in core functionality, but it isn't too bad. I had the chance to try it out a bit. –  Nathan Osman Jan 23 '11 at 20:23

I think, if you care about native look-and-feel in Mac environment, you may go for mono with keeping the UI and the core loosely coupled. Because in mono you can achieve more native look-and-feel for different platforms using different mono based UI APIs like Cocoa#. But you have to spend more time.

May be Java also supports the APIs for different platforms. But the practice is not common I guess.

Another point is, if using C# makes you more productive, go for mono.

share|improve this answer
1  
I think Java support for native APIs would be eclipse.org/swt –  LennyProgrammers Dec 27 '10 at 9:34
    
In Java, you can use AWT for native APIs, or at least whichever bits of the application you want native components for. You can then use Swing for the rest of the app where you want control/consistency/your own custom prettiness. –  mikera Feb 14 '11 at 16:46

In Microsoft's words, the .Net Framework consists of the following parts:

* Common Language Runtime or CLR, which provides an abstraction layer over the operating system

* Base Class Libraries, which are pre-built code for common low-level programming tasks

* Development frameworks and technologies, which are reusable, customizable solutions for larger programming tasks

Mono is a software platform designed to allow developers to easily create cross platform applications. Sponsored by Novell (http://www.novell.com/), Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime.

It provides decent support for the CLR but it is lacking the breadth of "Base Class Libraries" and "Development frameworks & technologies". That is especially true if one considers the enormous ecosystem of Java. The latter has achieved a level of maturity and is supported by a plethora of publications (Wikis, User Guides, Books, Articles, etc.). Lastly, there has been a number of new languages (e.g. Groovy, Scala) and frameworks (e.g. Grails, Spring Roo, GWT) that can make your team enormously productive in a wide area of functional domains.

The only caveat would be, of course, if you must integrate Microsoft products (e.g. Microsoft Office) in your application (whether within the browser or a stand-alone app). In that case the .NET approach would give you a significant advantage but it would not be easy to carry over these advantages to other platforms (e.g. Linux).

The Java ecosystem is enormous and contains high-quality libraries for pretty much anything that you can think of. In fact, before you start writing your app., you should conduct a search across the Open Source projects that have been written in Java. It is very likely that what you are trying to build is very similar to something that already exists. So, depending on the license (look for LGPL, BSD, MIT, etc.), you might find something to get you started before you even break a sweat.

In summary, if your primary goal is to achieve multi-platform support then Java is your best bet.

share|improve this answer

Definitely go with Java over .NET if cross-platform is your main concern.

.NET basically locks you into the Microsoft technology stack. Mono is nice and all that, but it isn't comprehensive or up to date with all the .NET libraries (and probably never will be given they are chasing a moving target and Microsoft has no real incentive to help them...)

On the other hand, I wrote a reasonably complex (including Swing GUI) app in Java and successfully ran it first time on both a Mac and Linux, with no need for even a recompile. In that respect, Java is about as cross-platform as you can hope for. There are a few areas where you have to be careful (e.g. using JNI to access native libraries) but if you stick to standard, pure Java then portability is pretty much perfect.

Also see this post I made about Java as a platform choice.

share|improve this answer

Obviously Java does have some multiplaftorm capabilities, where .Net/Mono is risible. You can say C is portable too, and you'd be roughly as right.

If it's desktop applications, I'd just do it in Qt. By far the best GUI framework out there, and really multiplaftorm.

For non-desktop, a good scripting language is usually the way to go.

share|improve this answer
    
I am using Qt currently (see my profile). But really, this boils down to .Net vs. Java. I obviously can't use Qt on a mobile platform (well, except for Symbian). –  Nathan Osman Dec 27 '10 at 19:58
    
well, in the question you said Win/Mac/Lin. BTW, is there any mobile platform where you can choose .Net or Java? (monotouch doesn't count) –  Javier Dec 27 '10 at 21:20
    
I can use Java ME. –  Nathan Osman Dec 28 '10 at 16:28

I'd say go with what you like. If you - while coding - keep in mind that the app has to run on different systems and test early and often I bet you're going to be o.k.

I haven't written any java in a long time „in the early days” porting wasn't always fun either. (i.e. 3D graphics come to mind...)

If you choose mono/.net you either need use windows.forms and do all your forms in windows (there is currently no windows.forms ui-editor in linux) or you could use gtk and have your windows-users install gtk first.

I personally have (in 2 projects now) doubled the ui. Wpf for Windows, gtk for the rest...

share|improve this answer
    
"I'd say go with what you like." - How will I know that if I've never used either of them? –  Nathan Osman Dec 27 '10 at 19:57
    
Sorry - I did't know. My point was they both have some problems (and loads of strengths...) so if you keep the goal portability in mind (i.e. use Path.Combine() instead of adding / or \ ) it will work out –  Nils Dec 28 '10 at 15:22

Just Create a web application and be done with it.

Having developed both desktop applications and web applications.

I have come to the conclusion that the majority of desktop application work just as well as web application. With the rise of RIA technologies such as Silverlight, the gap has narrowed even further.

Please note, I'm not advocating all desktop applications here, in some cases a full FAT client will be needed.

share|improve this answer
    
Silverlight is really iffy on Mac and Linux, and more so on mobile applications. To run on an iDevice, you need a native app or Javascript, and that's a lot of the mobile market. I haven't heard of Silverlight running on Android either. –  David Thornley Dec 30 '10 at 17:34
    
ok that's fine, but Silver-light is not the only RIA tech. –  Darknight Dec 31 '10 at 0:48

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