36

If you have a number of years experience in working with Java and a number of years experience in working with C# and .NET, I would value your opinion on software development productivity differences between these two environments. One of our customers is considering replacing their existing software solution. As the replacement will require approx. 10 - 15 man years work, a choice for Java or .NET, based on productivity differences between the them, may significantly influence the investment required and time-to-market.

Would you be able to provide us, an indication of software development productivity differences between Java and C#/.NET? I would prefer to receive an answer as follows:

My experience is based on X years experience working with Java and X years experience working with C#/.NET. Java is X% more productive then C#.NET or C#/.NET is X% more productive than Java if you take the the following into account.

16
  • 24
    I guess one important thing here also is what you are making. .NET might be better for some type of projects, and Java for others. Feb 25, 2011 at 12:50
  • 4
    What kind of project is it? A lot depends on the libraries available for what you're trying to do. Language wise I strongly prefer C#, but I'm not claiming that .net is better than java for all kinds of projects. Feb 25, 2011 at 12:52
  • 7
    IMO there is a very important strategic decision and shouldn't be based on programmer productivity at all. If you want a perfectly nice state-of-the-art Windows GUI, you can't choose Java even if statistics claimed it was 7% more productive. If you need a true cross-plattform product without the restrictions Mono comes with, Java is your baby, even if C# has the nicer syntax.
    – user281377
    Feb 25, 2011 at 13:34
  • 2
    @Edin: "Enterprise application" is not very descriptive of what type of application it is... Is it Desktop only, client/server configuration, web services, web sites, possible satellite applications on mobile devices etc..?
    – awe
    Feb 25, 2011 at 14:00
  • 3
    It's "Java" not "JAVA" Feb 25, 2011 at 15:40

11 Answers 11

19

My experience is based on 10 years experience working with Java and 3 years experience working with C#/.NET. Java is 0% more productive than C#.NET. This is based on writing back-end service-based applications.
C#/.NET is maybe 5% more productive than Java for writing user applications. But then I've not done this for a almost 5 years in Java and the new Netbeans UI editor could have closed the gap.

You want to increase productivity? CI (ideally Continuous Delivery) and automated tests. The productivity gained by language/platform/IDE choice on any major language/platform/IDE is fairly small.

4
  • Did you mean to say 0% for Java? Do you mean 0% more productive for back-end service-based applications, or Java overall? Just checking. Feb 25, 2011 at 17:45
  • If you were to ask me to write a back end application (some rules, db access and what have thee) then the estimate would be identical for both C# and Java. If you asked for a windows end user application I'd make my estimate slightly larger for Java than C# (WPF/XAML and its support MVVM via binding I think is slightly more productive than the more manual binding and UI building in Java (as off 5 years ago)).
    – mlk
    Feb 26, 2011 at 15:08
  • +1 for "The productivity gained by language/platform/IDE choice on any major language/platform/IDE is fairly small." Dec 6, 2011 at 17:55
  • 3
    -1 for the last sentence. For every (real world) problem class, you can choose two general purpose high level languages, where the increase in productivity from one to the other surpasses 100%. If you choose between C# and Java, you will find little difference (although I would argue that C# will prove significantly more productive in areas suitable for functional programming). If the choice is between C and OCaml, the difference gapes at you.
    – back2dos
    Jan 9, 2012 at 10:20
43

I've worked on projects both in college and in the Real World™ using Java and C# for 5 years now.

Hands down I enjoy using C# more because of it's succinctness and use of syntax sugar. You will rarely find a Factory.GetFactory(OfFactory.GetFactory(Factory)); code in C#. It's easier to read and follow along because the syntax is smaller and more succinct.

Which one will you be more productive with? That depends on the type of project.

Are you designing a desktop application for Windows? Then C# is the best choice because of it's powerful IDE Visual Studio and the .NET Framework makes creating GUI's very simple.

