
Ask HN : Which should I learn : C# or Java - aniketh
I have been lurking on HN for some time now, and I have noticed that the languages of choice are python, lisp and ruby. However, I would prefer to learn either C# (and thus asp.net) or java. which one would be better? For the record, I have used php a lot, and code in c, c++ on the day job.
======
bdittmer
I think as a language C# is superior to Java. That being said, learn Java. The
open source community alone makes it a much more attractive platform to build
apps on. The number of choices in terms of frameworks + no vendor lock in
makes it a winner. If you're serious about learning it pick up a copy of
Effective Java by Joshua Bloch -- by far the best general Java book out there.

~~~
geuis
Man I know that I'm gonna get burned for saying it, but java isn't all that
it's cracked up to be. I've worked for two companies that are java-based and
both experiences have been horrible. Except for a handful of people, every
java "engineer" I've known has been a siv. The ones that rock happen to just
know java in addition to experience in other languages. Point in case, we are
implementing some new web apis soon. I have been extolling the benefits of
JSON and REST. Friday, the manager/lead java dude that is in charge of our 10+
engineers and making critical technology decisions asks me, "So, what is
JSON"? Oy...

~~~
bdittmer
Clueless management is platform independent.

~~~
michaelneale
And so is the law of averages - its a popular platform ;)

------
mikeryan
I'm in Silicon Valley - so this skews me a bit, but Java by far.

It does depend a bit on what you want to do, but most everything I see is
sliding towards java. You can do web development, mobile (except iPhone) and
though it hasn't fully caught on yet, I'm seeing more apps on the desktop in
Java than in the past.

------
mickt
I've noticed that no-one has talked about the cost of using either.

Yes the Java IDE's are somewhat inferior to MS's, but you can get everything
you need to write, develop, manage, and host Java applications for free
compared to MS; the OS, IDE, Web Server ... all cost money which can be a
substantial amount for commercial purposes.

~~~
gaius
Time is money, and Visual Studio is a very productive environment.

~~~
mickt
I agree it might be more productive (I've never used it). But I do feel the
costs and associated costs are quite high.

Imagine you get accepted by PG into Ycombinator and you have your $15000 in
hand to start. Using MS technologies you have to pay ~$700 per developer for a
Visual Studio license: <http://www.amazon.com/dp/B000WM04HU> . As you are now
a commercial enterprise you can't use the cheapo student version for $50
anymore. Plus you need to pony up a IIS license for each developer to test on,
and Windows Server 2008 license for each developer, and an even more expensive
OS license for your multi-processor multi-core server ...

So off the bat you've already spend more than a month's rent for that studio
in Sommerville your going to be camped out in ...

Whereas if you go the freebie Open Source route all you need to buy is
hardware. Maybe your labour is more, but it's your blood, sweat, and tears
which at an early point in the game is cheap. VS is a lot of .99c noodles! ;)

~~~
mickt
I only saw iamelgringo comment ( <http://news.ycombinator.com/item?id=366487>
) after I posted this. I'd still take anything MS offers with a big bucket of
salt.

------
donniefitz2
I would go with C#. There are lot's of people who say that you are subject to
Microsoft's directing of the language, but if you go with Java, you are
subject to Sun/OS direction just the same. C# is a great language and ASP.Net
is great for the Web. It's not popular to advocate a Microsoft product here
but I'm very happy with C# and ASP.Net. Your goals will be the ultimate factor
in your decision though.

~~~
jimbokun
"if you go with Java, you are subject to Sun/OS direction"

Not as much, now that Java is open sourced.

------
delano
You're not going to find a clear answer one way or the other. If you enjoy
working with Microsoft products, including Visual Studio, go for C#. If you
like, or would like to learn, using other platforms, go for Java.

Keep in mind a lot of the value of Java is the JVM. It's everywhere now so
it's kind of like a perl for enterprises.

------
tzury
Once you said ASP.NET it is clear that you are heading to the web.

If you insist not to develop web applications using the greatest open source
platforms which serve today all the largest sites, then C# would be better
than Java simply because ASP.NET has much more to offer than Java in the web
field.

------
rbanffy
If those were my only choices, I would consider changing my career. Maybe
learn to cook and open a gourmet restaurant.

