share
Stack OverflowWhy is C# suddenly so popular?
[+138] [31] leeand00
[2009-02-22 19:22:01]
[ c# java .net ]
[ http://stackoverflow.com/questions/575513/why-is-c-suddenly-so-popular ] [DELETED]

Why is C# suddenly so popular?

There's been like a repeat explosion in the blogs lately about it. It reminds me of the earlier part of this decade when all of those frameworks for Java came out like Spring [1], JSF [2], Hibernate [3], Struts [4], Struts 2, Tapestry [5], etc.

I've actually been thinking about learning C#, and it seems to contain a lot of qualities that it has gotten from Java (aside from it being completely cross-platform).

It almost seems like a step backwards to me...it's not totally multi-platform, a language that's run by a corporation rather than a community...

(But, knowing this isn't the case, I've come here to find out why it isn't...) I am aware of the Mono [6] project so that you can run it on Linux, but isn't it always behind the curve? A new version of Java would be supported on all the platforms.

(110) Anybody that tells you that Java is cross-platform isn't telling you the whole story or they haven't actually tried making something cross-platform-ready. It's often a painful experience. Also, Java isn't controlled by a community. Where did you get that from? - senfo
(17) Java is "guided" by a community. The Java Community Process as it's called, but that's only guidance.. not control. - Mystere Man
(7) Most features are supported in Mono, I've made tons of console apps that I coded and compiled in VS for .NET 3.5, even using LINQ and they've worked unmodified in Linux. - M4dRefluX
(24) Re mono being "behind the curve"; at the language level, they're really not (OK, there's the odd compiler bug, but very rarely). It is the runtime that lags a little (see "Olive" etc). But mono is still very functional; don't underestimate it. - Marc Gravell
(21) When has Java ever been run by a community? Java is and was run by a corporation as much as C# is. The difference is, C# actually has some brilliant people designing the language. But you're right about the cross-platform thing. Yes, there's Mono, but the situation isn't as good as with Java - jalf
(2) Shouldn't this be a community wiki? - Hosam Aly
senfo: I've coded plenty of apps that worked just fine cross-platform in Java. I don't know what you're talking about. - leeand00
Maybe the inclusion of a 'subjective' tag should automatically trigger community wiki status? - Jonathan Webb
@jonathan, that would be abused way too much. - Robert S.
(3) This question should not have been closed. - achinda99
(1) You might find this interesting google.com/trends?q=java+programming%2C+c%23+programming - Peter Lawrey
@Peter Lawrey, nice graph! Shows Java Programming to be 3.4 times as popular as C# Programming. Trying for Java and C# (without "Programming") shows that Java is 5.1 times as popular as C#! :) - Hosam Aly
(3) Yeah, but Java is also a country and another word for coffee so that makes the "without Programming" bit a little dubious... - leeand00
(1) @leeand00: Please read stackoverflow.com/faq The "What kind of questions should I not ask here?" section. As for the answer, my subjective and argumentative point of view is because it looks lot more like Java than Visual Basic :) :) :) :P ;) ;) . Microsoft developers also have the right to code in a good programming language don't they? :) The problem with mono, it is not driven by MS, so it will ALWAYS be behind the latest .NET release. - OscarRyz
@senfo I think Java is very good as a cross-platform language. You just have to know how to use file.separator. - leeand00
(2) C# did not get "it's qualities" from Java - they both got them from C (via C++) - Wolf5370
(1) It's been said that C# didn't take things from Java, but anyone who believes that is kidding themselves. However, that's not what I started commenting to say. C# is an amazing language that was very well planned out. Java on the other hand is messy, largely because of its community influences and "let's tack this on here" mentality. - Millie
@Millie I remember when Java came out and the only thing Microsoft had was Visual - leeand00
(2) Apart from not completing sentences (which you have succeeded at), what are you trying to achieve here? Which of my points are you contesting and how? Because what you said doesn't make sense. - Millie
[+283] [2009-02-22 19:51:00] Randolpho [ACCEPTED]

There's nothing "sudden" about the popularity of C#, it's been quite popular since its birth at the turn of the century.

Also, I don't understand how you can consider C# to be a step backwards from Java; if anything, C# is several steps ahead of Java. The cross-platform "issue" you mention is only an issue of politics and not one of technical capabilities; Microsoft (erroneously, IMO, but that's neither here nor there) sees no value in doing the work of bringing the .NET platform to non-MS platforms. The other issue... "a language that's run by a corporation rather than a community" is actually more of an issue with Java than it is C#; Sun still controls Java with an iron fist, despite IBM's continual pleas. Edit: Not anymore [1]. Now IBM has to beg Oracle to modify Java...

So, to the actual question, why is C# popular?

Because:

It really is a great platform for programming. There are numerous improvements over Java, such as:

  1. Value Types
  2. Properties
  3. Delegates and Events
  4. Global Assembly Cache
  5. Runtime Generic Support

It's constantly evolving, both in terms of library support and new language features. For example:

  1. LINQ (it will change the way you iterate a collection!)
  2. Lambda Expressions
  3. Closures

It has broad reach across the Microsoft platform:

  1. WCF (Windows Communication Foundation)
  2. WPF (Windows Presentation Foundation)
  3. WP (Windows Phone)
  4. Windows Store Apps
  5. Windows Embedded
  6. Microsoft Xbox

It has broad reach outside the MS platform:

  1. iOS with Xamarin and MonoGame
  2. Android with Xamarin and MonoGame
  3. Mac with MonoGame
  4. Linux with MonoGame

And now in C# 4 [2]:

  1. Dynamic types and the DLR (i.e. runtime type binding, like python)
  2. Named and Optional arguments
  3. Covariance and Contravariance
  4. native asynchronous operators await/async

