
C# is now a better language than Java - fogus
http://brizzled.clapper.org/id/93
======
smakz
I guess I'll be the lone dissenting opinion and actually favor Java over C#.

Java has an extensive library of open source software, which makes it, as they
say, more of a platform then a language. From hadoop, to tomcat, to jetty, to
hibernate, to spring, to c3p0 (and many, many, many more), you have all the
tools you'll ever need to do 95% of the coding work.

I definitely get the love around here for dynamically typed languages, but
I've never been sufficiently motivated to switch to ruby. The whole philosophy
of ruby, "convention over configuration" is applicable to ANY language,
including Java. Java's EJB spec was monstrous and XML config file infested,
but I've gone through many projects in Java without a single XML config file
and following the philosophy of convention over configuration, and it's been
great.

As to .NET, I would never use it. Never want to get in the business of paying
for licenses, not just .NET, but it ties you to Windows server boxes and
Windows development boxes.

~~~
joechung
The article made a point of distinguishing the comparison between Java and C#
as languages, not between Java and .NET as platforms.

~~~
abalashov
Be that as it may, that seems like an awfully artificial cop-out.

"Oracle's the best database ever!"

"It costs half a million dollars!"

"I made a specific point of distinguishing its technological merits as a
relational database backend, not the dollars involved in purchasing it."

~~~
stcredzero
There's a lot of contexts where cost/benefit is not so much a cop-out as it is
a more relevant point! (Not an Oracle advocate by any means!)

~~~
abalashov
I agree. I meant that it is not an effective reply to its parent.

------
fogus
It's fashionable to say that Java is painful to use, and there is truth to the
statement. However, when I started with it I had come off of a few years of
C++ and loved that it reduced my pain exponentially. Like the new lover's
quirky laugh, the 'nuances' of Java became annoying. It almost seemed as if
with Java there is a threshold of productivity that the language itself
imposes. I have since moved on to Scala/Clojure and again feel renewed. Maybe
that is the natural progression of programming languages?

~~~
icey
I see C# as a linear improvement on Java. In my eyes, it looks like this:

C++ --> Java --> C#

~~~
shin_lao
C++ has got nothing to do with neither Java nor C#.

~~~
DrJokepu
The C# ECMA Standard ( [http://www.ecma-
international.org/publications/files/ECMA-ST...](http://www.ecma-
international.org/publications/files/ECMA-ST/Ecma-334.pdf) ) mentions it
several times that one of the main design goals of the C# language was
familiarity to C++ programmers. Indeed C# borrowed a considerable portion of
its syntax and keywords from C and C++. I suppose the same is true for Java as
well.

~~~
berntb
The C# standards only mentions C/C++ and not Java?!

>>Indeed C# borrowed a considerable portion of its syntax and keywords from C
and C++. I suppose the same is true for Java as well.

It seems really weird to me when you sound like C# was an independent
development? I'm not an expert on either, but...

Didn't Microsoft even try some (/a few?) Java-clone before C#? And then we
have that "embrace and extend Java" thing Microsoft tried first.

Is the ... hrm, inspiration... from Java in C# "the love that dare not speak
its name"? :-)

~~~
ido
> Didn't Microsoft even try some (/a few?) Java-clone before C#?

J#[1]? J++[2]?

[1] <http://en.wikipedia.org/wiki/J_Sharp>

[2] <http://en.wikipedia.org/wiki/Visual_J%2B%2B>

~~~
berntb
Thanks! Next time I'll just check this document linked from the J++ 'pedia
page myself before asking.

[http://www.ecis.eu/documents/Finalversion_Consumerchoicepape...](http://www.ecis.eu/documents/Finalversion_Consumerchoicepaper.pdf)

Page 16: _Kill cross-platform Java by grow[ing] the polluted Java market._
(Microsoft internal document.)

Etc etc, with references.

This document could be posted as a story on HN, if anyone wants lots of karma.
:-)

We can say one thing for certain -- the "love" here is criminal and violent...

------
mahmud
The SLW in me thinks: "Don't choose a language for its features, choose a
language for its feature _building_ capabilities".

It reminds me of people who buy stackable shelves and drawers to store their
crap and make some room. Sometime later, they buy vacuum-sealable bags to
store things that they bought after they made some space. As time passes, they
start digging for a new basement and add another floor as an attic to store
more things.