Now, seriously, I would go for Java because, at least, it can run cross-
platform without the danger of Microsoft suing you out of existence.

~~~
johns
"it can run cross-platform without the danger of Microsoft suing you out of
existence"

Please explain further. MS isn't suing Mono (and supports them in many ways)
and is increasing their cross-platform capabilities with Silverlight. These
are not cure-alls, but they are progress.

~~~
nailer
How is Silverlight cross platform? Have you tried finding and installing
Silverlight on Linux? If you managed to, what percent of the sites on
Microsoft's showcase worked?

Hint: I know the answer to all the above. That's why I'm asking the question.

~~~
johns
I didn't say it was cross platform right now, but that they were making a
cross-platform push with Silverlight which brings a subset of the .NET CLR to
Macs. Linux support is in Moonlight. Again, not all there yet, but it's
progress.

------
speek
C# has got a bunch of neat functional stuff in it (Microsoft's researchers
have seen the glory of functional languages), but Java might be easier to
start off with.

Once you can get through Java, everything else you learn will feel immensely
superior...

~~~
johns
Can you back up your claim that Java is easier to start with?

~~~
rbanffy
Nobody can. But then, C# isn't easy to start with.

"The least painful" is what I would say.

~~~
johns
I'll bite again. What makes C# so difficult to start with? I seriously want to
know what obstacles are out there for people interested in starting with C#.

~~~
icey
C# by itself isn't terribly difficult, other than its constantly balooning
specification. A lot of the percieved difficulty with C# today comes from the
rapid shifts in direction from Microsoft in terms of the "Microsoft Way" of
using it. A prime example is the DLinq / Linq to SQL / ADO.Net Entities fiasco
that's occurred in the past 5 or 6 months; Microsoft is trying to react
quickly, but in doing so is crossing its own streams.

Of course, these are all really .Net problems, but more often than not, C# and
.Net are used interchangeably.

~~~
johns
You're exactly right, those are .NET problems not specific to a language, and
not really problems for a hacker. There are multiple open source ORMs that
take full advantage of the language features (like LINQ) and aren't subject to
MS's whims.

I think that "constantly balooning specification" is an overstatement. Look at
the release timeline:

    
    
      - 2002: Version 1 (with VS.net 2002)  
      - October 2005: Version 2 (with VS2005)  
      - November 2007: Version 3 (with VS2008)  
      - Oct/Nov 2009 (I'm guessing): Version 4 (with VS2010)
    

Four versions over that span is hardly "constantly balooning". The .NET
framework revs slightly more often with SPs, but major versions are on about
the same pace.

~~~
icey
I don't think the time-line has as much to do with it as the scope of the
changes do. Again, this is personal opinion; and I'm speaking from the angle
of someone who has spent many years doing consulting work on the Microsoft
stack, and having to deal with figuring out which ways the 9-to-5'ers are
going to break things next.

Version 1.0 of the C# specification clocks in at 405 pages. There was an
addendum in 1.2 that I'll leave out, because it was a respecification of 1.0.

2.0 came along and added 117 pages of specification - including generics,
partial classes, iterators, and a handful of other things. On pure
specification, that's a growth of 25% to the core language. (I know this isn't
really scientific, but I think you get my drift).

Then in 3.0, just 2 years later, the spec is back to over 500 pages (just for
the language!). This version added a bunch of functional paradigm stuff to the
language, lambdas, linq and the like.

And now in 4.0, they're talking about making C# essentially a dynamic
language.

Now, all this being said, I really do like C#; but I think that it behooves
everyone who likes C# to admit that it's a large and evolving language; the
paradigms that Microsoft keeps adding to the language don't really seem to fit
from one version to the next.

~~~
johns
This is one area where I think MS gets a bad rap. If they didn't keep adding
new stuff, everyone would complain that they were stagnant and falling behind
the times. So they add popular new features to C# like lambdas and such, and
now they're bloated.

4.0 will not essentially be a dynamic language. They're making it much easier
to interop with dynamic languages by adding some dynamic constructs, but it's
still as statically typed as ever. 'dynamic' is a shortcut to save you time,
not re-invent how you work with C#.