In terms of IDEs, Visual Studio is pretty darn good. I'll admit that there are features of Eclipse I'd like to see in Visual Studio, but there are features of Visual Studio I'd like to see in Eclipse, too. There's also MonoDevelop [3], which is shaping up nicely.

Plus, there's a great community of fellow programmers who are always willing to help out. This site is the perfect example of that.

[1] http://developers.slashdot.org/article.pl?sid=09/04/20/128246
[2] http://code.msdn.microsoft.com/csharpfuture
[3] http://monodevelop.com/

(53) +1 on the bit that C# has numerous improvements over Java. Delegates/events is what sold me. C# 3.5 also has automatic properties which I've found indispensable. C# 4 is filled with a bunch of excellent improvements as well. - Spoike
(11) FYI, it's C# 3.0 that shipped with .NET 3.5. - Richard Szalay
(23) +1 for the Sun controlling Java comment. Reason why there is no Microsoft JVM anymore: Sun told them to bugger off. Same reason why there is C#. Same reason why Java is loosing ground to C#/Groovy/Clojure. Oops. Nice one Sun. Microsoft has actually helped out with Mono (Moonlight IIRC). - Jonathan C Dickinson
(12) I have used eclipse probably 5 times. Every single time, I have exited the program by it crashing. Visual Studio has not done this. Not that IDE is all that matters, but seriously... how about those sln files for VS? How about manually doing a whole bunch of crap in eclipse just to get started? - jle
(8) @jle: That's a good point about solution files; big benefit of VS. That said, I've worked with Eclipse many many times and never experienced a crash. Eclipse is not a bad IDE, it really isn't. When I program in Java, it's the IDE for me. I just prefer to do it in C#/VS. :) - Randolpho
(1) @Jonathan: Actually, Microsoft was already in the "extend" phase of the three-E plan before Sun sued them to make them stop. Remember J++ and J#? en.wikipedia.org/wiki/… - Michael Myers
(1) @Randolpho and jle: Maybe your problem is that you were using Eclipse and not NetBeans. ;) Actually, NetBeans is slower than Visual Studio (in startup time at least), but it seems whenever I use VS I find something that I could do in NetBeans but not in VS. (That could be because I use C++, though.) - Michael Myers
(2) J# came with C#, but you're correct regarding J++. However, you are incorrect in your apparent assumption (by your invocation of three-E) that Microsoft was trying to kill Java. On the contrary, they tried very hard to get their changes (particularly delegates) added to Java by Sun. Sun sued instead - Randolpho
@mmyers: I seem to remember defending Eclipse in my comments. I rather like it, in fact. I haven't used any recent version of NetBeans so I cannot comment, but Eclipse is a very solid IDE. I just happen to prefer C# to Java. - Randolpho
@Randolpho: OK, I don't want to spread misconceptions about Microsoft(since I wasn't paying attention to such things in 1997, it's likely that I'm wrong. Plus there's a lot of people doing that already). I did read that they tried to put OS-specific things in, so maybe that's what I was thinking of. - Michael Myers
@Randolpho: Sorry, I misread your comments as favoring VS over Eclipse, not favoring C#/VS over Java/Eclipse. My mistake. - Michael Myers
@mmyers: No problems. As I said, I do prefer VS over Eclipse in some things -- particularly solution files -- but find Eclipse better for other things. When it comes to language, I prefer C# for the reasons I listed in my post. It's not to say that Java is bad, just that C# is better. IMO. - Randolpho
(1) @spoke When you say automatic properties, do you mean you don't have to write all those setters and getters? - leeand00
(1) @leeand00: Yes, with automatic properties, a backing storage variable is created for you for properties that only get/set a variable. So string MyString {get;set;} compiles for a class as well as an interface. - Randolpho
Try groklaw.net/articlebasic.php?story=20070108020408557 for the details of that 1997 court case, MS doesn't come out well at all, especially when they discuss MS's anti-java strategy memo. - gbjbaanb
Perhaps the line that stands out most from the court transcript is (from a document by Aaron Contorer to Bill Gates): "The third choice is to make major innovations to our platform so people still prefer to write to us instead of some tepid cross-platform Java layer. This is our only real option. " Sounds just like what C# is! (and the 3Es are a microsoft term, they use it a lot). - gbjbaanb
woohoo, 60 votes! Only 40 more to go for a nice shiny gold badge. Let's have some votes, people!!! - Randolpho
+1 can't beat the speed of loading up devenv.exe... - jothetomato
I thought the JSR was an open process... - fortran
It may be, but the Executive Committee has the final say. Not exactly easy to get things fixed or changed. - Randolpho
Only one vote for a gold badge! Anticipation............................ - Randolpho
@Randolpho: here you go! - Ken Browning
Thank you Ken! Here's a few random reps for you from me. - Randolpho
Under the "broad reach" section of this answer, I am disappointed there are not more platforms listed. One is Netduino (embedded), and the other is all the platforms supported by Unity3D, which uses C# (and Boo and a custom ECMAscript) running Mono on: Windows, Linux, Mac, Android, iOS, PlayStation 3, Xbox 360, Wii, and unofficially PlayStation Vita, in addition to additional redundant support on some OS's via the web (Unity Web Player) and Adobe Flash. (Thanks to wikipedia for that list.) - Jared Thirsk
Fun fact: I'm the original author of this response, and I didn't mention that section at all. Jerry Nixon - MSFT did that. Should I feel overwhelmed that somebody at Microsoft thinks my post is good advertising? :) - Randolpho
(2) +1 for affirming that C# is better than java - Sam I am
1
[+97] [2009-02-23 06:23:39] Jonathan C Dickinson

