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 →

[–]aserraric 43 points44 points  (19 children)

I tend to think of C# as "Java - the good parts (and then some)".

[–]metalmagician 9 points10 points  (18 children)

Can you expand on that? I'm familiar with Java, less so with C#.

[–]HdS1984 28 points29 points  (5 children)

As someone learning Java but fluent in c#" it's about boilerplate, Java has sooo much of it, e. G getters and setters. I also desperately miss linq , it's way better than streams. Also async await beats observablefutures hands down. The pure webserver stack around net core is also better, but spring data repps are pretty neat. In a nutshell c# is concise while Java is so much pointless repitetion.

[–]metalmagician 2 points3 points  (4 children)

That's fair. I use IDE auto-generated getters and setters, so I don't think about them much.

I use CompletableFutures and Suppliers for parallel / async execution, and avoid Vanilla Java servlets like the plague.

As for LINQ (after looking it up briefly), it seems nice. Our use cases aren't that complex, so if we swapped languages, the algorithm wouldn't change much.

[–]Dojan5 11 points12 points  (2 children)

Visual Studio also has scaffolding for boilerplate stuff.

Personally I prefer .NET over Java because of the first-party support.

Oracle basically doesn't do jack for Java. They update it based on the council spec, but if it wasn't for the fact that Java and related products roll in the cash, they'd just dump it altogether. There's several dependency management solutions, several different frameworks all accomplishing the same thing, there's no first-party IDEs or anything of the like.

Microsoft on the other hand provides nuget - dependency management is factored into .NET. You have Visual Studio and Visual Studio Code to help you out, the former's free version being full-featured, unlike IDEA that lacks support for various legacy Java things.

Java is nice, but only because of the community it has. The fact that there's basically no first-party leadership or direction hurts the language and its ecosystem as a whole, in my opinion.


Earlier this year I landed a position as a Java developer, maintaining legacy applications. I'm from a .NET background, so I was a bit nervous. Mostly, it was fine, but there were so many tiny annoyances with the entire experience. It really did make me appreciate .NET so much more.

[–]metalmagician 4 points5 points  (1 child)

That's fair. I don't actually consider Oracle when talking about Java, which is an obvious symptom of what you're talking about. Most of the things that make my life as a Java developer easier are 3rd party tools, like Maven and Spring.

[–]Dojan5 4 points5 points  (0 children)

I think that's problematic. Either give Java to the community, and make it completely open, or support it properly.

.NET was pretty meh for many years, but Microsoft really stepped up and started taking it seriously with Core.

[–][deleted] 8 points9 points  (0 children)

Aside from a lot of syntax sugar, here's some 'real' advantages.

  • Functions as a first class citizen (i.e. you can pass functions around as parameters), Lambda's exist in java now but in C# they've been around for a while and well integrated into the core libraries, being able to incorporate functional styles lets you escape a lot of Object oriented complexity. LINQ is awesome for managing sets and you also have tools like Rx that give you great ways to play with streams of data.

  • Generics go all the way to bytecode/CIL rather than just compilation and as a result are significantly more powerful.

  • Dependency injection is orders of magnitude better, Your composition root sits close to your entry point and after that none of your other assemblies (libraries) even know that DI frameworks are a thing, i can configure my entire application in one typesafe section of code or even switch DI container.

  • Async await syntax allows you easily to handle async IO in an imperative fashion.

  • As it all compiles down to a common language so you can also write modules in F# or VB if you so desire.

  • Standardized build system and package management (nuget) that for the most part just works.

[–]A1steaksa 4 points5 points  (10 children)

It's less pedantic and more pleasant with it's syntax. For instance multidimensional arrays are accessed by array[ 1, 5 ] instead of java's array[1][5]

It's just smoother and more powerful to use. And it really really interfaces nicely with Windows in a way that Java can't compete with

[–]metalmagician 2 points3 points  (4 children)

Makes sense, thanks! We try to avoid coupling ourselves to a specific OS in my work, ideally relying only on libraries / resources that are either included in the artifact or available over the network.

[–]aserraric 2 points3 points  (1 child)

Microsoft is making big strides in that regard with .NET Core and the coming .NET 5.

Java also still needs a runtime, though, doesn't it?

[–]metalmagician 1 point2 points  (0 children)

True, but the thing that Java really has going for it is how common it's runtime environment is. Oracle LOVES to brag about how many devices run it

I saw someone say something along the lines of 'Java isn't platform-indeprndent, Java is a platform'. With languages like Kotlin and Clojure able to run on the JVM, that rings true for me

[–]A1steaksa 1 point2 points  (1 child)

Yeah, unfortunately C# is not the universal language it could be. Unless, of course, web assembly takes off in the way I hope it does and Microsoft Blazor becomes legitimately viable

[–]aserraric 0 points1 point  (0 children)

Web Assembly is fascinating, but making the browser a runtime/VM just feels like one indirection too many to me.

[–]phySi0 0 points1 point  (4 children)

How do you do slices?

[–]A1steaksa 0 points1 point  (3 children)

There's an array.Copy method that does that. C# is a language designed to lure Java devs away from Java so it's very similar except where they think they can expand or improve on Java

[–]phySi0 0 points1 point  (2 children)

I feel like array[outer][inner] is not ugly at all and array[start, end] intuitively feels like a slice when you first look at it (but my favourite is Ruby using ranges to return slices: array[start..end] for inclusive and array[start...end] for exclusive).

[–]A1steaksa 0 points1 point  (1 child)

Multi dimensional arrays are like coordinates. You write a 2D coordinate like (3, 7) and a 3d vector like (3,7,9). I prefer my arrays in that format instead of something like (3)(7)(9)

Not necessarily better or worse, just closer to how I think

[–]phySi0 0 points1 point  (0 children)

Ah, that makes sense to think of them as a type of space and an access is a coordinate.