------
SapphireSun
My startup was recently looking at platforms to target windows effectively. We
just spent a lot of wasted time looking at .NET. Perhaps because it was
because we are very cheap, but we couldn't find decent (well written)
documentation. Also, visual studio is a bit confusing after working for a
while in a linux development environment.

I then remembered that I was already familiar with Java syntax, and that if we
needed speed, we could always code subroutines in C/C++ and link them through
JNI. The thing that is nice about Java is the amount of documentation and
tutorials (and source!) lying around. Of course, working with a big IDE like
Eclipse will be a big change as well, but we are going to go with Java.

By the way,does anyone here know if it is possible to create a salable client
side application using something like Python? It is my impression that it is a
bit too easy to disassemble without including some sort of heavy duty DRM
scheme that wouldn't be worth the effort. If it isn't, does Java suffer from
the same problem since you compile to bytecode?

~~~
shiranaihito
Java class files can be decompiled, but is it really a cause for concern?

At least someone has to go out of their way to decompile your stuff.

~~~
SapphireSun
I suppose. What we really want to do is make it so that if someone cracks it
and posts it on thepiratebay or something that someone will need to
consciously need to run a keygen program or something so they at least
recognize they were supposed to get it from a more official source.

------
kstenson
I would recommend looking at c#, or more interestingly the .net framework and
the CLR. Once you've learn't the framework then you can also look at the other
.net languages. Ironpython, IronRuby and F# give you a width breadth of
languages and ideas but with the benfit of the shared .Net framework and the
object inter opt that comes with the CLR/DLR

------
DomesticMouse
As a ten year veteran of Java, currently learning C# (the world is full of
irony), I can say that Java is a simpler language. There are a bunch of bones
thrown to c++ and assembler focused guys in C# making it a more complex
language to master. And I dispute that VisualStudio is a better IDE than
IntelliJ. So, my honest opinion is start with Java.

Spend time writing code, and just as importantly, reading it. Read through
Spring, Hibernate, et al. Understand the architectures, the trade offs, and
the code tricks.

------
ensignavenger
You should look at doing C# and learning .NET, and as has been stated, you
could then use .NET with all sorts of languages (IronPython, IronRuby, etc.)
You could also look at the Mono project for Open Source development, and as
you are doing web apps, take a look at Silverlight/Moonlight. Silverlight has
very impressive capabilities and potential.

