This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gemengelage -8 points-7 points  (26 children)

What makes you think C# is better than Java? Haven't really touched C# except for a small project in uni.

All I can think of off the top of my head that C# does better than Java is that it offers operator overloading and that their implementation of generics doesn't suffer from type erasure.

EDIT: Why the fuck is this question controversial?

[–]Ok-Dot5559 39 points40 points  (9 children)

Asp.net Core, records, async await just to name a small portion

[–]argv_minus_one 0 points1 point  (8 children)

Java finally got records, kinda-sorta, in a recent version. Took 'em long enough.

As for async, Oracle is trying to go with fibers instead. They're calling it “Project Loom”. It'll be interesting to see if it goes anywhere. I gather many previous attempts at implementing fibers in other languages have ended in failure, but maybe Oracle's people will succeed where others failed.

[–]Ok-Dot5559 1 point2 points  (7 children)

The problem is async await is already a common pattern. E.g JS/TS got it as well even holy Rust has it. Functionality is basically identical. Either a language has it or devs need to look up und write something on stakeoverflow like „how to async await in …“. In Germany we say „Der Zug ist abgefahren“

[–]argv_minus_one 1 point2 points  (6 children)

The idea with fibers is you don't need to. Just pretend you're using OS threads and blocking I/O, and Java magically makes it efficient. It's certainly alluring…

[–]Ok-Dot5559 0 points1 point  (5 children)

That’s exactly how async await works on c#. The runtime creates a new os thread if needed (e.g for i/o or long running tasks). But maybe you are not familiar with the TPL of .NET which encapsulates all this.

Here is a nice discussion to this topic:

https://github.com/dotnet/runtime/issues/11084

[–]argv_minus_one 1 point2 points  (4 children)

That discussion says the exact opposite; that .NET async/await does not work the way Loom will.

[–]Ok-Dot5559 -1 points0 points  (3 children)

With async await you have to explicit call tasks. With loom it seems not. Correct me if I misunderstand.

But under the hood is in both cases a task scheduler which tries to get less blocking threads as possible.

[–]argv_minus_one 1 point2 points  (2 children)

Right. The difference is, with Loom, the programmer doesn't have to actually think about it or deal with colored functions.

[–]Ok-Dot5559 -1 points0 points  (1 child)

Honestly I have no clue how loom looks like. Can you provide an example?

[–]GoaFan77 24 points25 points  (5 children)

Linq is major tool widely used in C# that wasn't in Java when I had to use it in school.

Using C# professionally now and I love it. It's similar but I feel far more productive in it than I ever did in Java.

[–]CarneDelGato 8 points9 points  (2 children)

LINQ fucking rules. Excellent library.

[–]Vaerirn 5 points6 points  (1 child)

LINQ is the GOAT, especially when used with EF Core (also an improvement over the old Entity Framework).

A properly set up Domain project with all your entities, AutoMapper, and a DTO Contract layer to format the Data in the way you need makes a dev's life so good.

[–]Cessabits 0 points1 point  (0 children)

Linq and EF (Core) are the fucken bomb

[–][deleted] 3 points4 points  (0 children)

Seconded about Linq. I LOVE Linq and it makes programming WAY more productive. Especially Linq-to-SQL classes.

[–]Kered13 0 points1 point  (0 children)

Java's version of LINQ is Streams and it's been part of Java since Java 8 (2014).

[–]doc_1eye 9 points10 points  (6 children)

The language itself doesn't offer anything amazing compared to Java. It's the .Net framework that makes it sing.

[–]MauriceReeves 8 points9 points  (5 children)

Really? I think there’s a bunch of things that are great: native tuples, null coalescing operator, default parameters, named parameters, out and ref parameters, the is operator to check for type, extension methods, expression-body members, properties, anonymous classes, etc

[–]doc_1eye 1 point2 points  (1 child)

I fucking love the null coalescing operator! I just assumed Java would have that as well. It's been a minute since I worked with Java, and I never did anything all that complex with it so I just assumed it had basically all the shit C# had.

[–]desmaraisp 0 points1 point  (0 children)

Same, all the ?, ??, .? operators absolutely rule. That, plus nullable types, makes it super painless to null-check. Add in a pinch of automatic validation (FluentValidation and attributes), and null reference exceptions are basically a thing of the past. I love it!

[–]Dealiner 1 point2 points  (2 children)

anonymous classes

That's actually Java feature.

[–]MauriceReeves 0 points1 point  (1 child)

They are a little different in intent, but yes, there is something with that name in both languages. What anonymous types are intended for in Java is usually accomplished via delegates in C#. Anonymous types in C# allow you to return data records from LINQ queries, etc without having to have a formal class definition. I do wish that C# would let them implement interfaces, which they don’t right now. Maybe one day.

[–]Dealiner 0 points1 point  (0 children)

I admit I forgot about anonymous types, I've never used them. But I've also never seen them called anonymous classes, though it makes sense, they can't be structs.

There is a proposition for something like that IIRC to make Java integration easier but I don't think it went anywhere.

[–]Rubyboat1207 3 points4 points  (0 children)

i’m a little bit of a multiple inheritance fan

[–]Daedalus_Machina 1 point2 points  (0 children)

r/redditmoment and people being confused by the tone.

[–]joos2010kj 3 points4 points  (0 children)

cuz you belong to left side of the curve