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.

You are just starting a new project and you have these two technologies to choose from, Java and .NET. The project you are working doesn't involve having features that would make it easy to choose between the two technologies (e.g. .NET has this that I need and Java does not) and both of them should work just fine for you (though you only need one of course). Take into account:

  • Performance
  • Tools available (even 3rd party tools)
  • Cross platform compatibility
  • Libraries (especially 3rd party libraries)
  • Cost (Oracle seems to try and monetize Java)
  • Development process (Easiest/Fastest)

Also keep in mind that Linux is not your main platform but you would like to port your project to Linux/MacOs as well. You should definitely keep in mind the trouble that has been revolving around Oracle and the Java community and the limitations of Mono and Java as well. It would be much appreciated if people with experience in both can give an overview and their own subjective view about which they would choose and why.

share|improve this question

closed as not constructive by Mark Trapp Dec 16 '11 at 1:40

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.

    
There isn't enough information about the requirements to effectively answer this question. –  red-dirt Jan 16 '11 at 14:18
3  
Mono is a pain (e.g. time sink). Even a basic WinForm designer is not there. –  Job Jan 16 '11 at 15:54
    
@Job actually, MonoDevelop has a GUI designer for GTK#, since WinForms isn't open source yet. –  Mahmoud Hossam Mar 16 '11 at 12:08
    
Yes, but how is Mono with 3rd-party libraries? Do they "just work"? And (perhaps most importantly) do the vendors provide support if you use them with Mono? –  TMN Mar 16 '11 at 12:29
add comment

6 Answers

The single most important (edit: technical) decision is:

  • Will you at this point in time commit 100% to use Windows as your future deployment platform?

If no, then you should go with Java.


The conclusion from Mono is frequently used to say "Yes, .NET is cross-platform". How valid is that claim? was that Mono is only an option IFF you develop against it!

You cannot expect .NET-applications to work out of the box.


@Basic said that this was more a comment than an answer. To be precise I consider it a question to go on top of the list, because this is perhaps the most important technical decision you need to do when dealing with .NET. As Basic says he will test against Mono, then that is out of the way, and I would consider Java and .NET to be pretty equally well suited. I have very little experience with .NET, but quite a bit in Java.

  • Performance - Java runs pretty well, but still has quite a bit of startup time. This is because a JVM starts from scratch when being initialized, and the random access of the runtime library jar file is rather slow when needing to be read in from disk. Recent Java 6's have a background process to try to keep the runtime library jar files in the disk cache so access is fast when needed.

  • Tools available. Plenty of tools exist, and there is a lot available as high quality Open Source. IBM has some very advanced tooling available, but they also take quite a bit of money for them. You may want to have a look at MyEclipse who make a living from putting together the best parts in the Java world and make them accessible for a low cost, to see what is available. Netbeans has a very nice GUI editor. JDeveloper has a nice Swing debugger. The Sun 6 JDK has VisualVM which is a nice entry level profiler which can analyze already running programs (which is a killer feature).

  • Cross platform compatibility. Very good, tending to excellent. The JVM is very, very reliable and predictable. Issues only show when operating system differences seep in - like file separators, file name case sensitivity and menu behaviour.

  • Libraries. There are many and many of them are freely available and usable, but primarily written in Java as it is rather difficult to pull in code written in non-JVM languages.

  • Cost. Java is basically freely available. What Oracle is indicating is that the power tools - most likely coming from JRocket - will be at a cost. Also note that exended support ("Java for Business") also comes for a price. Non-x86 platforms are a dying breed, but IBM has plenty and IBM provides an excellent Java implementation for them. This is priced as being a part of the operating system - most likely for better adoption.

  • Development process. Much time with Java is spent researching and choosing the appropriate technology and learning it, but when that is done I think there are plenty of technologies which are quite fast to develop with. The latest version of Java EE provides for writing very powerful web pages using Facelets which can be reloaded at least as fast as PHP pages.

I think that unless you are not skilled in neither Java or .NET, you will save time and money by choosing the technology you and your organization are the most familiar with.

share|improve this answer
13  
Who guarantees that the Java program you write on Windows will run anywhere else? It only takes a single JNI call to break that guarantee. The same issue is with the CLI - if you use a non-cross plaform API, you lose portablity. Thus, the only person who can make the portability guarantee is yourself - the programmer, regardless of what framework you're using. –  Mark H Nov 20 '10 at 16:37
3  
@Thorbjørn, would you trust Oracle in current climate? –  radekg Nov 20 '10 at 16:39
11  
+1 because Thorbjørn said that if you're not 100% committed to Windows that you should go with Java, not that you must go with Java. And I agree - yes, Mono is there as a fallback, but if your current plans are not committed to Windows, save yourself the pain and go with the technology that was intended to run on other platforms. And I say this as a .NET developer and .NET enthusiast. –  Carson63000 Nov 20 '10 at 22:05
3  
I was wondering if there is any of the "mono-exists-on-other"-downvoters who have actually tried doing it... –  user1249 Aug 27 '11 at 11:39
4  
"Java is basically freely available (...) the power tools will be at a cost (...) exended support also comes for a price". Exactly the same for.NET, right? –  Konamiman Oct 4 '11 at 7:19
show 10 more comments