I have ranted on about how poor Java is all along in the comments here. The truth is that C# is what Java should be today, if Sun were not so short-sighted and, might I say, 'frightened' to evolve. The opposite side of that coin, is of course, C# wouldn't exist were it not for Java and Sun with their corporate strategies with Microsoft. So yes, C# owes a lot to Java.

To me one of the most pertinent features of C# is the whole IL emit scenario. I don't think there is another language which will let you emit a JITted IL (not interpreted code, like Ruby etc.) at runtime. Remember, machine code is a lot harder to work with than IL: so saying you could do it in C/++ doesn't count :). The whole IL emit scenario has opened the language for some amazing frameworks; and these frameworks allow the developer to gather momentum at the start of a project without the usual performance penalty to worry about.

The typing and versioning system is second-to-none (if used properly). Sure most modern languages have their reflection systems, but none of them feel as intuitive as C# (hell you can reflect the reflection classes if you see fit) - most (Java is an exception here) have built-in keywords which just seems alien when you use them. C# reflects classes using classes - it's insane!

And there is the framework. The namespacing system (which is something so subtle) makes a huge difference. When I did Java I spent my life importing types and resolving conflicts - the system was nearly there, it just took Microsoft to perfect it. The Java/C++ standard libraries are a mess when compared to the .Net BCL. Since when does that namespace of something start with the name of the language in use, that's redundancy. Or for that matter: org.joe.my.controls. This means that to use Joe's controls you must know that they are free and know the spelling of his name.

Much of this thread is about Java VS C#, and that's exactly the point. Java redefined the programming landscape, and C# has done it again. That is why the blog buzz around C# has had similar properties to the one around Java. Java was a great language and C# is a great language. The rest pale in comparison.


(5) I don't think this is worth the downmods; it certainly tells it like it is. +1 - Randolpho
(1) Why did people downvote? It's a good answer. +1 compensation vote - erikkallen
Definitely +1! a very good answer. - Pop Catalin
(14) A couple of points: 1) Java has been JITted for about ten years; please stop calling it interpreted. 2) Judging from en.wikipedia.org/wiki/Reflection_(computer_science), C# and Java reflection are roughly equivalent. I don't see that C#'s system is a major advantage over Java. - Michael Myers
@mmyers, the key word in the sentence about reflection was most. I made it bold. - Jonathan C Dickinson
(1) @mmyers, I did state that Java was int IL, my bad. The argument still stands. I stated that you can't emit raw Java Bytecode at runtime and have it load and be JITted. .Net is the only platform AFAIK that can do that. - Jonathan C Dickinson
@mmyers thanks for the comments though. My answer was lacking. - Jonathan C Dickinson
Although I don't agree with you, +1 for a well written answer. As for emitting bytecode in Java, can't you create new classes in runtime, and have them optimized when they are passed to the class loader and JIT later? - Hosam Aly
@Hosam, thanks. I don't think you can create new classes at runtime. From what I have read C# is the only runtime capable. - Jonathan C Dickinson
(4) You can create new classes at runtime in Java, but it's a major pain. - Michael Myers
(11) +1 the remark about c# being where java should have been is, IMHO, right on the money. - Colin
Most of what you said isn't C#, though, but .Net. Reflection is a .Net API that has nothing to do with C#. The same for namespaces, versioning, IL emit, the BCL and pretty much the whole post. ;-) OTOH, you do not have C# in the Java VM, so .Net features kinda count as a pro for C#. - Robert Giesecke
(3) @Robert: You do realize though, following the argument, that the implicit meaning attached to the 'Java' and 'C#' refers to the stacks not just lexicons. Otherwise, it will be a silly point to talk about platform agnosticism as a property. It makes no sense to describe a pure higer-level language as cross-platform if you are not speaking of the available compilers, interpreters, class library, and utilities ... especially enterprise frameworks - Pita.O
actualy c# doesnt need to hold any value to java as it was based on c++ with a ui of vb, I started off with vb6.0 and its very similar from ui to code appart from the syntax - almostSharepointMaster
2
[+73] [2009-02-22 19:25:31] Ben Collins

It's popular because it's now Microsoft's first-class supported language, and Microsoft steers a very large ecosystem with a lot of inertia.


(24) +1, Microsoft really does try hard. And it has paid off. - Jonathan C Dickinson
(4) Indeed, the reactions to this topic cannot be explained by the language alone. - CurtainDog
Well COM didn't take off and WinAPI is getting old. - Kugel
3
[+53] [2009-02-22 19:26:10] chakrit

How about a "corporation of smart people that also listen"?
The guy who designed C# is very smart, I'd say.

And personally, I've switched to C# because of LINQ and the semi-functional programming support. IMO I think that is what "wow"-ed most corporate developers and made them switch over from other languages.


@chakrit What's semi-functional programming support, does that have to do with writing assembler code? - leeand00
@leeand00 No, I mean you can pass function as arguments and use some lambda functions and lambda calculus in C#. But C# isn't a functional language in its entirely so I used the term semi-functional. Not sure if it's the most appropriate though. - chakrit
(4) No doubt they're very smart, but that's also its curse: the language is huge, and the stdlib is huge^2. I tend to find it much easier to work with systems designed by someone of moderate intelligence but good taste and humility. - Ken
(1) I take it you switched from Delphi? - CurtainDog
@CurtainDog VB.NET ... but I write mostly in javascript these days. - chakrit
@Ken stdlib is huge?? Have you tried some of the beginning tutorials? I think the "stdlib" from .NET (and Java) are wayyyyyyyy easier to grok than... say... Python or PHP... but maybe that's just me :-) - chakrit
The same person who invented Delphi / Object Pascal! :) en.wikipedia.org/wiki/Anders_Hejlsberg - thenonhacker
And he's Danish! <3 - Mathias Lykkegaard Lorenzen
4
[+46] [2009-02-22 21:07:46] Hosam Aly