------
caustic
From my experience of working with both Java and .NET I can say that: the
weakest part of the .NET technology stack is community, and the strongest part
of the Java world is community which produced the huge pool of quality, free
and open-source frameworks. Currently Maven repositories count for more than
14,000 unique artifacts and almost 60,000 versions
(<http://www.mvnbrowser.com/faq.html>).

C# is a nice language, but when you have to develop a real-world application,
it does not help much. .NET simply lacks too many essential tools and
frameworks. You can do basic things with it, but when you have a non-standard
task at hand, you are alone to implement the solution by yourself or pay for
crappy third-party closed-source component. Even for trivial tasks. Want a
decent HTML parser to sanitize HTML documents? Write it by yourself or pay for
crappy third-party closed-source component. Want to read email messages from
the server? ... you got the idea. The list goes on and on. I am currently
working on a C# project which has integration with source control systems. We
had to invest a lot of time to write our own framework and providers for
several most widely adopted tools, such as Subversion and Perforce. If we
based our project on Java, we would saved lot of time on development by
choosing Maven SCM providers, which are free and open-source. Another example
is that we needed a decent audit history for the documents in the database.
Again, we had to develop somewhat working home-grown solution. If we based our
project on Java, we would simply pick open-source Envers framework
(<http://www.jboss.org/envers/>) which does exactly what we need for free.

And I hate Visual Studio. It offers a little more than a notepad with syntax
coloring and debugger. It is horrible for coding and those variegated wizards
and diagramming tools don't make me productive either. Being unable to attach
third-party source codes is a huge PITA. Eclipse in size is just a fraction of
the VS installer, but still is feature-packed, better for refactoring and has
a plenty of plugins. Speaking of IntelliJ Idea, it's simply the best IDE ever.

.NET build and CI tools suck, there is nothing to compare with Maven.

If you like to learn new languages, I think there is nothing to beat JVM in
terms of variety programming languages running on top of it. Just for example,
the most notable ones are JavaScript, Python, Ruby, Groovy (Python-like
language with Java-friendly syntax), Scala, Clojure (Lisp-like), CAL Language
(Haskell-like) and many more. By the way, JVM by itself is quite a decent
piece of engineering.

My experience makes me think that Microsoft is trying to be popular at any
cost, targeting inexperienced programmers, intentionally oversimplifying their
solutions, making simple things trivial, complex things impossible. The
Microsoft culture is to give you a big bright flashy button, which does a lot
of things under the hood, but when accidentally it breaks, you are unable to
guess what is going on and how to fix it. Living in the world of closed-source
.NET code makes me cry.

So the conclusion is: choose Java over .NET, but learn more uncommon
programming languages as well. Haskell, Lisp and Prolog were huge "brain-
washers" for me.

~~~
jaycee
To add to the list of examples of places where you have to roll your own:

At my company we needed a simple CSV reader for a file submission. That's it--
just something that could read CSV files. We figured that _had_ to be
available in classic .NET We look around, dug into forums, and finally got in
touch with the local .NET user group guru. The ideal solution? Use MS's
communication tools to open the CSV file _in excel_ and read it there. Or?
Roll your own.

We ended up doing the thing in python and imported the csv lib.

~~~
johns
To be honest, you didn't look hard enough. There are multiple, mature OSS
projects to handle this.

Where should the framework end? People complain all the time about the size of
the framework, but then when their pet feature is missing, they cry foul.

------
webwright
Would probably be good to specify your goals. Long term job security?
Payscale? Building your own startup/app?

------
johns
One important thing I think is being missed in this conversation is the
vibrancy of the .NET community, much of which is C# focused. There's a very
active community of .NET devs out there that aren't doing things the Microsoft
way, creating useful and popular open source libraries and sharing that
information with other devs. The Dev Div at MS is extremely active in the
community as well. If you look at how the new ASP.NET MVC Framework is being
rolled out (open source, multiple rounds of community feedback) and the
inclusion of jQuery AS IS (not extended or modified) in the MS stack you'll
see a big difference from the MS you think you know.

------
ricky_clarkson
Go for the one with lambdas.

~~~
zcrar70
That'll be C# then - but I'm guessing that's not what you meant :-)

~~~
ricky_clarkson
Yes, actually, that's what I meant.

------
gills
Have you considered learning both? They have a lot in common, and 'which one
is better' is a decision you need to make for yourself in the context of your
project.

Oddly enough, geography might matter. For example, Seattle seems to have a
bunch of consulting shops and even a few product startups using MS tools.
(There are also startups using the usual suspects...Java, PHP, Python,
Ruby,...).

Both languages' VMs are accessible to a number of other languages if you
decide to branch out later. As many have said already, Java gets a slight leg
up from open source.

------
jimfl
C# and Java are very similar. Learn one, and the path to the other is quick.
The languages have essentially the same feature set, though some of the
advanced concepts (reflection metadata, generics) are easier to learn on C#.
XML in C# makes Java seem like a major pain in the 455.

------
newsit
Learn both. Seriously. Pick a good book about algorithms or data structures,
open Visual Studio and Eclipse, load the Java and .NET docs in your browser,
maybe pick some introductory books on both and start coding the examples. It
might take a little longer to start, but it will pay out tremendously in the
end.

I've been doing this with Scheme and Erlang using SICP
(<http://mitpress.mit.edu/sicp/>) and it has definitely helped me understand
better both the languages and the material.

In your case you have two very similar platforms, object-oriented, garbage
collected, with a very similar syntax. The big strengths for both are their
libraries and their VMs, learning them in parallel makes lots of sense.

------
vlad
So you've learned C, and C++. Of Java and C#, you may as well continue
learning them in that order to see how one tries to improve on its
predecessor, though by now it's likely that Java has adapted some ideas from
C# as well.

Oh, and learn Objective-C!

------
xefyr
Why would you only learn one of them? Learn every language you can. Learn them
well enough to love and hate each for 5 different reasons. Learn them well
enough to know which should be used when.

IMHO: they are very similar languages with converging library offerings. I
think Java is ahead of the game in this regard because it's been "in the wild"
longer and has more of an open source following.

And don't forget, they can interop very easily with SpringFramework and XML-
RPC.

------
dreur
Grails !! Works with java (and uses professional java tech) but has the dev
speed of rails or django.

Check the case studie of Wired :
[http://www.springsource.com/files/Wired.com%20Case%20study.....](http://www.springsource.com/files/Wired.com%20Case%20study..pdf)

------
ra
Java was a great choice of language to learn 10 years ago. c# was a mediocre
choice to learn 5 years ago.

In terms of employability, they both have enclaves of popularity around the
world.

Java would be my recommendation, if limited to those two.

However there are better languages around today including those already
mentioned.

------
ruslan
It seems, we are pretty close to epoch where C programmer to be treated as
assembly guru nowadays who can read machine codes right out of hex dump.

Man, learn C/C++ first, I beg you!

~~~
asmosoinio
He has done that already: "For the record, I ... code in c, c++ on the day
job."

------
NonEUCitizen
Yes, learn C# OR Java, where OR != XOR:

    
    
      TRUE == OR(TRUE, TRUE)
    

When it comes to programming, be language, platform, vendor, and ideology
agnostic.

------
13ren
What's your purpose? That is, "better" for what?

------
time_management
Java, then Clojure. I've never used Clojure, but my understanding is that it's
a Lisp dialect that targets the Java VM.

Do learn a language like Lisp, Ruby, or Ocaml, though. Once you get used to
the functional paradigm, you'll realize how much more powerful these languages
are, and you'll never go back.

~~~
PieSquared
Yup, you'll never look back! ...unless you need to get a job, of course...

Though Python is used more and more now, you can definitely get jobs in
languages other than Java and C# and such... But sadly, not Lisp or Ocaml
though, at least not easily.

------
lst
You ask seriously?

Then you should stop programming and start hacking (in the spare time of your
day job).

Seriously: what exactly do you expect from the only 2 languages left with
exactly _no_ _fun_?!

------
MaysonL
Component Pascal: available in both .NET and JVM versions, as well as a native
Windows app. Reasonably well-chosen splashes of OO, functional, and meta
programming in a spare, Wirthianly simple language.

------
geuis
If you are looking to only program for windows, C#. Stay away from java at all
cost. Java is a career trap, and more importantly a destroyer of intellect. My
roommate is a C# programmer and a system architect. Really smart and he makes
close to $150k per year. Java would qualify you to flip French fries in
comparison. Also, keep Objective C in mind. That opens up Mac and iPhone
development to you. Macs are at 20% marketshare now, iPhones the best selling
smart phone. Plus programming for Mac/iPhone is just _fun_. Further afield,
look at languages like Erlang. The future of computing is hundreds and
thousands of parallel cores and parallel languages like Erlang are in many
ways increasingly important.

~~~
vlad
I think the Systems Architect position earns that salary, not just a developer
who uses that specific language. I don't think anybody is saying C# developers
are paid badly, but that Java is open source in (I think) every way by now,
and that means it will survive for a long time.

On the other hand, I'm never putting faith into Microsoft's development tools
again, as nice as they are, because in recent history, Microsoft has killed
off programming languages and tools at will, even their most popular ones.
Microsoft makes developers depend on Microsoft's ability to update and improve
their programming tools, in order to make the case they should charge for
them, but has killed off popular programs or languages in order to concentrate
on new ones, given that they themselves don't have resources to support all of
them at once.

~~~
johns
I assume you're mostly referring to VB6 being EOL'd. Any other examples?

~~~
vlad
Yes, Visual Basic was maybe the most popular language at the time they killed
the product. Imagine picking the platform (VB6) that is supported on any
computer that mattered (at the time, Windows), compiles to native code, and is
also the most popular language. On top of that, your users don't need to
download a 30MB .NET Framework that's in beta over a slow dial-up connection.
And then, Microsoft kills it! If I'm going to invest time to create software
in a popular language, it's not going to be a closed one again.

Microsoft also recently killed scripting and macro support in the latest
version of Mac Office, so I imagine if you're a developer on either the
Windows or Mac platform and want to script an Access Database, Excel
spreadsheet, or Word Macro, you're screwed. It means you can't functionally
use previously-created files any more, or use files from Windows users that
use scripting. It's almost like Microsoft is helping users and developers
migrate to other tools and platforms.

