Hacker News new | ask | show | jobs
by shartacct 1714 days ago
> (language features, performance gains)

There haven't been any notable language features added since java 9 besides some basic syntax sugar (which is already covered by stuff like lombok anyway).

For features and performance you might as well just target .NET 6. It has things that have been perpetually 'too hard to implement' (read: oracle doesn't want to pay their engineers to impl it and will sue you if you do it yourself) like value types, generics without type erasure, no checked exceptions, etc. and with .NET 6 performance is better than OpenJDK across the board.

6 comments

I’m confused why you’re suddenly talking about .NET.
There's no real reason to use java for new development in 2021.
Java has a better technology stack. The JVM is light-years ahead of the .NET runtime.
Are you referring to its GCs, compilation tiers, or observability? ;)
Err... Not defending Java, but does .NET support Linux at all?
Yes - .NET 5 and 6 both have runtimes and SDKs available for Mac and Linux. At least in my opinion, Linux is the preferred deployment platform for it now unless you have a specific (usually older) library that only works on Windows.
.NET 5 finally delivered Linux support but only eleven months ago, so I would test it some before betting the farm.
> .NET 5 finally delivered Linux support but only eleven months ago

The previous versions in this stream (.NET Core 2.1, .NET Core 3.0 and 3.1) also run fine on Linux. For web server / API server workloads, it's been stable for a lot longer than 11 months, and people do indeed "bet the farm" or "run the business" on it, quite happily.

Technically, this starts with .NET core 2.1 on 2018-05-30. The prior version, 2.0, released on 2017-08-14, wasn't _quite_ there yet although some people were happy with it for production use.

.NET has been on Linux for years now. And my company is using it in production on Kubernetes (Linux/Debian). Its crazy how dependable and fast it is. Startup times are amazing and its only getting better each year. We're looking to upgrade to .NET 6 in production by January.

Have you even seen the benchmarks compared to Java and other languages?

https://www.techempower.com/benchmarks/#section=data-r20&hw=...

If you're not paying attention to .NET its time to get your head out of the sand, seriously.

I've been using it exclusively on Linux since 2.0. Both running and developing.
.NET Core is main support for Linux for .NET
The question was "at all." .Net has been available on Linux for ~18 years.
Yes, since 5 years (.NET Core 1.0)
Yes. It's ported to every mainstream CPU architecture and OS.
Then use Kotlin, and take advantage of the jvm and the ecosystem, and avoid basically all the stuff you listed about the java language.

"no real reason" is a stupid take. I could list multiple, but a big one is that there are hundred java developers for each dotnet developer in my city. The java env is well tested and well understood, if anything one should argue why not use it instead of a hip and trendy alternative.

Their point about using .NET were not really valid since one of the big and best reason to use Java is that you already have a Java codebase, but things like value types and generics without type erasure aren't solved in Kotlin, so Kotlin isn't really a good answer to his not really valid point.
> things like value types and generics without type erasure aren't solved in Kotlin

Perhaps not solved, but at least partially addressed with value classes[1] and reified type parameters[2].

[1] https://kotlinlang.org/docs/inline-classes.html

[2] https://kotlinlang.org/docs/inline-functions.html#reified-ty...

> take advantage of the jvm

In what way? It's slower and has less features than the .NET runtime.

> "no real reason" is a stupid take. I could list multiple, but a big one is that there are hundred java developers for each dotnet developer in my city. The java env is well tested and well understood, if anything one should argue why not use it instead of a hip and trendy alternative.

So, your only credible excuse for using java is inertia from boomers and middle managers refusing to adapt from the standard of the early and mid 2000s?

> So, your only credible excuse for using java is inertia from boomers and middle managers refusing to adapt from the standard of the early and mid 2000s?

If you come in and freely migrate all of the Java codebases to .NET while maintaining code quality and functionalities, I'm sure many people would let you do it. If you don't understand why people stick to one language, that means that you've never worked on a big codebase, or completly ignore the business side of the developer job. In both cases, that's a lack of wisdom on your part.

I guess you missed the 'new development' part of my original comment? Obviously it would be nonsensical to port a large extant codebase to a new language and tech stack if it's just being maintained.
Here is one real reason to prefer it over .NET Core: https://github.com/dotnet/sdk/issues/6145
why actually? what does it send?
In the past it has sent command line arguments and the path of the current working directory, among other things, according to comments on that issue. Even if Microsoft doesn't intend to deliberately collect sensitive data, they don't seem to think it's worth putting much effort into preventing accidental data leaks from broken anonymization, unreliable opt-out mechanism, etc.
Java is way better than .net, which nobody at all uses outside MS. Certainly not in enterprise.
> Certainly not in enterprise.

Lots of people use .NET in enterprise, I don't know where you got that impression.

There's tons of .net usage in enterprise, what are you talking about?
>Certainly not in enterprise.

pretty odd take, in which country?