As other people have said, the word "popular" needs to be defined in some context.

I would point you to one measure of popularity, that is the Tiobe Programming Community Index [1]. In about 8 years, C# has only gained about 5% popularity. Surely you can see it rising [2] (when compared to itself), but when viewed within the grand scheme of things, it seems that it is too slow when compared to other languages. At 5%, it's well behind the next language (PHP - 8.8%). Even it's increase rate (+0.55%) is about half that of C (+0.98).

It's certainly gaining popularity, but I don't see it gaining so much as you see it.

For quick reference, here are the graphs I'm referring to:

Tiobe Programming Community Index

TIOBE Index History for Language C#

[1] http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
[2] http://www.tiobe.com/index.php/paperinfo/tpci/C_.html

Awesome graphs. The top one also shows that Java is in a decline, which would help with the perception that C# is becoming more popular than Java. - Cameron MacFarland
(28) There are lies, damned lies and statistics. Caveat emptor - Spence
I don't find Tiobe to be all that useful. For instance, they don't break out VB versus VB.NET, nor do they break out C++ from C++/CLI. Also, C# is one of the few languages to consistently grow year after year. - Mystere Man
Also, if you go back and look at the feb ratings, C# grew by 2.88% while C and C++ both dropped, so over the last two months, C# grew by 3.3% wile C++ and C both had net negatives. - Mystere Man
@Mystere Man: When looking at the long term trends, I invision 2011 with Java still above 15-17%, C almost stable at 14-15%, C++ dropping to about 8%, and C# rising to about 7%. That's still a huge difference between C# and C or Java. - Hosam Aly
Only because you're looking at C# as a single language. People who use .NET often program in several different languages depending on the requirement. The same project can even have VB and C# and F# and J# code in it. Java is primarily a single language for the entire platform. - Mystere Man
Well, you may be right, but the question is specifically about C#. :) - Hosam Aly
Mystere Man - en.wikipedia.org/wiki/… - toolkit
Interesting graphs, but I think that they are too "toothy" to be truly accurate. It can probably say something about relative popularity, but I'd be careful when using them to talk about trends. - erikkallen
(41) I can't trust a graph that is made using keyword searches show me the popularity of a particular language, especially in the case of C#, where "tons" of searches are made without "C#" but instead contain MSDN or .Net, or simply class names. - Pop Catalin
(1) Pop Catalin makes a good point. I seldom include "C#" in my search strings when I want to look up how to use some part of the .NET framework. - Joel Mueller
(19) "The popular search engines Google, MSN, Yahoo!, and YouTube are used to calculate the ratings" How can you rely on something based on query result from search engine? Suppose you've the best programming language with no bugs and excellent offline documentation, since is perfect as is you will probably not found anything on the net, so this made this language unpopolar? Meaningless. - kentaromiura
(2) See this about TIOBE: blog.timbunce.org/2008/04/12/… - Alexandr Ciornii
@Pop: and who adds C or even C++ to their keyword searches? You're suggesting C is far more popular than it appears in the graphs. - gbjbaanb
why doesn't this chart have Delphi? - Paulo Guedes
@Paulo Guedes: That's because it's not in the top 10. The graph only shows the top 10 languages. - Hosam Aly
(7) O'Reilly's analysis of the computer book market shows the same broad trends. See radar.oreilly.com/2009/02/…, in particular the graph at radar.oreilly.com/languages_all_5yrs.png - Nelson
@Nelson: Nice graph! Thanks. - Hosam Aly
(6) I like this data. But my interpretation of it is: See how much internet search you need to do to get your work done on the different languages!! Or "IDE sophistication reduces the need to search online". Or "Don't name your kid C# because each of his teachers will call him a different thing (csharp, c-sharp, cs, .net dotnet) and he'll look like he missed school!" Or "The C# community is not such a net-chatty bunch afterall." Or "Empty vessels make the most sound." - Pita.O
Trend is clear and in long term C# will prevail: tiobe.com/index.php/content/paperinfo/tpci/index.html And that's just plain stats and lies :D - feronovak
Upvoted since the response went to the heart of the question: language popularity. Who makes the question states that the language is popular, although it shows no metric to justify it. - JBishop
5
[+37] [2009-02-22 19:35:27] cwap

Well, my completely subjective view is:

C# pro's

  • Best IDE ever (Visual Studio)
  • Best documentation (I luv msdn :) )
  • Really easy to learn
  • WPF is awesome.
  • Usable for a lot of deployment projects (silverlight, windows compact and ofc "ordinary" windows programming
  • As you said - tons of nice blogs
  • MS is really doing a great job enhancing .NET all the time

C# con's

  • Not completely cross-platform

.. So, in my view, the pro's outweight the con's by a large margin. So as long as I'm not doing anything that requires a total cross-platform design and which needs a window-based GUI, I wouldn't consider other languages as it is right now. :)