OK, lets try to break this down:

Take into account:

Performance Tools available (even 3rd party tools)

Both the Java and .NET platforms have plenty of good performance testing tools available, I know that in the Java space that there are plenty of free open source tools that are adequate for most scenarios. I can't speak for the .NET side.

Cross platform compatibility

Java has an advantage here - project Mono (or similar) is required to get .NET running on some platforms. I'm not sure with Mono is 100% bullet-proof and performant, something hopefully someone else can chime in on.

Libraries (especially 3rd party libraries)

Both have strong support here. Initially the Java eco-system lead the way (there's literally a a free open source library for just about anything you could think of) but I'd say that .NET has certainly caught up where it matters (NHiberante for persistence, NUnit for unit testing to name two basic ones + I'm sure there's a metric truckload more).

Cost (Oracle seems to try and monetize Java)

All companies try to monetize to some degree, but in the case of Java I think your statement is a little misleading. Java was open sourced as of version 6 (the OpenJDK project) and Oracle has shown no inclination to monetize Java beyond what Sun was doing. So yes they sell App servers and extensions to the JVM (management extensions in particular), but core Java itself? Nope and they never will (this has been publicly stated plenty of times).

I think both MS and Oracle benefit massively due to indirect revenue with their repsepctive platforms.

Total Cost of Ownership (TCO)? I'm not even going to get into this debate as there's no way to prove it (programming is a creative human activity after all). I personally think that Java based systems tend to have a lower initial cost as you can utilise a free open source stack from top to bottom in most cases. However, large enterprises tend to prefer having support contracts so that can nullify that particular benefit.

Development process (Easiest/Fastest)

Depends on what you're trying to build! I'd personally argue that they're pretty much even, although C# has some extra features in the core language over Java at the moment. However with (multiple inter-operable with Java) languages on the JVM (Groovy, Scala, Clojure etc) you can have all of the langauge features you want.

.NET had a distinct advantage for building web front end 'stuff' for awhile (Rapid Application Development if you will), but I think JEE6 and/or Spring and other web/app frameworks have pretty much closed that gap.

Also keep in mind that Linux is not your main platform but you would like to port your project to Linux/MacOs as well. You should definitely keep in mind the trouble that has been revolving around Oracle and the Java community and the limitations of Mono and Java as well. It would be much appreciated if people with experience in both can give an overview and their own subjective view about which they would choose and why.

If you want to port to Linux, UNIX and in particular Mac OS then as stated above Java has an edge there.

Hope that helps!

share|improve this answer
add comment

Taking into account your list of points, I'd be split and it would really depend on what I need to build.

.Net wins for these aspects:

  • Performance
  • Development process (Easiest/Fastest)

Java wins for these aspects:

  • Cross platform compatibility
  • Libraries (especially 3rd party libraries)

It's a draw for these aspects:

  • Cost (Oracle seems to try and monetize Java)
  • Tools available (even 3rd party tools)

.Net is, for all intents and purposes, a single platform technology stack. Yeah, there's Mono, but until Mono is 100% compatible with the Windows implementation it doesn't provide a true cross platform experience. The only subset you might be able to count on for cross platform support is what would fit in Silverlight.

That said, .Net has better perceived performance (actual measurements TBD). In the eyes of the user, perceived performance is the only thing that matters. After having developed in Java for the past 12+ years, and recently doing .Net, I can appreciate the power of the platform.

Java on the other hand has a much richer IDE set to choose from, and the cost of these superior IDEs are much less than the cost of the .Net variation. On the other hand, the cost of professional J2EE engines easily dwarfs the development environment costs. In .Net I have the perception of being nickle-and-dimed to death. In Java there are workarounds to the huge costs--which can easily be made up for with developer time setting them up. Outside of the IDE, for the tools that matter (profiler, coverage, etc.) the costs are equal.

In the end it really depends on the need. If I'm going to be deploying on Windows anyway, then .Net is a no brainer. I have clients that are Windows only shops. If I'm giong to be deploying on Unix or need to support hetergeneous systems, then Java is a no brainer. I may even be radical and suggest a mixed technology stack. After all, just because the client requires the server to be Unix doesn't mean they run that on their desktops. Not every application is best made into a web app.

share|improve this answer
add comment

Performance - Even

Both platforms perform extremely well for virtually all applications.

Not really much to set them apart, though my subjective experience is that Java has a slight edge for long running applications, whereas .Net is quicker for application startup time.

Tools available (even 3rd party tools) - Debatable

Depends on what tools you need and what you are familiar with.

.Net certainly has some great tools provided by Microsoft. On the other hand, there are equally good tools in the Java world e.g. in the Eclipse, Netbeans of IntelliJ environments.

Cross platform compatibility - Java win

.Net is fundamentally tied to Microsoft platforms (Windows, Xbox etc.). Complete implementations are not available for any non-Microsoft platforms.

Mono is nice, but it doesn't actually give you full cross-platform capability because it doesn't support all the .Net libraries (for example you can't expect all the Windows GUI stuff to work correctly, so unless you switch to a cross-platform toolkit such as GTK# you won't be able to run your app on different platforms)

Java is genuinely portable. Not just the language, but much more importantly all the Java libraries are portable. Providing you stick to pure Java libraries (e.g. Swing for GUI) then your code will run anywhere you have a Java runtime environment.

Libraries (especially 3rd party libraries) - Java win

Probably the best strength of the Java platform is the vast ecosystem of libraries, especially open source libraries. Some examples:

  • All of the Apache libraries and tools
  • All the libraries in the vast Eclipse ecosystem
  • All the libraries contributed / maintained by Google
  • JBoss and all the related enterprise tools maintained by Red Hat

Cost (Oracle seems to try and monetize Java) - Java win if you go open source, otherwise Even.

You can have a 100% open source Java stack which is free and doesn't tie you into any particular proprietary platform. This is 100% free.

Alternatively, you can buy IntelliJ IDEA, run Java on Windows and use a proprietary database, in which case it's pretty much the same cost-wise as a typical Microsoft .NET stack.

Development process (Easiest/Fastest) - Debatable

This probably depends more on the experience of your developers with each platform rather than the particular attributed of the platform.

.Net certainly has some great tools that can make you very productive for simple GUI apps on Windows. Not surprising as this is the "sweet spot" for .Net development.

On the other hand, I prefer the Java stack for server-side development. With tools like Maven and all the continuous deployment / integration capabilities you can establish a very effective development process for robust server-side apps.

Language-wise C# has some productivity advantages over Java. But on the other hand if you are developing on the Java platform nowadays the trend is not to use Java itself but instead use one of the new JVM languages such as Scala, Groovy or Clojure - if you do that then you will be far more productive than either C# or Java.

share|improve this answer
add comment

.Net

It's hard to answer this question without being subjective or flamebaiting (I have a feeling I'm going to be downvoted), but .Net is a language on the upswing and Java seems bogged down by legal issues as well as becoming less popular.