yeah, you got it. My city has very little job listings requiring .NET for actual back-ends. Whereas, there are like a thousand Java jobs and almost half mentioning Spring
These discussions inevitably end up as a flame war sooner or later.

Regardless, i actually compared Java with .NET and their web frameworks as a part of my bachelors', everything from synthetic benchmarks for encryption and data processing and transformations, to things like shuffling JSON around. Now, it's all in Latvian and was a number of years ago, so it's not entirely relevant at this point, but i did have some tangible findings.

In short:

  - both Java and .NET (then Core) are inconsistent in their performance - there are certain things which are slower in one technology than other by not using external optimized libraries. For example, Java had problems with writing deeply nested dynamically generated JSON with JavaEE libraries (now Jakarta), whereas .NET Core had problems with handling large amounts of text
  - their performance was largely comparable in most other tests, neither was faster by a factor of 10, like you'd see with Python and Ruby compared to either
  - thus, it's largely a matter of choosing the actual frameworks that you'll want to utilize properly and consider both the job market and business factors (familiarity with the tech stack, job market etc.)
  - in summary, they're close enough for it to not be a technical decision most of the time in real world circumstances (save for a few exceptions), but rather is a decision that depends on social elements
Since then:

  - i don't believe that the observation of them being "close enough" has changed much, both in legacy code and otherwise
  - .NET Core and now .NET 6 has improved bunches with its runtime; Core was so successful it's essentially the future of the platform (i feel bad for developers who'll be tricked into working on legacy code with the old .NET and IIS, versus the new one and Kestrel)
  - JDK has improved bunches with its runtime and GC; the runtime situation is a bit complicated and cumbersome, considering the OP's article, but overall it's pretty usable, especially with frameworks like Quarkus
If you care about benchmarks and vaguely realistic performance comparisons in the current year, simply have a look at the TechEmpower benchmarks: https://www.techempower.com/benchmarks/#section=data-r20&hw=...

If you jump around the different tabs that compare which frameworks do what better, on average:

  - .NET is better for plain text
  - .NET is noticeably better for data updates
  - Java is noticeably better for JSON serialization
  - Java is noticeably better for single DB queries
  - Java is noticeably better for multiple DB queries
  - as for cached queries and other use cases, there's more variance
  - neither is better than the other for it to matter a lot
These are probably better than me linking the bachelors' because it's done in a better controlled environment, with more resources, and a lot of people contributing to the source code of the benchmarks: https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast...

In short, you're not necessarily wrong - there have indeed been great improvements to the .NET platform and it's good to see it finally being a capable and performant tech stack that you can use on *nix. But you're also not right: Java is getting similar attention, even though it's still lagging behind a few years in regards to "having its stuff together" (e.g. going from Oracle JDK to a more stable model + the JDK 8 to newer version shift, which is similarly painful with old .NET versions).

To lighten the mood, i'd consider suggesting that anyone also have a look at Go, which is similarly performant and allows you to build runtime independent executables by default, which is easier than in either .NET or Java. It's also pretty easy to write and has seen good use for the development of tools, since its startup time is a tad better than either that of Java or .NET as well. Here's the three compared: https://www.techempower.com/benchmarks/#section=data-r20&hw=...

As if implementing value types in a backwards compatible way that also modifies generics to work with them would be a trivial task..

Also, Oracle does pay plenty for the development of Java, and is a (surprisingly) good steward of the language, let’s drop all the blind hate.

And both in terms of GC and JIT, the JVM ecosystem is ahead, the reason they can be so head-to-head is that the CLR doesn’t hide lower level controls all that much, allowing for better hand-tuned programs (at the price of the resulting code not getting “automatically” faster in a possible future release)

> read: oracle doesn't want to pay their engineers to impl it and will sue you if you do it yourself) like value types, generics without type erasure, no checked exceptions, etc.

All of this is currently being implemented in project Valhalla...

I never buy into the tech stack argument that things are being worked on (e.g you mention Project Vahalla but I see this across many languages and tools). Seen this argument used on a number of different technologies. It compares a future state to a current state to put the favored tech (the future state) in an equal or better position. It usually punishes innovative platforms as well; because it dismisses any reason to take them up.

It's comparing apples to oranges - in this case .NET is also being actively worked on so may have other things by then. Compare current state only.

The truth is each platform has prioritized features relevant to its context. For what its worth in my experience while the JVM has many more JIT optimisations and the like it tends to need them more of them given the lack of some of those features you mention (e.g. value types). Whereas .NET code allows value types, better management of memory (i.e. Span), reified generics etc so the focus has been to allow the user to optimise themselves where required where still allowing for a decent performance default. Many of the optimisations in the JVM wouldn't have the same bang for buck in .NET and vice versa.

On a personal note I'm more of a fan of the .NET philosophy because the code is usually fast enough, and when I need to tune memory, avoid allocations, and do fast code it seems to offer more tools not in an unsafe context to do so. It allows a better "upper bound" of performance for core things IMO while keeping to bytecode/IL. Many benchmarks where the same level of application optimisation has occured from what I seen have confirmed this bias for me. YMMV