Java vs C# programming sounds a lot like two hoarders of the kind described
above, except one has enough room behind his La-Z Boy to recline to 120
degrees, while the other only gets to 100.

~~~
jrockway
Indeed. Java and C# are some of the least flexible programming languages
around. The problem, though, is that people like being told what to do. They
don't want to wonder if they are implementing something correctly, they want
to know that they are "following best practice". They don't want to invent
their own features, they want to read a cool blog post about something "the
experts" came up with and then try using that in their application.

This produces horrible code, of course, but since it sort of works and nobody
knows any better, it's the norm. (Most programmers don't know programming. Why
they want to be a programmer is beyond me, but it happens.)

The people that have a deep understanding of programming and know what they
want to do and how to do it are not using Java or C#.

~~~
nollidge
C#'s got lambdas, closures, generics, reflection, extension methods (weak form
of monkey-patching), and anonymous types (I can't speak to Java, but it's got
a lot of these as well). Can you please describe the flexible features C# is
missing?

As for the programmers in those languages, I guess I'm one counterexample. My
colleauges and I talk quite a bit about the "right way" to do things. We gripe
a great deal about shortcomings in the .NET universe. I hate "best practices"
(aside from trivialities like naming conventions), and prefer to evaluate
practices on their merits. I've written frameworks of various sizes. I read
cool blog posts to see what others are doing. Occasionally I'll try things to
see if they'll work, not because some "expert" thought of it.

So, I'm at least one counter-example, and I know of numerous intelligent and
erudite friends and bloggers who also fit this description. I wonder if you
can perhaps provide some examples to support your claim that Java and C#
programmers have no depth of understanding?

------
DanielStraight
Java is painful after experiencing .NET. I'm not sure this is really news
though.

~~~
habs
I wouldn't describe it as painful myself. But, I would agree with sentiment.
Having spent 3+yrs working with Java and then moving to C# (2yrs+ dev) has
been a pleasant experience. C# is great language with features like delegates,
Indexers, Pointers and Unsafe Code (executed in an unsafe context) and
constraints on type parameters.

In contrast, I hate the msdn documentation for C# and still have a soft spot
for java documentation.And yes, C# v Java is not the same as JVM v CLR

~~~
lunchbox
_I hate the msdn documentation for C#_

Not sure if this is addresses your complaint, but MSDN's low-bandwidth
formatted site makes it easier to work with.

Example: [http://msdn.microsoft.com/en-
us/library/system.xml.xmlreader...](http://msdn.microsoft.com/en-
us/library/system.xml.xmlreader%28loband%29.aspx)

Here's a link to a bookmarklet you can use to turn loband on:
[http://weblogs.asp.net/jgalloway/archive/2008/08/30/msdn-
low...](http://weblogs.asp.net/jgalloway/archive/2008/08/30/msdn-low-
bandwidth-bookmarklet.aspx)

~~~
chaostheory
I think another thing I really hate about C# documentation is that it's merged
with docs for other languages like VB.NET. It's a small thing but when I need
to do something, I really don't want to be wasting time constantly filtering
through stuff I don't need.

~~~
Rexxar
There is a language filter in order to display only language we want to see
(in the standard version, not the low bandwidth one).

~~~
chaostheory
Thanks Rexxar - you've made my life easier. For some reason I've never noticed
it before. Maybe it's because I use Firefox and the filter button looks really
small on it.

------
chaostheory
Nothing new here. I've been working with both for years and I agree.

There is one thing that Java still has though, that I somehow doubt C# will
have due to culture. Java has way more free or open source libraries. Yes, C#
open source has gotten a little better over the years, but it's still not even
close (it doesn't help that historically MS has been antagonistic towards open
source even within its own products). What does this mean? With C# I have to
keep re-inventing a ton of wheels, as opposed to Java where there are already
thousands of existing well made ones for me to just grab and use.

~~~
Caligula
I was a c# dev a year ago and whenever I looked for open source packages to
address some requirement, I would always end up at codeproject. It always
tended to be poor quality, never updated, etc.. Java has so much more but
maybe things have changed over the last year.