(5) C# cons: VS might be a nice IDE, but it's not free (I know there's an Express version but you can't have integrated source control with that version). - cdmckay
(4) @cdmckay: Even still, Visual Studio Express is really nice - especially for being free. - xian
(7) @cdmckay: Bah! You can still run source control such as subversion or mercurial just fine without VS integration. - Spoike
(7) @cdmckay - re integrated source control; personally, I vastly prefer it separate to the IDE (tortoise, etc) - Marc Gravell
(11) I'm talking about myself, but I find Visual Studio intrusive and very poor in refactoring. I certainly prefer Eclipse as long as I'm writing code (which is 99% of the time; I don't do GUI). As for documentation, I still find MSDN much lacking compared to Java IMHO. - Hosam Aly
(1) I'm not convinced VS is the best IDE ever! Eclipse, Netbeans and Intellij in the Java space are all far superior. - Fortyrunner
+1 on Tortoise. VS Express is amazing for the price. - Jonathan Webb
(1) @Hosam; you need to extend VS with ReSharper if you want to be happy and sleep well at night! - Henrik
(1) @Henrik: So you have to pay about $800 for VS Pro, $150-250 for ReSharper, some more money for for a good profiler, and still pay for upgrades every year. For me, that's a hefty sum of money, while I have all the goodness of Eclipse and TPTP for free! And it runs on Linux too. ;) - Hosam Aly
@Jonathan Webb: I don't see how VS Express provides a good value for price, when compared to Oracle JDeveloper for example! - Hosam Aly
@Hosam Aly: any free software that allows you to get stuff done is good value :-) - Jonathan Webb
@Jonathan: maybe, but to be "amazing" it has to be truly amazing ;) :D - Hosam Aly
ReSharper > MSDN :) - Jacob Stanley
I probably wouldn't say VS is the best IDE, but since there's nothing much better, VS is the one I spent most of my time on. Qt Creater is pretty cool and cross platform, but it's only for Qt. - Hao Wooi Lim
(2) Personally, my favorite IDE is a bunch of xterms running vim and assorted development tools (like gcc, gmake, gdb, gprof, etc.), but Visual Studio isn't really bad. - David Thornley
@Fortyrunner have you actually tried Visual Studio over Eclipse? - Mathias Lykkegaard Lorenzen
(1) Yes - many times (not tried VS 2012 though) because I was a .NET dev for about 5 years as well as a Java dev. A lot of Java ides offer some sort of free profiler, better refactoring, better support on smaller monitors (I have 1280x1024 at work). VS is expensive and typically have fewer features (that regular developers use) than Open Source IDES. Having to pay for Resharper sucks - Fortyrunner
Best documentation (I luv msdn :) ) No <sarc> tag? WOW! I guess I'm looking at it a little differently than you are. - David Tansey
6
[+35] [2009-02-22 19:35:57] Mystere Man

There is nothing about C# that is not platform independent. C# is entirely platform independent, and it exists on multiple platforms. The .NET framework has parts of it that are more oriented towards windows, but that is not C#.

Unlike Java, there is a clear seperation between the languages used, and the runtime. In Java, both the language and the runtime are "Java" and are inextricable. Yes, there are various 3rd party languages developed for Java, but none of them have Sun's blessing, nor was the runtime designed to facilitiate this.

Consider that C# and the CLI/CLR are both ISO standards, fully documented, with royalty free licenses. Java is (mostly) GPL'd now, but is not an international standard. C# 3 is not yet a standard though, and probably will be skipped with 4.0 being resubmitted for standardization.

Plus, C# is a better language than Java in many respects. It's easier to work with, and none of that Checked exception BS. And it has extension capabilities that Java just can't match, not to mention versioning and whole raft of other features.


(9) While what you say is true, c# in most people's mind is intimately tied to .NET. When people think c#, I think they mostly think of .NET, not c#. - Giovanni Galbo
That's a ridiculous argument. Mono can use C# without any part of the .NET framework. You can stick to C#/CLI/CLR and write in GTK# and other non .net libraries. - Mystere Man
(8) Argh, "that checked exception BS" is what I miss most in .NET you insensitive clod! - Wim Coenen
what's a ridiculous argument, I'm agreeing that what you said is true. That doesn't take away from the fact that most people are really thinking about c#/.NET rather than the language when they discuss c#. - Giovanni Galbo
Reguardless, this is about the language, Giovanni Galbo, and not about .Net. - TraumaPony
(4) True, but the question is "Why is C# suddenly so popular," and a huge (probably the biggest) is because of the enormous library behind c# - .NET. - Giovanni Galbo
@Mystere Man: Is there any way to use destructors properly without using the GC namespace? - supercat
@supercat - your question is not relevant to this question, you should ask as a new question. - Mystere Man
@Mystere Man: You stated that C# is independent of .net, and suggested that as being part of the reason for its popularity. I'm curious to what extent that's true of programs that use destructors, since the only patterns I know of for using destructors would seem somewhat platform-dependent. - supercat
@supercat - Destructors are a language feature, not a platform feature. So i'm not really sure what your point is. Yes, a C# destructor is called by the garbage collector, but that's an implementation detail. Also, you can have GC without having .NET, as the concept is not .NET specific. - Mystere Man
@MystereMan: Code which uses destructors must generally make use of things like GC.SuppressFinalize() or GC.KeepAlive() to yield correct behavior. And I would consider those latter things to be platform features rather than language features. - supercat
@supercat - You are confusing easy portability with platform independence. They are not the same thing. One could easily pre-process out .net features, just like one does in C/C++. But all that is irrelevant, since I never said anything about running C# without a VM. We're talking about platform independence for the HOST operating system, be it MacOS, Windows, Linux, etc.. C# depends on the CLR and the CLI, which are the runtime and the standard framework. - Mystere Man
If we are still talking about C# and haven't slipped into C++, then it is rare to need destructors anyway - when clean up is required, then the class can impliment IDisposable to handle it. C# is managed and the GC is managed - the fact that there is any ability to control/guide the GC is a boon at worse. This is a high level managed language. - Wolf5370
7
[+26] [2009-02-22 20:26:18] joel.neely

Just a suggestion: I wouldn't confuse "popular with bloggers", "popular with programmers who can choose their own tools", and "widely used in some specific environments". (Especially beware of the first of those. Based on what some bloggers like to write about, Rails has taken over the world, Java is dead, and COBOL never existed... ;-)

