News for hackers. Stuff that matters.
Re:Guide to Java Virtual Threads by DeathArrow on Thursday March 16, 2023 @05:44AM (#35179925)
Not only async, but C# had LINQ, lambdas, records, pattern matching, pointers, hardware instructions via intrinsics, stackalloc etc. before similar constructs came into Java, if they ever did.

Probably there are examples where Java introduced something first, but I don't know because I'm not so well versed in Java.

While similar and inspired by Java, I do prefer C# because is less verbose, requires less boiler plate, it generally has only one proper way to do things and is kind of jack of all trades, in the sense you can tackle any area of programming besides very low level systems programming - and It quite can reach that point, too if there will be a way to disable GC and allow manual memory management.

Web backend - check, web frontend - check, mobile apps - check, desktop - check, multi platform - check, embedded - check, games - check, VM - check, native AOT - check.

It also looks great in benchmarks: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

I am biased but since I recognize it, maybe you shouldn't downvote me just for that. :)

And what's even better than C# is F#, but that's too bad nobody likes functional programming or hire programmers to use functional languages.

Re:Guide to Java Virtual Threads by krzyk on Thursday March 16, 2023 @06:53AM (#35180322)
> Not only async, but C# had LINQ, lambdas, records, pattern matching, pointers, hardware instructions via intrinsics, stackalloc etc. before similar constructs came into Java, if they ever did.

Just a clarification regarding one statement which I know for sure is not true: Java team started working on records before C# started similar work.

I don't know about the rest.

Re:Guide to Java Virtual Threads by shellac on Thursday March 16, 2023 @07:29AM (#35180619)
And pattern matching was started in java first (goes hand-in-hand with records to some extent).
Re:Guide to Java Virtual Threads by pron on Thursday March 16, 2023 @07:17AM (#35180525)
There's plenty of stuff Java did first (or only) -- an optimising JIT, two new generations of GC (G1, ZGC--a low latency GC with <1ms max pause time), low-overhead deep profiling (Java Flight Recorder) -- but they're all in the runtime. Java's strategy since the beginning has always been to innovate on the platform and be a last-mover on the language, keeping it conservative. .NET seems to follow an opposite strategy.

That's how we've been able to avoid properties and just have algebraic data types, avoid async/await and do virtual threads, avoid string interpolation and just have safe string templates. This also allows us to keep the number of features in the language relatively low -- as we, and most of our users, like it.

Re:Guide to Java Virtual Threads by DeathArrow on Thursday March 16, 2023 @07:38AM (#35180672)
I'm sure Java dis some things first, as I said. It's great that you mention some.

>That's how we've been able to avoid properties and just have algebraic data types By algebraic data types you mean product types or sum types?

Re:Guide to Java Virtual Threads by wathef on Thursday March 16, 2023 @08:47AM (#35181162)
Both of those (sum and products) are ADTs.
Re:Guide to Java Virtual Threads by pron on Thursday March 16, 2023 @09:22AM (#35181584)
Both. Java has records for products, sealed hierarchies for sums, and offers pattern matching over them. See https://www.infoq.com/articles/data-oriented-programming-jav...
Re:Guide to Java Virtual Threads by DeathArrow on Friday March 17, 2023 @05:44AM (#35194998)
>sealed hierarchies for sums

I wouldn't call that a good example of sum types. You can use sealed classes or other mechanism in C# to emulate sum types. I was thinking about something built in the language.

Example:

type IntOrBool = | I of int | B of bool

Re:Guide to Java Virtual Threads by pron on Friday March 17, 2023 @07:03AM (#35195433)
It's built into the language and the VM (the VM enforces the "sealedness", and pattern matching uses it for exhaustiveness checks). It's just that all types in Java are nominal.
Re:Guide to Java Virtual Threads by xmcqdpt2 on Thursday March 16, 2023 @07:24AM (#35180571)
> And what's even better than C# is F#, but that's too bad nobody likes functional programming or hire programmers to use functional languages.

In JVM land there is Scala and people do hire for it, more so than any other typed FP language, AFAIK.

Re:Guide to Java Virtual Threads by vips7L on Thursday March 16, 2023 @07:24AM (#35180578)
Have you looked at the source of some of the C# benchmarks? I don’t believe they’re representative of how one would actually write C#. They’re all extremely hand tuned using raw pointers and unsafe blocks. The regex benchmark actually just delegates to a C library over FFI.
Re:Guide to Java Virtual Threads by vijucat on Saturday March 18, 2023 @11:10AM (#35209702)
Yes! It was distrust towards Microsoft that kept .NET from growing to be a universal language and kept Java in the game, to be honest. The language / framework, per se, is to be celebrated as a great leap forward borne out of the good kind of competition.