~~~
chaostheory
I doubt the culture will change unless MS shifts its attitude towards open
source even more (which is really doubtful). Until then, most people will only
release quality stuff on a paid restricted commercial license.

------
voidpointer
So if the JVM beats CLR but C# beats Java, why isn't there a C# compiler for
the JVM?

I suspect that all language features of C# should be expressible in Java
bytecode, but I have not thought about the details yet. If you know of
anything in C# that would be unimplementable in terms of Java bytecode it
would be interesting to hear about that.

~~~
rcoder
Java bytecode is Turing-complete, so there's nothing explicitly preventing you
from implementing many of the advanced features of C# atop the JVM. As the OP
stated, alternate languages running on the JVM (such as Scala) already do
this.

The problem is simply that most Java shops use only the officially-blessed
Java language. Because Sun has always forced "certified" implementations of
the language and platform to conform to their standard, there has been little
room for innovation in the source syntax and bytecode format since the release
of the first JDK in 1996. In the meantime, programming languages (and the
programmers who use them) have moved forward, and Java has failed to keep up.

------
kashif
Yes C# is an improvement over Java. But, that isnt saying much with the
plethora of cutting edge languages available today.

I still prefer Java, because C# is limited to the Windows environment,Mono
isn't much help yet, and that is a huge limitation for me. Especially because
Windows is not conducive to any serious systems programming - its ugly.

Another reason in favour of Java is the better open-source eco-system, more
libraries and much more mature stuff.

C# has had the benefit that all new products/techs have - it leapfrogged.

------
francoisdevlin
Excellent writeup, and he nails the fact that C# vs. Java is not the same as
CLR vs. JVM.

~~~
solutionyogi
Interesting. I don't think it's right to discount the CLR and focus on the
language whereas the fact is that C# can not do certain things without support
from CLR. [In fact, for each C# feature, I like to know whether it's a
compiler trick or CLR feature.]

The biggest example I can think of is 'generics'. Java 'generics' are
implemented using the compiler and JVM has no clue about them whereas CLR
actually understands them and you get full reflection support for generic
classes. Read this detailed article on Generics in Java vs C#:

[http://www.jprl.com/Blog/archive/development/2007/Aug-31.htm...](http://www.jprl.com/Blog/archive/development/2007/Aug-31.html)

I also like the utility of AppDomains supported by CLR.

Overall, I love .NET platform precisely because how all the modules (CLR,
languages) are integrated with each other to give you a powerful tool set.

Other than JVM being portable, I don't know of a single case where JVM is
superior to CLR. [Performance wise there is not a measurable difference
between the two.]

~~~
snprbob86
There is no reason why you can't implement a C# compiler which uses the same
compiler "tricks" as Java. In fact, someone has:
<http://www2.mainsoft.com/content/port-net-apps-java-ee> (I've never used that
software and can't say if it really works as promised, but I don't see why
not)

Which side of the fence the compiler/runtime fence any given feature fails on
is probably more a function of (human) resource pooling on the Microsoft
managed languages teams than any technical constraints.

~~~
solutionyogi
That's COMPLETELY incorrect. I have been following blogs of CLR team and C#
compiler team members and they think very hard about whether a feature needs
to be a compiler feature or in the runtime itself. If they are short on
manpower, they don't implement a feature rather than implementing it at the
wrong level.

~~~
snprbob86
Since you probably haven't been following my comments here on HN: I work at
Microsoft on a very C#-centric team. I have good friends on, and direct
working relationships with, the managed languages teams here at Microsoft.

The "wrong level" corresponds to the goals and direction of the greater
managed languages team. If the C# team wanted to implement every feature
without any regard for the Visual Basic or F# team, they could. Clearly, they
aren't going to do this because it creates wasted effort, inconsistency
between languages, and maintainence complexity. Moreover, implementing on the
wrong level has impact on performance and the developer experience.

I didn't mean to imply that they do the wrong thing because they are short on
man power. On the contrary, they do the _right thing_ because they are short
on manpower.

Everything _could be_ a compiler trick, but that doesn't mean everything
_should be_. The managed languages teams here at Microsoft absolutely kick
ass; they know what they are doing.

