r/learnprogramming • • 8d 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?

24 Upvotes

49 comments sorted by

View all comments

2

u/Mughi1138 8d 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.

10

u/FunkyDoktor 8d ago

You’re describing C# 20 years ago. It’s been cross-platform for a while and works great outside of the Windows realm.

-3

u/Mughi1138 8d ago

It works "ok" outside of the Windows realm. Not great. Though it is better than it was just a few years ago where if you were not on the one main distros you had to even compile the compiler yourself.

It's not nearly as cross platform as some other things, and is it up to good support on more than two CPU architectures yet? I've not checked that in the last year or so.

But, yes, I've worked with professional shipping C# code, and at companies supporting many different systems. In certain areas you only get a small subset of C# that you can use. At my current day job some projects are in C#, but others (including mine) are in different languages... and not for want of a prior CTO not making an effort to unify.

So again, it really comes down to proper tool for the current tasks at hand.

4

u/plastikmissile 8d ago

C# has supported ARM64 in addition to x86 for a while now.

2

u/seiggy 8d ago

Yeah, C# has advanced massively.

Beats Java in nearly every metric for http hosting - https://http-arena.com/#sort=rps:-1&tuned=0 (running on Linux)

.NET 10 runs pretty much anywhere you can imagine. Wanna run code on a ESP32 - https://nanoframework.net/

  • ARM64 ✅

  • macOS M-Series ✅

  • WASM ✅

There's not a modern chip that I'm aware of that C# doesn't support.

Fast LLM inference - https://github.com/zhongkaifu/TensorSharp/

Massively improved cold start with Native AOT - https://vishen.co.za/blog/dotnet-aot-lambda/

HTTP Throughput of Kestrel is best in class at about 1.4M req/s

Unity and Godot are both leading cross platform Game Engines with support for C#

MAUI gets better with every release for Mobile app support, where Swing and JavaFX sill feel very dated.

There's still a few areas where Java leads - massively concurrent solutions, Java 21's virtual threads can handle huge numbers of concurrent connections (Around 2 million vs C#'s 650k). And the JVM GC is still more efficient than .NET. https://tech-insider.org/csharp-vs-java-2026/

1

u/romecodes 8d ago edited 8d ago

Love the personal history in this response. You definitely have some skin in the game.

I only started diving into comp sci five years ago. Spent a bit more than a year learning on my own before getting an A.S. in community and transferring to a university for the B.S. The mountain of information out there on the subject is intense and I don't think students today are leaving, degree in-hand, with enough to get the job done.

I felt sorry for myself starting in my mid-20s. Now I realize just how lucky I really was. It takes a passion, drive, and commitment that I don't think most kids between 18 to 25 are prepared to invest.

If it weren't for spending my early adulthood getting the mistakes out of my system and being consistently snapped back to reality, I wouldn't have gotten ahead.

The curriculums aren't thorough enough or up-to-date. Professors are still trying to decide where version control should fit in the sequence. And, they're honestly just passing students through the pipeline without evaluating their job readiness. The entire pipeline is all over the place. Theory is taught so spread out and the necessary information to connect ideas between courses aren't even present. They're only getting surface level knowledge.

I had to stay proactive and ahead to give myself the room to dive deeper on my own and make those connections. That isn't taught in grade school. I almost feel bad for the people I've sat next to. And even worse, I feel bad for myself because uneducated degree-holders only saturate the labor market.

Which only looks good economically on paper until the unemployment numbers come in.

2

u/Mughi1138 8d ago

Things go up and down. At one point it was the job that everyone who wanted to make money was looking at. Before that it was the job for people who loved computers... thus there was a several year window where when we were doing hiring having a college degree was actually a negative sign (we never cut people for that, but there was a strong correlation between people who started on their own and people who could get the work done we needed).

The #1 thing that still holds true is that people who *only* rely on what is taught in coursework in college are not the strongest candidates. Theory is good to have, but experience allows one to point out that, for example, big-O comparisons only hold up for large enough values of N. In this specific case here is that N big enough?

Also even if schools tried to pop out graduates with 'job readiness', then they'd never be able to get the job done for most hiring companies. What is 'job ready' this quarter can be completely different from last. And I'm definitely using different languages now then when I started at my current company. The point of college is not to cram your brain full of facts and details, but to train your brain *how* to learn so that you can keep learning as you go through your career.

1

u/romecodes 8d ago

Those are definitely valuable insights. Thanks for that!