
What factors led to the development of C# in spite of Java - ashishgandhi
http://stackoverflow.com/q/3979679/399268
======
tikhonj
Fundamentally, 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
I'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.

~~~
InclinedPlane
The biggest breaking change was from version 1 to 2. Generics were added, as
were partial classes, private setters on properties, and delegates. Along the
way a lot of little breaking changes were also taken on. Things that change
the behavior of the language enough to warrant calling out the incompatibility
from previous versions (if you happened to rely on a particular behavior) but
which generally result in an improvement in the language.

~~~
statictype
Did generics break working code?

I didn't think that was possible.

~~~
InclinedPlane
Not easily. There are a few rare instances where they could cause an error
during compilation of code that compiled fine for .net 1.1, and some problems
with using tlbimp. I don't think it caused previously compiled code to break
though.

------
itsboring
Not 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
While 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.

~~~
rrreese
WPF is used extensively in enterprise. Alternatives are Windows Forms which is
pretty old,and significantly less flexible, or web apps. WPF can host Windows
Forms, so for legacy its a way better option then web.

~~~
computerslol
I use WPF regularly. Initially it seemed quite alien compared to the windows
forms world I was used to. Once I got to know how it works on the inside, I
fell in love with it. In my opinion it is elegant and well thought through.

------
mrcsparker
From what I remember, it was one main thing: delegates

From Sun: <http://java.sun.com/docs/white/delegates.html>

~~~
densh
Wow, 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.

------
arikrak
They 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...](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)

------
strictfp
Another very interesting question closed as off-topic.

------
angry-hacker
Why 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...

------
shmerl
Mostly 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
Politics 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
There 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=al...](http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=csharp&lang2=java)

~~~
noblethrasher
That 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
<http://shootout.alioth.debian.org/demo/compare.php?lang=csc>

------
tzs
One 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.

