r/learnprogramming • u/Vafireems • 5h ago
Topic C# or Java?
If you had to choose one class between the two, which would you select and why? I tried to Google the purpose of them; the immediate answers from Google felt very vague and like both of the languages are common. Is one course better for web development as opposed to apps or something? Looking at the courses I'm taking, down the line I will select one of the two. The only thing I know so far is C++, so I'm quite new.
Also, side question: why are there so many languages? The only logical thing I can imagine is there were problems that couldn't be solved with say for example C++ so someone created something new. But why not just build on the original language? Why did they need to reinvent the wheel? Or is it as simple as that: someone wanted to create their own thing?
3
u/Mughi1138 4h ago
To answer part of the side question first - why so many languages and why C#?
C# actually started life as the next iteration of Microsoft's J++ which was their Java implementation. They poached the architect who did Delphi among other things from Borland and eventually tasked him with making C#... which turned out to essentially be Java hacked to support Microsoft COM interfaces. And appeared to be part of their traditional efforts at vendor lock-in. Oh, and it added 'delegates' as a language feature since that architect loved to shove those into any language he created.
When Microsoft was first introducing C# the president of our Orange County Java users' group attended and then came to give a presentation to our UG, as we were mainly professionals who used many different languages and not just one. Most of his presentation was "and it does XXX, just like Java" (including immutable strings), but every once in a while he hit "and then C# does this odd thing, but I have no idea why". Each time he said that, I had the answer as for the company I was working at I had shortly before finished an automatic Java -> COM wrapper tool that would create C++ code to be either standard JNI interfacing or Microsoft proprietary RNI. I recognized each and every one of those divergences as what was required to give it first level COM support in the language itself. Or at least make it easier to use.
So... if you plan to make your career just in the Microsoft Windows realm, with their platform and their tools only, then C# is a good tool for the job. If you want to be more universal Java shines (kinda... mostly still..) but with things like Kubernetes and languages like Python your options are more wide open these days.
And, of course, the more tools you become proficient with the more options you will have when picking the right one for the job at hand.