10 ms·
Ask HN : Which should I learn : C# or Java
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 18y agoI 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 18y agoMan 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 18y agoClueless management is platform independent.
- michaelneale 18y agoAnd so is the law of averages - its a popular platform ;)
- jcromartie 18y ago"Java programmers" are the worst part about programming in Java. There are plenty of smart people doing smart things on the platform, but you won't find them on the average project due to the fact that it seems like every idiot programmer on the planet works in Java too. Perhaps it is second to VB in this regard, but I am not sure.
- axod 18y ago"java isn't all that it's cracked up to be" "every java 'engineer' I've known has been a siv" It depends if you're learning a language to build stuff, or to work with good people (community). As a language, I'd say java rocks most of the time and does a good job of things. It's similar to javascript. A large number of people who program javascript are really pretty poor programmers, who just program by trial+error, or copy+paste code they found on the web. This doesn't mean javascript as a language is bad though. It just attracts a wide range of users.
- alnayyir 18y agosiv?
- tocomment 18y agoSimian immunodeficiency virus
- amichail 18y agoLearn Scala: http://www.scala-lang.org http://www.scala-lang.org
- jorgeortiz85 18y agoAgreed. As a language, Scala is superior to both C# and Java. It's open source and it has the advantage of being compatible with Java's platform, environment, and libraries.
- jherber 18y ago+1 Scala. Open JVM, open compiler, open libraries, open language design/research community, and 3 books on the way. More importantly, Java and C# are throwing in lots of functional programming features after the fact. They will likely never have the uniform object/functional model Martin Odersky has already achieved in Scala.
- jrockway 18y agoExactly. If you need to use Java for some reason, like getting at their libraries, you will do well to use anything other than the Java language. The platform is good. The language is 20 years behind the state of the art. Unless you are forced to work with other people that can't learn a language other than Java, there is no point in using it. I lean in the direction of Clojure, but lately the constant fanboi-ing is really putting me off. C# is similar -- F# is a much better way of interacting with .Net libraries. It is even "fully-supported" by Microsoft from what I've read, so it is definitely a good alternative to C# if you prefer its functional style. (And who doesn't?) Finally, if you don't need Java or .Net libraries, SBCL is a very nice Common Lisp implementation. It's fast, and if you like emacs, the tools are great. It is quickly becoming my favorite environment. (Perl is my other favorite.) Despite what others say, you can write maintainable and well-performing code in any of these languages. So pick one and get started... that's the hardest part.
- jules 18y agoHow's .NET vs Java library-wise?
- deleted 18y ago[deleted]
- delano 18y agoYou'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.
- mikeryan 18y agoI'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.
- geuis 18y agoIf 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 18y agoI 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 18y agoI assume you're mostly referring to VB6 being EOL'd. Any other examples?
- vlad 18y agoYes, 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.
- time_management 18y agoJava, 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 18y agoYup, 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.
- vlad 18y agoSo 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!
- speek 18y agoC# 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 18y agoCan you back up your claim that Java is easier to start with?
- rbanffy 18y agoNobody can. But then, C# isn't easy to start with. "The least painful" is what I would say.
- johns 18y agoI'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 18y agoC# 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 18y agoYou'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.
- kstenson 18y agoI 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
- tzury 18y agoOnce 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.
- mickt 18y agoI'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.
- icey 18y agoDue to Mono, this is only like 63% true.
- krschultz 18y agoYea except 63% true X 40% of .NET that Mono actually implements is a lot less than the 100% of Java that can be accessed from Eclipse.
- Encosia 18y agoThat was once true, but the "Express" (free) versions of Visual Studio and SQL Server all but completely negate the cost argument.
- aschobel 18y agoI love IntelliJ IDEA, it kicks some serious ass: http://www.jetbrains.com/ http://www.jetbrains.com/ The last time I used VS was with VC++ 6.0, so no clue how IntelliJ compares.
- alexkay 18y agoJetBrains has an add-in for VS called Resharper: http://www.jetbrains.com/resharper/ http://www.jetbrains.com/resharper/ I wouldn't consider using VS without it.
- gaius 18y agoTime is money, and Visual Studio is a very productive environment.
- ensignavenger 18y agoYou 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.
- webwright 18y agoWould probably be good to specify your goals. Long term job security? Payscale? Building your own startup/app?
- jimfl 18y agoC# 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.
- rbanffy 18y agoIf 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 18y ago"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 18y agoHow 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 18y agoI 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.
- ricky_clarkson 18y agoGo for the one with lambdas.
- zcrar70 18y agoThat'll be C# then - but I'm guessing that's not what you meant :-)
- ricky_clarkson 18y agoYes, actually, that's what I meant.
- gills 18y agoHave 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.
- xefyr 18y agoWhy 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.
- ra 18y agoJava 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.
- MaysonL 18y agoComponent 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.
- johns 18y agoOne 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.
- NonEUCitizen 18y agoYes, learn C# OR Java, where OR != XOR: TRUE == OR(TRUE, TRUE) When it comes to programming, be language, platform, vendor, and ideology agnostic.
- caustic 18y agoFrom 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 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/ 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.
- donniefitz2 18y agoI 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 18y ago"if you go with Java, you are subject to Sun/OS direction" Not as much, now that Java is open sourced.
- DomesticMouse 18y agoAs 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.
- newsit 18y agoLearn 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/ 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.
- lst 18y agoYou 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?!
- ruslan 18y agoIt 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 18y agoHe has done that already: "For the record, I ... code in c, c++ on the day job."
- SapphireSun 18y agoMy 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 18y agoJava 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 18y agoI 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.
- 13ren 18y agoWhat's your purpose? That is, "better" for what?
- dreur 18y agoGrails !! 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..pdf http://www.springsource.com/files/Wired.com%20Case%20study.....