Instead, I'd look at my current environment (or the one I'm trying to break into), and ask "What tools and techniques are emerging in that area?" and ignore marketing hype and blog rants (pro or con).


(4) Interesting thought Joel, I'll have to keep that in mind. I used to base my option solely on blog posts. What other things can I base my option on? Job listings? - leeand00
8
[+18] [2009-02-22 19:29:34] Brian Rasmussen

What do you mean suddenly? C# has been around for a while now and it is continually being enhanced. The new features actually make it a quite unique language.

Also .NET offers a very good alternative to doing Win32, MFC or the like. It is much easier to use and while the feature set may not be complete, it will suffice in most cases.

Additionally C# and .NET may be used for both embedded systems as well as entertainment devices such as Xbox 360 and Zune.


(2) Not to mention cars, watches, phones and robots. - Richard Szalay
@Richard: that is what I was addressing with the "embedded systems" part but good examples. - Brian Rasmussen
@Brian, 2007 was a rough year, I had to leave my job due to health reasons. Then I got a job in 2008 at a place that still uses VC 97". I'm trying to find out where things are presently... - leeand00
@RichardSzalay which watch uses c#? that's absurd - Артём Царионов
brian, can you please give me an example of how embedded systems use c#? i do not believe that is true even 4 years later - Артём Царионов
@АртёмЦарионов - Google is magical. robmiles.com/journal/2011/5/20/… - Richard Szalay
@АртёмЦарионов - Many car manufacturers (including Ford and Fiat) use "Microsoft Auto", which allows .NET development. - Richard Szalay
@АртёмЦарионов .Net Micro Framework eg anything netduino powered? - Basic
9
[+17] [2009-02-22 19:28:16] Duncan

I prefer coding in C# over Java. They feel so similar to me that it's the IDE that makes the biggest impact between the two. Visual Studio [1] over Eclipse [2] any day of the week.

[1] http://en.wikipedia.org/wiki/Microsoft_Visual_Studio
[2] http://en.wikipedia.org/wiki/Eclipse_%28software%29

Yeah, Eclipse sucks... - quant_dev
Eclipse actually has two features I wish we'd see in VS. 1) When you open a parenthesis '(' or a curly brace '{' it automatically closes it for you. 2) Spell checking for comments. - BFree
(3) VS does actually have #1, kind of. it's called snippets. Type "class" then hit tab twice. Or type "for" and hit tab twice. - Mystere Man
(5) Try NetBeans, it's much nicer experience than Eclipse. - cdmckay
(3) @quant_dev: Although I prefer coding C# over Java, Eclipse doesn't suck! It has excellent code assist and refactoring support, something that VS still currently lack unless you have CodeRush or Resharper. - Spoike
@Mystere Man: I use snippets all the time, and trust me, I love it. I've created quite a few of my own. It's just when you're calling a method for example, and you want to pass in params, when you start typing "MyMethod(" Eclipse automatically closes it for you, VS doesn't. - BFree
(1) Mine are 1) CTRL+SHIFT+R - Find resource/class and 2) CTRL+O - goto member. They are adding #1 to VS2010, not sure about #2 though. - Richard Szalay
10
[+14] [2009-02-27 22:41:31] Adam Smith

I am an anti-Microsoft guy, and I have recently gotten quite interested in .NET and C#, so they must be doing something right ;-)

A couple of things have caught my attention. Just seeing what the guys making the Unity3D [1] engine managed to get out of using Mono [2], convinced me that Mono is not a second class product. OK, .NET is still better but Mono is good enough for real commercial usage.

Secondly, C# has grown to quite a respectful language. Especially with all the concepts from functional programming being added like type inference, lambda functions, LINQ [3], etc. it has become quite powerful.

I am a Mac user, but now I am considering embedding Mono in my applications and using it as a script language, like Unity3D. I think that gives some really cool opportunities.

[1] http://en.wikipedia.org/wiki/Unity_%28game_engine%29
[2] http://en.wikipedia.org/wiki/Mono_%28software%29
[3] http://en.wikipedia.org/wiki/Language_Integrated_Query

Yeah, I'm an anti-M$ guy from way back, I've always been a bit skeptical only because I can't be guaranteed that I can port my applications to some other platform other than windows. But other than that everything else I've read here about C# sounds really great, and I'm starting to lose my initial skepticism about the language. How good is the support for exporting an application into Mono in your experience? - leeand00
Not sure what you ask. But I answer based on guess ;-) My impression is that to be certain of being cross platform it is best to actually stick with mono as the runtime on both Linux and Windows and target Mono rather MS .NET. - Adam Smith
Given that .NET has a more mature IDE and better support, if your first project targets windows, you should use .NET; but get a hold of unsupported .net namespaces from the Mono website and decide how to architect such pieces or even avoid them altogether in case you have to migrate in future. - Pita.O
+1 So true about Unity3D showing that Mono isn't a second class product -- my thoughts exactly. - Nick Wiggill
11
[+11] [2009-02-22 23:57:21] seanb

C# behaves like I always wanted Java to behave.

It generally "feels" like I write less code to achieve the same outcome than the equivalent in Java. Java seems to force you to be "enterprisey", C# just gives you the option (totally subjective "vibe" based opinion).

Cross-platform is a non issue for me, there are enough Windows machines out there to make a living writing for Windows, one day, that may change, but probably not this year.


12
[+10] [2009-02-22 19:29:39] Kibbee

Suddenly? It hasn't suddenly become popular. I don't know where you have been, but it's been pretty steadily gaining momentum for quite a few years. You may be hearing a lot of buzz about it, because they are introducing a lot of new features to the language, whereas languages like Java have been pretty stagnant in the feature department for the last few years.