Frankly, I'm glad I don't use Java anymore (it's been over a year now) because I remember how horribly verbose the code had to be. A quick example is exception handling. If your code can throw an exception you must account for every single exception possible. This quickly turns trivial code into a 20 line+ monstrosity.

C# isn't as hand holding, if you choose to leave your code open that's on you as a developer to decide.

C# also has made a lot of additions over the year that make it a joy to use. Lambdas, delegates, anonymous function (a la Ruby), lots of good little things you'll find as you go along.

6
  • 3
    I remember that in Java from uni, a point Im glad to forget. Forced exception handling. yes it had a purpose, but code documentation can tell you if methods throw exceptions and it gives you a choice of what to do.
    – JonWillis
    Feb 25, 2011 at 15:18
  • 5
    haha, i'm a java programmer but i liked your example code. Mar 23, 2011 at 8:38
  • 7
    If your code can throw an exception you must account for every single exception possible. I don't see the downside of this, at least this raises awareness of problems...though, might just be me.
    – Bobby
    Mar 31, 2011 at 8:46
  • 4
    The checked exceptions mean you write error handling code as part of the main implementation, instead as bolting it on as an afterthought. This mean quite a lot maintenancewise.
    – user1249
    Aug 27, 2011 at 7:39
  • I think it's just a disagreement on what exceptions mean--they can be expected circumstances (file does not exist) or unexpected errors (divide by 0). Java decided that exceptions should represent both and so has both checked and unchecked exceptions. This is a surprisingly controversial feature. Jan 9, 2012 at 9:19
29

I've worked extensively with both Java (since 1996) and .Net (since 2002) and in 2010 made a decision to go with Java in my company on the basis that it would be the most productive environment overall.

Note that I define software development productivity in terms of business value created per unit of cost/resource, on an end-to-end basis (i.e. you have to look at the productivity of the whole software lifecycle including deployment and maintenance, not just the initial coding!!).

Here are the key elements of my reasoning:

  • Syntax is a minor factor in productivity - while Java is certainly verbose and I prefer the syntax of C#, it simply doesn't matter much. Whether your developers type object.getSomeProperty() vs. object.SomeProperty or use an anonymous inner class vs. a lambda is simply not going to make any appreciable difference to your company's competitive advantage....
  • Library ecosystem is critical - developing a modern software product, you don't want to be developing lots of common components from scratch. The Java ecosystem has a clear advantage in terms of the number and quality of open source libraries (especially those developed by Apache, Google, the Eclipse Foundation and RedHat/JBoss)
  • Portability / deployment flexibility - I know I can deploy a JVM on pretty much any platform, including big cheap Linux clusters. With .Net, you are restricted to Windows environments. With the advances in cloud hosting options, I judged this to be a pretty important advantage.
  • Scala and Clojure are both viable options for development on the JVM if you want advanced language features. It's a realistic option to develop in Java but keep open the option to move to Scala or Clojure over time. To some extent these are "next generation" languages that I think are ahead of both Java and C#, so this reassured me that the Java platform has a good future in terms of language innovation. (Java 7 and 8 looked promising, but I wasn't exactly holding my breath....)
  • Maintenance costs actually seemed to be pretty favourable towards Java. Java has a simpler syntax than C# which means more verbosity but on the flipside means that people tend to write more maintainable code - it's simply harder to write "clever code". In addition, the Java world puts much greater weight on backwards compatibility than the .Net world, which is going to be advantage in terms of maintenance costs over multiple years.
  • Vendor independence - having seen companies being burned by vendor lock-in in the past, I felt it was an advantage to go with the relatively more open Java ecosystem rather than the Microsoft-dominated .Net world. For example, I'd rather have the choice of databases rather than being pushed into using SQL Server (and the push is quite strong, through both the tool support and typical skillset of .Net developers). Keeping your core product investment vendor independent is, in my view a smart long-term move. I judged (correctly as it turns out) that the OpenJDK would be the future of Java so I would effectively be building upon an open source platform.
  • Talent - this is subjective of course, but I was more impressed with the technical ability of developers in the Java world than in the .Net world. My impression on average was that .Net developers had a tendency to do whatever Microsoft provided easy tools or templates for, whereas the Java developers tended to care more about finding the right solution from a software engineering perspective. This is completely subjective and no doubt dependent on the specific locality/market and there were clearly many individuals that didn't fit this pattern, so YMMV of course.
  • Tools were about level. Microsoft have a lot of great, easy to use tools that would be particularly appealing for developing on Windows. However I am working primarily on server-side development, where I'd argue the Java tools have the edge. In particular, Maven has proved to be an extremely powerful tool in the Java ecosystem which I still don't think has a decent equivalent in the .Net world.

