9 ms·
What factors led to the development of C# in spite of Java
- mrcsparker 14y agoFrom what I remember, it was one main thing: delegates From Sun: http://java.sun.com/docs/white/delegates.html http://java.sun.com/docs/white/delegates.html
- soc88 14y agoSeeing how Java tries to play catch up currently, this reads down-right bizarre. :-)
- densh 14y agoWow, they really thought that inner classes were an elegant and supreme solution. That strikes me as a really weird aesthetics attitude. Inner classes always felt like an accidental misfeature which everyone regretted about but couldn't remove it due to backwards compatibility.
- deleted 14y ago[deleted]
- tikhonj 14y agoFundamentally, Java and C# are extremely similar. What's interesting is how different their philosophies are: Java really values backwards compatibility, does not evolve very fast and tries to hide and features that could cause a programmer to shoot himself in the foot. C#, on the other hand, has had some compatibility breaking changes, has evolved quickly with fancy research features (e.g. Linq is actually much like a monad with SelectMany as bind) and has a bunch of "dangerous" features like operator overloading and unsafe regions. EDIT: Maybe there weren't actually any language changes breaking backwards compatibility. I'm not sure. I personally like C#'s philosophy better: PL research exists for a reason and newer features make coding easier; moreover, I can avoid doing really stupid things and so can be trusted with operator overloading! Others maintain the opposite and believe Java's more conservative approach is best. It would be nice to compare how the two philosophies fare in getting their respective languages adapted, but I fear such a comparison would be flawed: C# is much too tied to Microsoft, so most people not keen on heavy coupling with any particular vendor or OS tend to avoid it for that reason. The opposite is also true: heavy MS shops are much more likely to choose C# just because it's part of .NET, and not because of the language characteristics. Still, it is very interesting to see what has happened given two virtually identical languages with different backers and philosophies.
- statictype 14y agoI'm curious: What are the breakages in backwards compatibility that C# introduced? The only one I can think of is the upcoming change in closure semantics for loop variables - something that is being changed to make it work like people would expect for 99% of the case and risks breaking that 1% of cases where someone actually wants the same loop variable to be closed over in all functions defined within the loop. (e.g. Linq is actually much like a monad with SelectMany as bind) Correct me if I'm wrong but I believe, with SelectMany, Linq does in fact, provide everything required to support monads. Agree with everything else you said - especially on flawed comparisons between the two languages.
- noblethrasher 14y agoInterestingly, named parameters introduced a kind of breaking change: http://blogs.msdn.com/b/ericlippert/archive/2011/11/07/breaking-changes-and-named-arguments.aspx http://blogs.msdn.com/b/ericlippert/archive/2011/11/07/break...
- deleted 14y ago[deleted]
- tikhonj 14y agoI'm not actually intimately familiar with C#. I remember reading about some of the changes between major .NET version (e.g. 2 to 3) which did not maintain backwards compatibility. However, on review, that may have been backwards compatibility of the bytecode rather than the language proper, in which case I am mistaken. It would be great if somebody who knows one way or the other for sure chimed in.
- josteink 14y agoC#3 adds features not found in C#2 (just as C#2 added features not found in C#1). However the C# compiler will produce bytecode compatible with the .NET 2.0 runtime from C#3-code. And all C#2 code will compile just fine with the C#3 compiler. Basically what breaks is trying to shove C#3 code through a C# 2 compiler, and that can hardly be said to surprise anyone. The part which may be confusing is that unlike Java and the JVM, C# is tied to CLR runtimes, and you can have several installed at the same time. C#1 was tied to the .NET 1.x runtime. C#2 was tied to the .NET 2.x runtime (which also powered .NET 3.0 and .NET 3.5). C#3 was tied to the .NET 2.x runtime with some extra LInQ DLLs installed (aka .NET 3.5). C#4 (which again adds more features) depends on the .NET 4.x runtime. And all these runtimes can be installed at the same time. The fact that Microsoft is willing to "leave old runtimes behind" and create new ones when the language features being requested requires it means they can iterate much faster than the Java can, since backwards bytecode compatibility is not required. I think it is a decision which has worked out largely to their advantage.
- itsboring 14y agoNot relevant to the question, but: Some of the comments in that thread illustrate a widespread misconception that C# isn't cross-platform. We're finishing up a game that runs on windows, osx, ios, and android, with a server on linux; and it's written in C#. Microsoft's CLR and BCL implementation aren't cross-platform, but I haven't used those in quite some time.
- tikhonj 14y agoWhile C# is cross-platform, almost everybody using it seems to be on Windows. Also, a bunch of the libraries people normally use with C# are Windows-specific (like WPF, I guess. Does anybody still use WPF?). Also, Microsoft has some patents which put projects like Mono in a potentially poor situation, which is why it isn't entirely embraced by the free software world. Java, on the other hand, is, for better or worse, used heavily on all the different platforms. Moreover, most Java libraries (like Swing. Does anybody still use Swing?) are cross-platform. I find F# a much more interesting language than C#. Do you know how F# behaves on Linux? While I've heard of people using C# on Linux and Android, I haven't heard anything about F#. Then again, the Linux people might just prefer OCaml.
- danieldk 14y agoFor standardized (and some other parts) of .NET/C#, Microsoft provided a patent license: http://www.mono-project.com/Licensing#Patents http://www.mono-project.com/Licensing#Patents
- itsboring 14y agoI would, of course, agree that the majority of C# developers are on Windows (this seems natural). However, I think mono is in wider use than people think because of the fact that it's embedded in products like Unity. It's often not very obvious. WPF was a definite non-starter for mono. Just too huge of an undertaking; much more focus on GTK#. Sometimes it's easier to bring something else to Windows than to bring Windows to everything else. In the case of WPF, it seems like not bothering was probably the correct move... My understanding is that F# works just fine on linux and mac, but I haven't had the opportunity yet. Quite interested in this as well.
- shmerl 14y agoMostly political reasons it seems. Java was always encumbered with patents and licensing restrictions especially for mobile usage, which came out the ugly way as we know with the latest Oracle's lawsuit. Even though Oracle didn't succeed, but nevertheless there was always a risk. I guess Microsoft didn't want to depend on that, but on the other hand wanted to leverage familiarity with Java to lure Java developers into using C#. Rather boring and uninspiring move (creating a close clone), but Sun can be partially blamed for not making Java truly free (like C++ for example).
- mariusmg 14y agoPolitics between SUN and MS was the main reason. But the low quality (and by that i mean things like doing value type allocations in the heap, shitty libraries for UI (Swing), the language not having common sense features such as delegates/properties etc) implementation of the JVM was another.
- thebluesky 14y agoThere are many reason's it made sense for MS to create their own Java-like system, but the "low quality" of the JVM implementations is not one of them. The JVM implementations (HotSpot, IBM J9) are more efficient than the CLR in virtually any sensible benchmark you care to run and it's been that way since about December 1998. e.g. http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=csharp&lang2=java http://shootout.alioth.debian.org/u64q/benchmark.php?test=al...
- noblethrasher 14y agoThat shootout is between the JVM and Mono. The CLR outperforms Mono. That being said, my understanding is that JVM programs slightly outperform CLR programs in terms of speed while CLR programs do better than those on the JVM(s) in terms of memory.
- igouy 14y agohttp://shootout.alioth.debian.org/demo/compare.php?lang=csc http://shootout.alioth.debian.org/demo/compare.php?lang=csc
- dvhh 14y agothe benchmark is pretty much irrelevant, because if it was we would all be coding in C or Fortran, or why not machine code or assembly ? On the other hand I find that the mono project (young, open source implementation ), is doing quite great against java 7 (commercial implementation, unless I misread). It would be interesting to see how the openJDK is performing ? (the real question would be : is openJDK crippled compared to the Oracle - JDK ?)
- strictfp 14y agoAnother very interesting question closed as off-topic.
- angry-hacker 14y agoWhy interesting questions are getting closed all the time on Stackoverflow? It's not THAT off-topic and everyone are interested in it, what harm does it do that it needs to be closed... Edit: Ok, now they deleted whole thing instead... because someone pointed out that it shouldn't been closed...
- arikrak 14y agoThey deleted it, but it can still be seen in Google's cache. Someone needs to tell Wikipedia and StackOverflow that they're going a bit overboard with all this deleting. Why don't they just demote stuff to show lower down in searches or something? http://webcache.googleusercontent.com/search?q=cache:mdxfQ2k_-ecJ:stackoverflow.com/questions/3979679/what-factors-led-to-the-development-of-c-sharp-in-spite-of-java+&cd=1&hl=en&ct=clnk&gl=us http://webcache.googleusercontent.com/search?q=cache:mdxfQ2k...
- tzs 14y agoOne factor is that Microsoft wanted a programming language with Java's language features that could be used to write Windows programs. Sun was adamantly against the notion of people writing Windows programs in Java (or Unix programs in Java, or Mac programs in Java). Java programs were supposed to be for the Java platform.