4 ms·
In broad strokes, what are the differences between Java and C# and why should I bother with it? (Disclosure: I hate Java)
by elnate 13y ago
In broad strokes, what are the differences between Java and C# and why should I bother with it?
(Disclosure: I hate Java)
- adamnemecek 13y agohttp://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java
- thomasz 13y agoC# is years ahead on the language feature side: - lambdas - Expression trees - sensible operator overloading - value type semantics (you can define your own types that behave like primitives) - reified generics instead of type erasure, which means that you can have an <int,int> table (just two ints instead two pointers to Integer) - "async monad" baked into the syntax On the other hand, Java wins easily on the open source lib count
- sdegutis 13y agoThe way I heard it put some time ago was, Java/JVM couldn't make some important changes because it would break backwards compatibility in an unacceptable way (I'm assuming this means there are mission critical apps written in Java 1 that the whole world depends on), but since C#/.NET were from scratch, they were free from this legacy baggage and could take huge steps forward.
- MichaelGG 13y agoThe JVM didn't want to break compat to add generics into the runtime, hence they adopted the erasure model. Other language features are still quite doable on top of the JVM (as evidenced by plenty of more advanced languages targeting the JVM). Yes, the CLR gets a major advantage by having a better bytecode language design, but it can't be the real reason Java didn't get lambdas until Java 8.
- ygra 13y agoActually, .NET was in pretty much the same place, because generics were only implemented in .NET 2. They chose to add the support directly to the VM, though and break compatibility. That being said, Java broke other things along the way back then, if I remember correctly, so in hindsight type erasure for fake generics was maybe not the smartest choice.
- tejinderss 13y agoJava 8 supports lambdas
- thomasz 13y agoI know. But it's not even released yet, and it takes a lot of time for such massive changes to ripple through until you can expect them to be useful for the general public: Developers need to be trained, documentation, tools and libraries updated and hyper conservative tech leads persuaded or dethroned.
- Aaronontheweb 13y agoI'll give you a broad answer to your question: C# is a streamlined platform that is designed to work with Microsoft's platforms and tools. If you use what Microsoft has to offer (Visual Studio, Windows, NuGet, IIS, ASP.NET MVC) and some of the really well-maintained OSS packages, you'll have a great experience. Bad news is: you don't get a lot of freedom in terms of platform choice. Java is a broad platform that comes in thousands of different flavors; there are tons of mature, well-maintained options for just about everything from web framework to IDE to build tool and so forth. The problem is: everyone does everything their own way, so you kind of have to jerryrig everything yourself. Java can feel really janky, but you have a ton of options. disclosure: I'm ex-Microsoft and LOVE .NET, but I feel that I need to know the JVM better in order to work on some of the projects I love.
- sdegutis 13y agoI only started using C# because I wanted to write some Windows programs[1]. And just like ObjC for Apple, C# is the primary blessed language of the platform, so if you want to write apps there, you have to use this. But even though I came for the platform, I might stay for the language. [1]: I'm porting my OS X window manager (https://github.com/sdegutis/zephyros https://github.com/sdegutis/zephyros) to Windows.
- choonkeymoonkey 13y agoIn my opinion, the best way to see the difference between the two language philosophies is the way compiled programs are started. [Java] > java SomeRetardedAnd.Inconsistenlty.StructuredNamespace.AndARidiculousClassNameThatHasAnObligatoryOrSuffixLikeForExampleAMotherFckingInflector arg1 arg2 arg3 # wait for what subjectively seems like 20 minutes until JVM starts, 19 if it's Hotshot. [.Net] > MyProgram.exe arg1 arg2 arg3 Very superficially the languages are very much alike, but somehow C# doesn't manage to get in the way all the time.
- n1ghtmare_ 13y agoYep, it was just a matter of time before this becomes C# vs Java ... :)