So while there were a lot of complex considerations, overall I'm pretty happy with the choice to go with Java, and would make the same choice today (As of early 2012).

Probably the only case now where I'd go with .Net would be if I was developing a Windows-only desktop application (where the .Net advantage is clearly huge).

4
  • 9
    +1: Great answer! It summarizes many of the issues that should be considered when evaluating productivity as a whole. Some syntactic sugar may make a language look cool and more "modern" but there are also other important factors that influence productivity.
    – Giorgio
    Jan 9, 2012 at 10:47
  • 3
    +1 for a way more comprehensive answer than previous ones. Oct 25, 2012 at 12:35
  • 1
    Since you mentioned Scala and Clojure you might as well mention F# too... Oct 28, 2012 at 4:02
  • 2
    Great! Thorough analysis. Just what I was looking for. :)
    – xebo
    Feb 11, 2013 at 13:57
9

I have: Java 10 years, C# 8 years

I vote Java for

  1. No Vendor lock in (you can change app/web servers from linux to windows to Unix)
  2. Interoperability/Interchangeable of third party packages, such as JasperReports JFreeChart, JSF or Spring
  3. Most innovation comes from here (Log4j, Ant, Spring, Hibernate, and on and on)
  4. Works on Multiple application servers (kind of like A). Such as JBoss, Tomcat, WebSphere, GlassFish, WebLogic
13
  • 25
    What kind of "innovations" can be in a language with no lambdas?
    – SK-logic
    Mar 23, 2011 at 13:06
  • 6
    There were other MVC frameworks before ASP MVC (e.g. MonoRail)... Apr 18, 2011 at 5:19
  • 2
    Oh BTW: Lambdas/Closures are a language feature, you are talking about frameworks. Apr 18, 2011 at 5:20
  • 5
    @SK-logic, you do not require lambdas to write an O/R layer.
    – user1249
    Aug 27, 2011 at 7:40
  • 2
    @Giorgio, lambdas fit perfectly any language with GC. There is no place for them in C++ and C, of course.
    – SK-logic
    Dec 6, 2011 at 19:30
6

Java: 5 years (non continuous)
C#: 7 years

I don't believe you can quantify the productivity that way. That heavily depends on the individual developer and the project. Use what your developers know.

Edit:
Let's define "typical enterprise application" as:

  • multi tiered
  • client/server
  • DB backed

Both Java and C# can do that. It's not so much a matter of the language, but of the framework/runtime. Again, use what your developers know. They can learn a new language and a new framework, but it takes time to grok it. The would be true for a desktop app. Both languages can be used with numerous GUI toolkit/libs, but it they all have different approaches and philosophies.

6
  • 4
    "That heavily depends on the individual developer" ... which is exactly why he wanted an opinion from people who have experience in both worlds ... "and the project." ... which should require an answer that points out what kind of projects will benefit from the different technologies.
    – awe
    Feb 25, 2011 at 13:49
  • 4
    It does not depend on this dev (aka me), but on the devs who are supposed to build the project. It also would be easier if he had stated what kind of project he is about to build... Feb 25, 2011 at 13:58
  • @eric it's typical enterprise application Feb 25, 2011 at 14:12
  • @Edin, Java does have JavaEE edition with inbuilt enterprise features. You can quickly develop applications with this framework. However it does alot of stuff by Magic, you must conform to its rules. And if things break don't expect the exception messages to be useful as the stacktrace is huge. Accessing a DB with wrong name or DB is off, the stacktrace is so big you cannot see what caused the initial problem.
    – JonWillis
    Feb 25, 2011 at 15:20
  • 5
    Sure there is a "typical enterprise application", take this data from point a, allow the user to mess it up, then put it in point b. ;)
    – mezmo
    Feb 25, 2011 at 17:02