Also .net nowadays is by far a much more cohesive and modern language with excellent support for multicore (Parallel.net) and asynchrounous programming (reactive extensions),not to mention LINQ which I couldn't live without. .Net also has a number of free tools, but Visual Studio Express, Sql Server Express, Web Matrix etc.

It's true that java does hold some multiplatform benefits. You have some options for .Net with mono etc which might do for tradional applications or backend components but some get's iffy if you're doing something very specialized (and let's not evend discuss WPF).

Another option if crossplatform is really really important is go Silverlight, I'm personally not that keen on silverlight "applications" but atleast it works.

Crossplatform is the pain point, ask yourself if it's really really necessary, at least at this point.

share|improve this answer
    
Preferring .Net isn't a bad thing. I actually quite like it. It's no doubt that Java is facing an identity crisis at the moment, which is a shame--I also like that platform. I'm glad you acknowledged Java's improved track record for cross-platform (+1). Some clients require Unix deployment, others require Windows deployment. Java folks can service both platforms, while .Net really is limited to Windows. That said, there's a lot of Windows only clients out there. –  Berin Loritsch Jan 20 '11 at 13:31
add comment

In our organisation, at this point in time, we'd choose Java. The reason for that is simple: our Java team is larger, more experienced, and better tooled than is our .NET team (who also are tied up enough in maintenance of existing systems that they lack the resources to take on any major new projects).
That said, if there were pressing reasons to use .NET (e.g. client requirements, some customers may have a large installed base of .NET software and want their new system to fit into that base, take over maintenance themselves, etc.) we will do so and hire contractors to do the work where we can't free our own people.
I would not force either technology on a customer against their best interests, and some customers simply benefit (because of their internal organisation) more from one than the other because of investments needed to deploy the system (again, say we have a customer who already has a number of .NET applications running and has the staff to support those, we're not going to try and force them to hire people and buy hardware and software licenses to run a Java application on the side, and of course the reverse would also be true. We'd in fact advise them not to do so if they came to us with that as a request).

share|improve this answer
add comment