------
rbanffy
You know... C# may be less painful than Java, but, still, it took me 8 years
to go through learning C++ after I had learned OOP with Smalltalk and done
some programming with Actor (kind of Smalltalk with an ALGOL-ish flavor). I
closed my first book on C++ seconds after I saw the overloaded binary shift
operator being used to output text.

I see my early contact with Smalltalk made me picky and spoiled. Today, it
makes not much difference if it's C#, Java or C++, they are all painful well
beyond my pain tolerance.

It's like smashing one's toes with hammers of different sizes - I am pretty
sure even a small hammer is painful enough.

------
StrawberryFrog
What do you mean, _now_ ?

 _annotations (though C# calls them "attributes")_

he means "Java added attributes, which C# had from day 1, but called them
"annotations""

 _C# has many of the same features as Java ... generics_

Again, C# had this first, and still does it better since the bytecode is aware
of them.

~~~
adharmad
Java being more widely deployed has to worry about source and binary
compatibilities between all the supported versions and thus for them, changing
the bytecode would have been a painful decision.

As opposed to that C# did not have to worry about these things due to their
limited deploy base and could freely change the language and/or the VM without
worrying about backward compatibility.

That does not mean java is a better language than C# - its just that when Sun
woke up and started adding features to the language, it was not easy.

~~~
cakeface
Actually it does mean that C# is a better language _now_. If you are
developing new applications then all the compromises that were made to shoe
horn in new features don't matter to you. You just want something that works
well and is simple. I think that C# has that on Java in a lot of respects.

~~~
adharmad
No arguments there. But the rate at which C# is changing, what is stopping
Microsoft from adding yet new features and breaking compatibility with
previous language/VMs?

~~~
StrawberryFrog
That's why there are generally several different versions of .Net installed
side-by side.

------
subwindow
He's _just now_ realizing that Java is painful to use? Even PHP had me
dreading the tiny bits of Java work I had to do when I last touched it in
2005.

------
ilitirit
Language wise C# was than Java from day 1, but the C# toolset and build model
are why I prefer C# over Java.

I have never had to spend ages trying track down a "class not found" error in
C#. Nor have I had to deal with version clashes between libraries. And I might
be biased because I develop mainly on Windows, but I think Visual Studio is a
better IDE than Netbeans, Eclipse, IntelliJ or JDeveloper.

~~~
kashif
Really Visual studio is better than Intellij/Eclipse?!?

I can tell that you havent done enough programming in the Java world. Have you
ever tried any serious refactoring or bothered analyzing your code. I didnt
think so, you would have realized why visual studio sucks..

BTW, I program in both C# and Java all the time. Actually, I do about 70% C#
and 30% Java. So your claims are crap.

~~~
Caligula
I would not call all his claims crap. I disagree with his libraries statement
but agree that visual studios is better than netbeans or eclipse.

I have used c# in vs.net for years up until a year ago and am stuck using
eclipse now. I miss vs.net, not so much c#.

~~~
kashif
Hmm...try Intellij Idea and I think you might get over VS. Eclipse is a bit
clumsy but really powerful. VS is basically a text editor with intellisense.

------
geebee
A good article, but I think the last line is the most revealing...

"compared to C# and Scala, it (Java) is almost painful to use..."

I think most of the Java community realizes incremental improvements to Java
are at the point of severely diminishing returns, and Scala seems to be the
next phase (I've heard people jokingly refer to Scala as Java 1.9... of
course, this really isn't accurate, but it does capture what's going on in the
Java world right now).

So in the future, I'm going to be a lot more interested in hearing how Ruby
and especally Scala stack up vs C#...

------
zmimon
It's sad, but this isn't really an interesting argument any more these days.
Even as a staunch java supporter, I wouldn't try to argue Java is in and of
itself as good as C#. I'm more interested in how the 2nd generation JVM
languages (Scala, Groovy, etc) compare with C# or the other options on .NET,
and on the pros and cons of the whole platform and ecosystem.

For my money, no matter how good C# is, I'm not willing to be tied to an
environment where the only full, modern implementation is tied to a single
platform.

------
adharmad
A thing that I have wondered about: Although Java and C# are similar languages
with very similar libraries and features, Java has migrated towards being used
for server side and middleware programming. C# however has not gone in this
direction even on Windows platforms. What is the reason? Wouldn't it be easy
to write the equivalent of Tomcat, JBoss, EJB's etc. in pure C#?

It is surprising that some of the apache projects have .NET equivalents
(lucene, log4j, ant) but some others dont........

~~~
vetinari
Windows shops are vary of writing functionality, that might one day compete
with Microsoft. Writing net Tomcat/JBoss could clash with IIS and future
frameworks. Something like this happened with nant/msbuild and nunit/mstest.
Commercial companies find it difficult to justify development of tools with
high risk of being obsolete soon (something competing with MS product does not
stand a chance in most Windows shops). Apache projects do not care about this
risk.

------
tumult
C# is awesome because in a situation where you are using C#, there's a good
chance you could use F# instead.

------
ramoq
I've always preferred Java to several languages (could be JVM influenced). I
would still rather hack up an idea using Java vs C# or many other languages.

~~~
umjames
What are the other languages that you prefer Java over?

~~~
ramoq
C#, Visual Basic, Ruby to name a few...

~~~
scythe
I guess I can understand the first two, but you'd take Java over Ruby? Really?

~~~
umjames
I agree about Ruby not belonging on that list. If anything my learning of Ruby
(and then Rails) soured any remaining interest I had in Java development.

I'd really be interested to know why ramoq thinks Ruby is less suitable than
Java.

I'll tell you one thing that absolutely stinks about Java: no collection
literals. For all the time one spends in Java (and most other languages)
dealing with arrays, lists, and maps, I always have to instantiate an object
and manually add the elements to the collection. Heaven forbid you decide to
nest one collection in another.

------
angstrom
I could tell the tipping point when I did a recent search for jobs. Even NYC
which is still heavily Java is shifting to C#/WPF for client front ends.

~~~
icefox
And on the backend?

~~~
angstrom
C\C++\Java backends mostly.

------
tybris
The problem with language features is that people will actually use them. Much
better for maintenance to have consistent code. Except for inner-classes, you
always know what to expect when opening a Java file. Java's not as elegant as
Eiffel or some of the functional languages, but its simplicity has value.

(No, I program mostly in C#)

------
mgrouchy
I am not sure if I feel it is better, but I do like them both quite a bit.

Sometimes I just feel like C# is just a little bit more pliable in a lot of
ways compared to Java, just a little easier to make it do what you want it to
do.

~~~
kashif
Windows usually undoes that benefit really fast...

~~~
mgrouchy
you could use mono....?

~~~
shimi
I wish Mono would be even half as good as the .NET, I really do!!

I actually had great hopes for the .NET Compact Framework until the Dalvik
came along...

------
nathanwdavis
This is not new, of course C# is the better language. What is the better
environment is up for debate, but the C# language is better designed,
friendlier, and more feature-packed leading to more concise code.

------
messel
The author has some pretty wide ranging experience. The value I got from the
read is that his preferred coding languages are scala and c# for features he
describes.

Thanks for the share fogus.

------
known
Perl have <http://perldoc.perl.org/perldsc.html>

    
    
        * arrays of arrays
        * hashes of arrays
        * arrays of hashes
        * hashes of hashes
        * more elaborate constructs

------
abalashov
Mono notwithstanding, getting into C# culture and ecosystem isn't really
feasible for pure-UNIX developers like me. Java takes the cake there.

~~~
danbmil99
why not withstand mono? I've worked on two open source projects that used mono
and we've had a great time with it. It's portable, FOSS, runs fast, compiles
(almost) everything, and has a strong and vibrant community.

The JVM is closed source, which is a non-starter for me. Why should I invest
in a proprietary platform that is lagging in features and support?

MS won this battle, get over it

~~~
ekiru
The JVM is GPLed.

------
abrown28
Ook is a better language than Java.

~~~
Quarrelsome
now that's just mean.

~~~
mahmud
If he said "Oak", instead, I would vote him for being a predecessorist;
usually, a bunch of people with better judgment than fadists.

------
eli
I dunno. What's it do that my turning machine with infinitely long tape
doesn't do?

------
danbmil99
"The JVM is robust, mature, fast, and (above all) portable."

mono is damn portable.

------
TweedHeads
Two dinosaurs stepping on each others' eggs.