@Kibbee see my comment for Brian Rasmussen. - leeand00
13
[+8] [2009-02-22 22:54:03] ShuggyCoUk

Specifically answering the question "There's been like a repeat explosion in the blogs lately about it".

Microsoft have added a significant language change in each major release rather than just the addition of new libraries (only including the major ones in the list).

  1. 1.0: first release, 2000
  2. 2.0: Generics, generators and lexical closures added 2005
  3. 3.0: Lambdas (and expressions though most coders don't use that directly) that allow Linq in 2007
  4. 4.0: Dynamic programming planned for 2010

This change causes changes in the preferred way to do things, the idioms of the language need reinterpretation or complete redefinition. This generates a rich source of content for discussion.

It helps that in the same time frame of C# [1] and the .NET [2] platform's public life Microsoft has become considerably more supportive of blogging within the organisation to the extent that they host them and provide a means for teams rather than individuals (who may not be able to sustain such an effort on their own) to provide one.

The discussion of why C# is popular has been dealt with in many other questions and restated here too.

[1] http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29
[2] http://en.wikipedia.org/wiki/.NET_Framework

14
[+8] [2009-02-23 18:01:18] user69878

Re: Java vs C#

C# has the advantage of being released after Java and thus the designers were able to improve upon Java's syntax and libraries. And I think Java had the disadvantage of early widespread adoption, which made it harder to evolve the language early on.

I like C# because I think it has a very practical set of features in comparison. For example, C# has properties, which you could say are "syntactic sugar" for basic getter/setters. But you can use them to semantically separate get/set operations from other methods. And you can do this with one line of code in 3.5.

Also in C#: string.IsNullOrEmpty(string s)

When I do work with Java, it seems like I need to have giant books on my desk to be able to do really basic things. I don't mean to say C# is better than Java. You can definitely do amazing things with Java and the time I got to use WebMethods, I loved it. However, I think C# is nicer to work with. Perhaps the recent surge in popularity (if it exists) is due to people switching over and liking it (the iPhone effect). Also, the C# language is moving in a pretty exciting direction (for geeks).

NB: I do not work in situations where cross-platform is needed.


(4) And what's the excuse of Java not to improve even if they released several versions after C#? (Well they did improved, here and there, but those attempts are shy compared to what C# did every version) - Pop Catalin
15
[+6] [2009-02-22 19:38:30] Giovanni Galbo

Wasn't Java "corporate driven" until very recently, if I'm not mistaken?

Also, (lets forget about Mono just for a minute), multi-platform just doesn't matter to a lot of people.

As for why its so popular; he language looks like c++ and java (so less learning curve), the library is awesome and Visual Studio is considered the best IDE by many people.


(4) And the language has pointers, mind you. Java locks you into a safe pointer-less world. C# lets you delve down to that level if you see so fit. - Jonathan C Dickinson
(2) So pointers are there if you need them, but if you don't, you're not forced to use them either? Hmm that does sound pretty good. - leeand00
16
[+4] [2009-02-22 20:48:44] Tamas Czinege

The thing is that the parts of the .NET Framework that are not cross-platform (such as WPF, System.Management namespace, etc.) are usually things that you couldn't get with Java anyway. There aren't many things in the .NET Framework that are not supported by Mono but a similar concept exists in Java/JRE.


(1) WPF isn't intrinsically tied to Windows. Just hasn't been implemented elsewhere ;) - TraumaPony
TraumaPony: True, what I've meant by not being cross-platform is "not being implemented on other platforms" - Tamas Czinege
17
[+4] [2009-02-22 22:52:36] jimi hendrix

I like C# a LOT more than Java. It feels more natural to me and has more features. Also, I find the GUI classes' names to be more logical (pane... Swing [1]?)

And I kind of liked Visual Studio [2]/C#, and I love XNA [3].

[1] http://en.wikipedia.org/wiki/Swing_%28Java%29
[2] http://en.wikipedia.org/wiki/Microsoft_Visual_Studio
[3] http://en.wikipedia.org/wiki/Microsoft_XNA

18
[+3] [2009-02-22 19:39:29] dsimcha

It's popular because it's just like Java, except evolving and adding useful features at a pace faster than the utterly glacial pace of Java. This means you get most of the advantages of Java, such as a good VM, tons of libraries, the backing of a large corporation, etc., and the same general feel of the language. However, you don't have to deal with lack of properties, closures, and just about every other modern feature that Java eschews.


c# never had a VM. It's always been jitted. - SnOrfus
(2) You can be jitted and have a VM. VM does not mean "interpreted". Java was created to be Interpreted, and a VM, .NET was created to be compiled and have a VM - Mystere Man
@SnOrfus. You should read up on what a VM is. C# has a JITting VM, which is (after the first, say, 2 minutes) superior in every way to the interpreting Java VM. And Java doesn't have IL emit. - Jonathan C Dickinson
(2) almost every currently available non academic java VM is Jitted. - ShuggyCoUk
(2) Yes, please remember folks that Java has JIT compilation too. Let's keep our facts straight. - Randolpho
@Jonathan C Dickinson, do you have a link to any benchmarks that compare the most recent VMs? - Hosam Aly
19
[+3] [2009-05-12 20:45:23] Garrett

Reasons for C#'s popularity:

  • backing by major corporation
  • easier app development, as compared to C++/MFC, for eg
  • flat learning curve (coming from language like C++ or Java)
  • lots of language constructs that s/w devs like
  • continuing support by MS of language
  • popularity often begets more popularity (of anything, incl language)

20
[+3] [2009-05-12 20:59:41] Cuga

I have about equal parts experience in Java and C#. I will say that for anyone who wants to pick up a language, C# generally is easier. That, taken with many of the reasons listed above will account some of the perception noted.