You’re missing the point. He claimed Oracle refuses to develop these features or will sue you if you do it yourself (they hired the guy who implemented fibers to implement them in the jvm), but they are actively working on it. The point of my comment was that OP’s claim was just patently false. I wasn’t claiming the JVM has feature parity or is better or anything of the sort.
Valhalla isn't anywhere near complete and has been in development for 8+ years, C# had these features before valhalla was even planned.
But they ARE working on them and they ARE paying their engineeers to do it. They even hired pron to implement fibers in the jvm and didn’t sue him for doing it in quasar, which is the opposite of what you’re claiming.
Records, switch expressions, multi line strings and that is only language changes.

You could call `+` syntatic sugar, just like anything past assembler being that.

> Records, switch expressions, multi line strings and that is only language changes.

None of those are features, they were desperately needed shorthands for common java idioms. This is like calling braceless if/for/while statements 'features', when they're purely syntax sugar that has fallen out of favor completely because there's been several major security vulns found in major projects due to their use and development oversight/code review failure (https://nakedsecurity.sophos.com/2014/02/24/anatomy-of-a-got...), to the point where most companies ban writing them.

Just off the top of my head:

* LINQ. Added to C# in 2007, Java didn't get streams until 2014.

* structs/value types, implemented in net framework and net core for 15+ years, but not present in java 17. Some oracle engineers have been working to implement them under project valhalla but it seems to be vaporware at this point after 8+ years of work.

* unsigned types, no plans to implement in java (though IIRC it was originally planned as part of valhalla)

* async/await

At the feature level Java is stuck in the mid 2000s. Nobody wants to do the actual work on keeping it competitive.

> async/await

Thank God they didn't shove this crap in. When Loom ships (I believe the next LTS is their target, more or less), JVM will have the same concurrency story as Go does, without blue/green function split like in C#.

> unsigned types, no plans to implement in java (though IIRC it was originally planned as part of valhalla)

Not too comfortable to use functions that will compile to efficient byte code exists for them, but with the definitely coming Valhalla, it will be trivial to create a custom primitive class for unsigned ints.

> async/await

With project Loom, it will avoid the mistake of function coloring that async introduces. In a managed language, why not let the runtime automatically transform blocking calls to non-blocking, when it already knows what’s up?

> With project Loom, it will avoid the mistake of function coloring that async introduces. In a managed language, why not let the runtime automatically transform blocking calls to non-blocking, when it already knows what’s up?

Not saying it's a good or bad thing, but .NET and C# by extension has had these features for years (decades in some cases) while the only thing java has are half-baked prototypes and plans to 'maybe' implement things. In many cases these plans just get endlessly pushed back and new java major versions just become a pile of simple bugfixes which in the past were just pushed as minor jre updates.

It’s not like async/await is a must, they are on the surface just syntactic sugar.

In the background, coroutines are a strictly less useful feature than what will happen with Loom, and please show me any “promised feature” that were only half-baked prototypes? We do have one half of Valhalla (vector api) under an experimental flag with JDK 17 already, several language related JEPs were shipped already. That Loom and primitive classes take their time only mean that they are not vaporware, because these are actually ridiculously complex problems.

With your explanation everything is just a shorthand. All you really need is NAND.

Streams are a library feature, records are a language feature. Streams could be implemented outside, records could not (no lombok abominations are not records).

comparing braces to records/multi line strings/switch expressions is so funny that I won't even comment on that.

any references/benchmarks for some realworld apps/services? and also what do you mean by oracle suing if you implement value types?
> any references/benchmarks for some realworld apps/services?

.NET 6 is vastly more performant than .NET 5, which was already faster than openjdk and openj9 (https://devblogs.microsoft.com/dotnet/performance-improvemen...)

> and also what do you mean by oracle suing if you implement value types?

this one shouldn't need an explanation, oracle very commonly pursues frivolous lawsuits as a way of bullying money out of businesses that don't have the budget to fight them for years in various courts.

where does it say .net 5 was faster than openjdk? hotspot is a very sophisticated jit compiler that has probably 100 manyears put into it just in optimizations. given that .net added monomorphic/bimorphic call site devirtualization recently which is considered quite basic in the hotspot, it would be good to see real world usage comparison.
Where required there are ways to force it to inline/devirtualise yourself. For example using refied generics is one way I've seen - i.e. there is no interface/virtual casting since it takes a type that implements interface, rather than the interface itself. It allows you to make polymorphism compile time rather than runtime. Seem comparison libraries to Java (closed source) that have run much faster as a result.

I do find people comparing Java and .NET Core often are compare apples to oranges however. Working on both languages it is just my opinion but the .NET platform is newer - it has a better "base" even without the same man hours. Much of the engineering time in both ecosystems is spent optimising for code typical to that ecosystem which is affected by history/legacy like any other software system.

I don't see any mention of Java in the article you linked, do you have any source on .NET being faster?