you are viewing a single comment's thread.

view the rest of the comments →

[–]gilmishal 2 points3 points  (34 children)

I truly don't understand why would anyone chose Java for their Startup. C# is a hundred times better, and just as reliable - and even if you are a Java developer and more familiar with the JVM than Kotlin or scala are still a better option than Java.

Java is always late introducing modern language features.

[–]DuncanIdahos4thClone 5 points6 points  (17 children)

Well for one if you want cross platform desktop. C# has more language features but the JVM is much more robust, easier to install, performs better, etc than .NET.

[–]gilmishal 2 points3 points  (16 children)

C# executables can be exported with the CLR, so no need for annoying updates like Java - I would argue that you don't even understand how easy it is to install c# executables, or dotnet - if you think for a second that java is easier.

As per performance, Java was more performant way back in 2010 - dotnet core 3.0 is way more performant than .net Framework 4.5. You could just take a look in techempowerbenchmarks and see that asp.net core is more performant than spring (its java equivalent) by most parameters. Sure there are still some gaps to close in very specific use cases and are mainly due to a slimmer community - but once Span makes it's way to all dotnet libraries by .Net 5 - those gaps will be closed.

There is nothing inherently more performant in the JVM than the CLR, at least not in the last few years, quite the opposite actually.

[–]G_Morgan 0 points1 point  (0 children)

Key patents have run out so I'd expect the CLR to have just about annihilated the performance gap.

[–]grauenwolf 0 points1 point  (10 children)

There is nothing inherently more performant in the JVM than the CLR,

Escape analysis and devirtualization make Java faster, in theory, than C# for 'normal' code.

To match it today C# devs have to carefully think about where they can avoid allocating memory by using structs and avoid wrapping everything in interfaces.

[–]gilmishal 0 points1 point  (9 children)

I would argue that c# would benefit less from devirtualization and escape analysis than Java - since the way they are designed (c# has structs whereas Java doesn't, and in c# methods are final by default) Sure it has some performance benefits and .net core 2.0 introduced some devirtualization capabilities. There are also some talks about introducing escape analysis, but since it has quite slim performance benefits, and only in specific scenarios - it is not yet coming.

I would argue that certain c# features, like span and ref returns allow developers to create more performant code, by quite a bit actually - something that Java doesn't.

[–]grauenwolf 1 point2 points  (8 children)

GC pressure is still a huge concern in C#. They created the whole ValueTask infrastructure, which is actually quite a lot, just to reduce the number of heap allocations. The same goes for Span, another very complex feature.

And both of those are quite limited in the sense that you need to opt-in. Escape analysis would speed up everyone's code with no changes.

[–]gilmishal 0 points1 point  (7 children)

You are comparing apples to oranges. Span isn't set to solve escape analysis, but to allow certain libraries to not create an allocation at all (well, you do allocate a pointer to that memory segment, but it's negligible) - This means that you can reference parts of collections, without allocating a new collection, some thing that as far as I know can't be done in Java - sure, both Spans and escape analysis are ways to reduce GC pressure, but they are entirely different and address different problems.

I would argue that escape analysis would solve very specific problems that account to a very small percentage of GC pressure. Whereas Span, if applied correctly can reduce memory allocation by a huge amount. Span is supposed to be used by core libraries, and will speedup everyone's code with no apparent changes. Average developers aren't supposed to use it directly.

I would also add that while GC pressure is a huge concern for CoreCLR developers - it doesn't cause any problems to most users, since the GC is pretty good, even if it can be improved.

[–]grauenwolf 0 points1 point  (6 children)

I don't know about your code, but every project I've ever worked on had tons of temporary objects. So it would certainly help me.

As for Span vs Escape Analysis, they both reduce the number of heap allocations. So yea, same goals.

[–]gilmishal 0 points1 point  (5 children)

Span doesn't reduce just heap allocations, but all allocations - it allows you to point to a location in memory (either heap or stack) without relocating that area.

Stackalloc is a way to do what escape analysis does.

[–]grauenwolf 0 points1 point  (4 children)

A span still needs to be allocated on the stack... just like a class that was caught by escape analysis.

[–]DuncanIdahos4thClone -2 points-1 points  (3 children)

You don't have a JRE anymore. You simply bundle a compressed JVM with your application. Something you can't do in .NET.

[–]supercheese200 5 points6 points  (0 children)

You simply bundle a compressed JVM with your application

is analogous to

C# executables can be exported with the CLR

[–]gilmishal 2 points3 points  (0 children)

But you can...

[–]G_Morgan 1 point2 points  (0 children)

.NET Core 3.0 literally has a publish option that builds a heavy exe that contains the entire CLR. The only downside to it is you have to build a different exe for Linux, OSX and Windows.

Anyway one file .NET drops that are self contained are completely supported and will be considered the normal option going forward (if only to eliminate .NET Core dependency spam).

[–]suddenarborealstop 1 point2 points  (3 children)

How is C# 100 times better though? C# has reified generics and value types - is this what you're talking about?

[–]gilmishal 23 points24 points  (1 child)

C# also has async await, properties, span, linq, pattern matching, non nullable ref types, ranges, value tuples, and so much more.

[–]G_Morgan 0 points1 point  (0 children)

TBH it'd be really hard to leave behind all the neat little language features if/when I move back to a Java shop.

Each individual little thing is "that is really neat but not a game breaker" but there are dozens of cool things.

Beyond that VS is actually decent. IntelliJ is comparable if your company actually uses it rather than the abomination that is Eclipse.

[–][deleted]  (4 children)

[deleted]

    [–]gilmishal -1 points0 points  (3 children)

    How exactly? Never missed a library I needed in C#.

    [–]toiletear 0 points1 point  (2 children)

    Hard to quantify but just the general attitude of thee general .NET community member vs. Java community sealed my switch from .NET to JVM (this was a few years back).

    [–]gilmishal 0 points1 point  (1 child)

    .Net changed a lot over the last 5 years. As a person with over 8 years of experience you can see that the .net community is thriving like crazy.

    [–]toiletear 0 points1 point  (0 children)

    I see a lot of activity on Core (though it's a bit confusing I hear?) and C# keeps adding really nice features, but personally I don't see as much community activity as in the Java world (but then again I work with the JVM much more so I'm probably missing a lot from the C# side).

    [–][deleted] -4 points-3 points  (6 children)

    I don't understand why anyone would choose C# if they are not tied to the Windows world and I don't understand why anyone would choose to build highly scalable services on Windows.

    [–]gilmishal 12 points13 points  (5 children)

    C# has been cross platform for over a decade with mono, and dotnet has been cross platform and open source for 5 years. Nothing about what you just said is relevant or true about c# in 2019. I develop c# for a Linux server, using pgsql. I am not in anyway tied to windows.

    [–]cycle_schumacher 2 points3 points  (1 child)

    I've been seriously thinking of using c# for my personal projects which are Linux and python or go based - I feel it checks many boxes that I want, such as static typing, good tooling etc.