As for the rest, I feel that the Stack Overflow community is one that is slightly more favorful towards .NET [1] than Java. This likely contributes to much of your perception as well. At this moment, these are the counts of questions listed as "new" on Stack Overflow with the following tags:

  • C#: 20,902
  • Java: 10,881
[1] http://en.wikipedia.org/wiki/.NET_Framework

I also do both but get continuously frustrated that I have to implement some helper or utility in Java that just works in .Net - I don't want to waste my time writing boilerplate code, I want to be working on the interesting problems I get paid to solve. - Basic
21
[+2] [2009-02-22 23:02:42] Gregory A Beamer

Why is C# suddenly popular? If you think suddenly means for the past few years, then I guess it is rather sudden. Considering we did not have a release of C# (.NET) until 2002, that is not surprising, however.

Despite Mike's comment, Visual Studio is considered a good UI, but the IDE is not the main reason someone picks a language. The fact Microsoft is pushing C# (and has been) and the fact that there are many Microsoft shops in the United States helps the popularity.

The fact that C# is cross platform (with Mono [1]) probably helps some, but the LAMP [2] stack is far more popular on Linux, so I don't think this is a very good reason for the popularity of C#.

[1] http://en.wikipedia.org/wiki/Mono_%28software%29
[2] http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29

22
[+2] [2009-02-22 23:11:11] billfredtom

I think it's the way Microsoft has nurtured the developer community personally - ever since Steve Ballmer [1] shouted out "developers developers developers!!!". They're working hard to get followers, and in a lot of cases it's working. In aus - the user groups are great, and Microsoft (until recently because of budget cuts) even paid for free food and drink - gave away prizes, etc. It all might sound like a bit of who-ha, but it's working to a certain degree.

[1] http://en.wikipedia.org/wiki/Steve_Ballmer

>> It might sound like a bit of who-ha. Let's face it, the same corporate strategy that drives the plan to bring food to community meetings would drive a determination to go beyond throwing features into the SDK and actually investing into the right developer experience built around that feature. Microsoft invests heavily on dev tools user experience and it pays off in followership. Until recently, one of the founders of Java was quoted as saying something to the effect that Intellisense is non-hardcore devs. How can you win with that?! - Pita.O
23
[+1] [2009-02-22 19:40:03] Nick

In my opinion, its the gaming aspect of it. Using C# with XNA, I can without a ton of effort start geeking out some games that'll run on an X-box or my PC. I've tried game programming before using C++ and OpenGL and it required a lot of heavy lifting (my back still hurts). Other than that, I think its just preference. Both Java and C# help push each other along, I know the object for loop was a C# thing that Java incorporated. So for me at least, in the game programming realm I love C#, but at work, I"m a Java guy.


24
[+1] [2009-02-22 20:36:58] codemeit

MS has made some good frameworks for C#.On top of the frameworkds, you can build different applications EASILY from frontend to backend.

C#'s syntax combined Java and other C alike languages so that it is easy for programmers to jump on.


Not only that, their frameworks are easily implemented through VS. Want to set up a web service in C#? No problem. Want to do one in Java? You'll prob need a plugin first, and then you'll have to read some specs. - Cuga
25
[+1] [2009-04-23 12:12:13] Andrew Corkery

Because it's an elegant, mature language that lends itself well to object-oriented programming. It is also the defacto choice for new developers working within the .NET framework and this has seen a big growth in the last few years. I quite like Java, but Sun have never really focused on providing a next-generation web development platform like ASP.NET (especially MVC). Because more and more apps are going online now, I think Java is losing ground here.

And I also would say 'hats off' to Microsoft for recognising the best parts of Java and incorporating them into C#, rather than re-inventing the wheel (badly)!


26
[+1] [2012-02-22 13:47:33] MajesticRa

The time has come to mention the new async methodology [1] and other new features [2] in the upcoming C# 4.5. While Java 7 showed a very unobtrusive update list [3].

[1] http://reedcopsey.com/2010/10/28/c-5-async-part-1-simplifying-asynchrony-that-for-which-we-await/
[2] http://stackoverflow.com/questions/4135010/what-is-c-sharp-5-and-where-does-it-come-from
[3] http://www.eclipse.org/jdt/ui/r3_8/Java7news/whats-new-java-7.html

27
[0] [2009-02-22 23:13:51] Eduardo León

In my opinion, C# is popular because it is as easy as VB and more powerful than Java. If you think of a Java as a reaction to C++, C# is a better reaction to C++ because it didn't strip almost any features from the language, but did them right (for example, operator overloading). The only thing I really miss when I code in C# is using const and mutable to enforce logical const-correctness.


28
[0] [2009-06-15 03:23:17] Felix Guerrero

I think C# is a respectable language since it has come up in the world. Java is a great language but has the same situation as C# with respect to its future because both languages are controlled by very-closed corporations (SUN&MS).

Open sources languages are growing up nowadays, maybe in the future there will be an open C# controlled by the community and running over mono.


java is almost open source: sun.com/software/opensource/java - Ray Tayek
29
[0] [2012-04-13 07:39:23] Kiril Rusev

In addition to the other benefits listed above, one key difference between Java and C# is the amount of examples and support you can get. It is fantastic!


30
[-4] [2010-05-10 02:14:10] Ray Tayek

It's had slow growth and is approaching C++ now. See C, C++, C#, Java, Ruby, PHP, JavaScript job trends [1].

Also, see TIOBE Programming Community Index for May 2010 [2].

[1] http://www.indeed.com/jobtrends?q=c,%20c%2b%2b,%20%20c#,%20%20java,%20ruby,%20%20php,%20%20javascript&l=
[2] http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

31