6

I have 10+ years of experience with Java (since version 1.1, really!) and 7 years of experience with .NET (C# mostly).

You have a very though decision to make but mostly you should try to break down into a couple of scenarios:

Desktop Application

If you are developing a desktop application you have to go with the major platform you will be working with. If it's a Microsoft platform use .NET, there are no better solution than the platform developed by the mother ship itself. If it's a Linux or Multi-platform scenario consider Java or moving to a web based solution.

Web Based Application

This is a very hard decision to make because each one has their own strength and weakness. Here's a few:

C#

Strength: Currently has more momentum building new features into the language and the platform/framework. Everything comes from one vendor and definitely this is an advantage. You can also put to use some very powerful components like DevExpress for example (Java doesn't get even close to have something like what the DX team has put together over the years and this represents a huge productivity boost).

Weakness: For enterprise application .NET is not as mature as Java. You don't have that many vendors building enterprise software in .NET as you have for Java.

Java

Strength: More mature (already explained) and has a big community with several great open source projects that can help. Several .NET so called open source projects are really just a copy-cat of projects from Java.

Weakness: Oracle owns Java (I know, not the JCP) and that is definitely a risk to be considered. Their intentions are not very clear and I personally don't like where the language is going right now (I know a lot of Java developers have similar concerns).

Server Side Application

It's basically the same arguments as the Web Based Applications but because you don't have to worry too much about UI Java gets stronger in this case. But again, if the platform is mostly Windows .NET might be a better choice.

Overall Considerations

Overall, in my opinion, .NET has the advantage mostly because of the tight integration of Visual Studio 2010 (hands down the best IDE out there), MS SQL, Entity Framework, IIS and so on. This all represent a huge productivity boost and I have tons of experience proving that. Also I work with mostly Java developers that turned to .NET and they share basically the same opinion.

I think it's also a good point that Microsoft is stronger than ever meaning .NET will be there for a while. So when looking 10-15 years ahead I feel more secure with .NET than Java.

4

I'm a recently graduated student from university, but have had commercial experience with both languages, giving a total of about 3 years java and 4 years C# .Net (note .net means you can use C#, VB.net, C++ CLI, and J# and F#).

I'll state now my overall preference is C# over Java, whilst both have similar syntax I like the power of the .Net framework over the cross OS compatibility of Java. You must strongly consider ,what you need to build ? Is this just a desktop application? Are you needing connectivity to other clients, so other desktops, mobiles, websites?

**Discussion on IDE lost as question at Stackoverflow was closed. End gist of it was Java has many free IDEs but they don't compare in my opinion to the power and addons of visual studio. But note Visual studio costs over per license.

You need to look at what skills your development team has already, as this will have an initial impact. Which is faster is here nor there given an experienced user in either language/framework. Which I guess brings the point that you must not consider the language, as the language is just syntax, but the tools and the framework that the language is making use of.

7
  • 11
    £1000 per licence for VS? If you're getting MSDN subscriptions, you get far more software and tools available for the cost. I really doubt anyone pays the retail shelf-price of VS2010.
    – James Love
    Feb 25, 2011 at 13:11
  • 6
    @Michael, I've never tried to wrtie VS extensions. However I do use or have tried a variety of plugins for Visual studio. These include Resharper, CodeRush, Gallio, VisualSVN, AnkhSVN, testDriven.Net, and many more.
    – JonWillis
    Feb 25, 2011 at 15:16
  • 2
    @JonWillis agreed, there are a plethora of extensions out there. On top of that list, I also use (on a daily basis) Productivity Power Tools, CKS:Dev for SharePoint and WSPBuilder. The gallery (at visualstudiogallery.msdn.microsoft.com) has a couple of thousand on there, so it can't be that hard to write more extensions for VS (full framework is actually provided for doing so, and there's ample community support).
    – James Love
    Feb 25, 2011 at 15:27
  • 1
    For a project planned to be 10-15 man years work, an initial cost for VS licenses is peanuts.
    – awe
    Feb 28, 2011 at 7:42
  • 1
    Visual Studio 2010 Professional without MSDN is $550. Aug 27, 2011 at 13:10
3

With the similarity in syntax and tools, the producivity gains from either C# or java are not of an order of magnitude to make a significant difference to your 10 - 15 man years work project. I would look more closely at issues like:

  1. What are the requirements of the project and what language capabilities meet those requirements (e.g. cross platform vs rich Windows client).
  2. What can I put in place as a project approach/methodology that is going to enable my team to work productively.
  3. What can I do about the work environment to make sure I employ, retain and fully utilise the best team possible for a significant project.

I would suggest that, in my opinion, the premise behind the question, that "productivity differences between (C# and Java) may significantly influence the investment required and time-to-market" is not true. I do not doubt there would be some difference but it would not be significant.

3

I've flipped back and forth between Java and .NET, starting with Java 1.2 up to 1.6, and .NET 1 up to 4.0, over about 10 years of professional work experience (being a C/C++ programmer before that).

At one time, like .NET 2.0, I would say that Java and C# would be about the same, especially for back-end work. The language constructs were still very similar. .NET would have probably gained the edge in desktop UI programming, because of the WinForms designer in Visual Studio, and Java would have had the edge in Web / Server stuff, primarily because you weren't stuck with IIS.

Now moving in to .NET 3.5 and 4, I give the productivity edge to .NET, hands-down. This is primarily, in my opinion, because .NET is a much quicker evolving language, since MS can make language decisions relatively quickly, as opposed to pushing changes through the politics of the JCP. Big improvements are the var keyword, the entirety of Linq, Extension Methods, the Null-coalescing operator ??, dynamic, and probably a lot more great stuff that really boosts productivity.

Now, that said, the "most productive" language for a project is almost always the one that the most developers are the most comfortable and experienced with. The learning curve is always the biggest productivity killer.

3

One thing that I have noticed is many C#/.NET shops have a "not invented here" attitude and ban all third party/open source libraries while many Java shops are more willing to use open source libraries. Also there seem to be more libraries available for Java. Even if you look at some cool third party libraries in .NET e.g. NHibernate, NPOI, Spring.NET, etc. they are ports of the Java libraries and hence are behind them. It certainly seems like many of these innovations came first to Java and after time a .NET port was created. From a library perspective it certainly seems Java wins in terms of new innovative discoveries.

Still Microsoft does make some official libraries e.g. ASP MVC, LINQ, etc.. But often like with ASP MVC third party libraries like Struts, Spring MVC, etc. were already out for Java and Microsoft was late entering the model view controller web paradigm.

Of course, many of these libraries save a ton of time and make you more productive. Core language to core language C# and Java are not that different and for me it is too close to call. Throw in the army of third party libraries and the scale certainly tilts towards Java. Still with an open shop a lot of that tilt balances out. It's just a lot of .NET shops have the not invented here attitude while a lot of Java shops are whatever it takes to get the job done... This is even true within the company I work, the .NET team does not get much (due to management) while the Java team has many approved third party libraries/utilities. Also with .NET a lot more of the good stuff is not free (e.g. prior to NPOI if you wanted to work with Microsoft office documents, most of the solutions [not counting office automation] were not free. Whereas java had POI since 2001 I don't think NPOI came out until 2008, it's hard to tell based on the npoi project site.

2
  • "Not invented here". Based on what grounds? I work in a mix between C# and Java and I've seem greater abuses from Java folks, e.g. creating an IConverter and implementing logic to convert a string to double, and vice versa. Jan 9, 2012 at 13:05
  • For several reasons I prefer C# over Java, yet, I prefer the "migrated" Java To C# libraries over the native C#, usually, better designed, tested & applied in real world.
    – umlcat
    Oct 27, 2014 at 18:05
0

I asked myself this question a lot : which is better ? C# or Java ?

I will give you an advice and this advice is the conclusion of my research : None of them is better, only the language you know well and you can do a lot of fascinating applications with is the best.

Learn how to program and then train yourself a lot using one language and when you become perfect in writing code with it, think about other languages and believe me, you will learn the other languages like a piece of cake.

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