News for hackers. Stuff that matters.
Re:Was Rust Worth It? by tkubacki on Thursday October 26, 2023 @02:47AM (#38022498)
I used to be .NET dev and don't agree. Couple of reaons:

1) Modern Java is almost as good as C# with some things I can't give up in Java (static imports => succint code, Groovy Spock => succint tests)

2) Kotlin is better than C#

3) JVM has much much bigger ecosystem (almost all the apache projects are JVM oriented) and default web framework is much less code to type (SpringBoot) is much more productiv

4) JVM has wider variety of langs

For those reasons IMHO if you are small-mid company (or startup) it's wiser to choose JVM.

Re:Was Rust Worth It? by pjmlp on Thursday October 26, 2023 @03:28AM (#38022764)
Kind of, maybe you need to do some low level coding and don't want to wait for Valhala, or make use of JNI and native libraries, GraalVM/OpenJ9 still aren't as integrated as .NET Native or Native AOT, e.g. writing native shared libraries.

Also Java lost the attention span of the gaming industry, besides Android casual games and Minecraft, there are hardly anyone else paying attention to it.

Re:Was Rust Worth It? by Ygg2 on Thursday October 26, 2023 @04:23AM (#38023114)
To be fair, C# is ok for game dev, but not great. C# libraries are lagging heavily behind Java.

Want a fastest possible library? It's in C++, and not portable to Win/Mac. So good luck with wrap + porting it.

Want a decent implementation of an algo? It usually exists for Java but not for C#. Hope you like writing it from scratch.

Want a C# implementation of an algo that doesn't allocate to the Nth degree. Again, write it yourself.

But ok, maybe Unity has a good ecosystem... And they fucked it over a barrel.

Re:Was Rust Worth It? by pjmlp on Thursday October 26, 2023 @04:40AM (#38023221)
It is widely better recieved in the AAA gaming developer community than Java, and that is what matters.

I also like Java, but c'mon no decent algorithms being implemented in C#? That is already approaching zealotry.

Re:Was Rust Worth It? by Ygg2 on Thursday October 26, 2023 @05:26AM (#38023486)
I didn't say no decent algorithm in C#, but for each performance sensitive algorithm/data structure there is a C and Java implementation at the least ( in my case Roaring Bitmaps).

In C# the solution is half baked or archived or abuses allocation.

I think Unity has way more with C# adoption in game dev than innate C# qualities.

Re:Was Rust Worth It? by neonsunset on Thursday October 26, 2023 @05:44AM (#38023579)
This is a classic case of goalpost moving. The reason why so many algorithms are written in Java especially closer to academic side is because most curriculums in comp-sci often straight up not allow using anything else except Java, Python or sometimes C++. Having C# as an alternative in these is a luxury. There are also more people using Java in general. However, this does not make it a better language at solving these tasks, nor it is any suitable for writing high performance implementations for advanced vectorized algorithms which would push hardware, which is actually what you want when you start caring about such scenarios, which C# excels at.
Re:Was Rust Worth It? by Ygg2 on Thursday October 26, 2023 @10:15AM (#38025883)
I'm not moving the goalpost. I explained my examples in another reply. Want to write an engine mostly from scratch in C# and you need libraries that are low on allocation and for niche data/algorithms that games need? You're going to have a bad time(TM).

Sure you could use YAML parser, but it allocates everyone and their mother. Can you find a Fluent localization in C#? Sure, but its outdated and archived. Ok, but basic RoaringBitmap implementation? The repo is archived and not fully complete.

Why C# is used in game dev is incidental. It has more to do with Unity and XNA/FNA than any concrete quality of language modulo value types (but then again, most C# libraries don't focus on avoiding allocation and are just as happy as Java to construct a complicated hierarchy of classes).

Re:Was Rust Worth It? by mpawelski on Thursday October 26, 2023 @04:58AM (#38023335)
Java is surely keeping up but I can't name single Java feature that I miss in C# or is implemented better in Java. I haven't used Java in a long time though, just occasionally I read about new Java features and I've never said to myself "cool, I wish I had it in C#".

Static import are also available in C# for quite some time now (c# 6, released in 2015, and in C# 10 you can even make this import global for for project).

I haven't used Kotlin, is there any killer feature compared to C#? (except more succinct code in certain cases?)

Re:Was Rust Worth It? by pjmlp on Thursday October 26, 2023 @05:50AM (#38023606)
Depending on how you look at it, better extension everything support on Kotlin's case, and a way to do DU, while it keeps being discussed for C#, people should just add F# to their codebase, but alas.
Re:Was Rust Worth It? by tkubacki on Thursday October 26, 2023 @02:50PM (#38030098)
Kotlin is younger and made better choices by default, like immutable "val" as default option.

Also since it's Jetbrains - IDE integration is superior compared to anything C# can have (including Rider...)

Re:Was Rust Worth It? by lenkite on Thursday October 26, 2023 @05:20AM (#38023456)
Also with JDK 21 - you can use virtual threads. No need for async/await which IMHO is a design mistake. Java copied Go here instead of C#.
Re:Was Rust Worth It? by metaltyphoon on Thursday October 26, 2023 @09:19PM (#38033630)
Which makes C interop worse, just like Go
Re:Was Rust Worth It? by Const-me on Thursday October 26, 2023 @08:16AM (#38024526)
I think Java is only good for long-running servers.

Java doesn’t support C interop. For many desktop and embedded projects this is a showstopper, here’s an example https://github.com/Const-me/Vrmac/tree/master/VrmacVideo That C# code directly consumes V4L2 and ASIO Linux kernel APIs, and calls unmanaged user-mode DLLs like libfdk-aac.so and liba52-0.7.4.so.

Native stack and value types in C# reduce load on GC, and the number of complicated tricks required from JIT compiler. This in turn helps with startup performance. This is critical for command-line apps, and very desirable for desktop apps.

Another thing missing in Java is intrinsics support, both scalar like popcnt, bitscan, BMI, etc., and SIMD like SSE and AVX.

Re:Was Rust Worth It? by generichuman on Thursday October 26, 2023 @12:29PM (#38027957)
Projects Panama & Valhalla seems to solve all your complaints:

> Java doesn’t support C interop. For many desktop and embedded projects this is a showstopper, here’s an example https://github.com/Const-me/Vrmac/tree/master/VrmacVideo That C# code directly consumes V4L2 and ASIO Linux kernel APIs, and calls unmanaged user-mode DLLs like libfdk-aac.so and liba52-0.7.4.so.

Part of Panama: check out the "Foreign Function & Memory API" [0]. The official docs [1] say it is a preview in 21 but it got stabilized in Java 22 (isn't out yet).

> Another thing missing in Java is intrinsics support, both scalar like popcnt, bitscan, BMI, etc., and SIMD like SSE and AVX.

Also part of Panama: see the "Vector API" JEP [2].

> Native stack and value types in C# reduce load on GC, and the number of complicated tricks required from JIT compiler. This in turn helps with startup performance. This is critical for command-line apps, and very desirable for desktop apps.

This is part of Project Valhalla [3], they're adding value types and actual generics, among other things.

That said, most of these are not done / not in a stable LTS Java release yet. We'll see how much better it'll be compared to C# (if at all) once they land.

[0] https://openjdk.org/jeps/454

[1] https://docs.oracle.com/en/java/javase/21/core/foreign-funct...

[2] https://openjdk.org/jeps/460

[3] https://openjdk.org/projects/valhalla/

Re:Was Rust Worth It? by Const-me on Thursday October 26, 2023 @01:23PM (#38028775)
> Part of Panama

Most real-live C APIs are using function pointers and/or complicated data structures. Here’s couple real-life examples defined by Linux kernel developers who made V4L2 API: [0], [1] The first of them contains a union in C version, i.e. different structures are at the same memory addresses. Note C# delivers the level of usability similar to C or C++: we simply define structures, and access these fields. Not sure this is gonna be easy in Java even after all these proposals arrive.

For a managed runtime, unmanaged interop is a huge feature which affects all levels of the stack: type system in the language for value types, GC to be able to temporarily pin objects passed to native code (making copies is prohibitively slow for use cases like video processing), code generator to convert managed delegates to C function pointers and vice versa, error handling to automatically convert between exceptions and integer status codes at the API boundary, and more. Gonna be very hard to add into the existing language like Java.

> "Vector API" JEP

That API is not good. They don’t expose hardware instructions, instead they have invented some platform-agnostic API and implemented graceful degradation.

This means the applicability is likely to be limited to pure vertical operations processing FP32 or FP64 numbers. The rest of the SIMD instructions are too different between architectures. A simple example in C++ is [2], see [3] for the context. That example is trivial to port to modern C#, but impossible to port to Java even after the proposed changes. The key part of the implementation is psadbw instruction, which is very specific to SSE2/AVX2 and these vector APIs don’t have an equivalent. Apart from reduction, other problematic operations are shuffles, saturating integer math, and some memory access patterns (gathers in AVX2, transposed loads/stores on NEON).

> most of these are not done / not in a stable LTS Java release yet

BTW, SIMD intrinsics arrived to C# in 2019 (.NET Core 3.0 released in 2019), and unmanaged interop support is available since the very first 1.0 version.

[0] https://github.com/Const-me/Vrmac/blob/master/VrmacVideo/Lin...

[1] https://github.com/Const-me/Vrmac/blob/master/VrmacVideo/Lin...

[2] https://gist.github.com/Const-me/3ade77faad47f0fbb0538965ae7...

[3] https://news.ycombinator.com/item?id=36618344

Re:Was Rust Worth It? by tkubacki on Friday October 27, 2023 @12:11AM (#38034604)
Well maybe you should use C++ or Rust instead of Java or C# in that case?

My point is if you are doing business (especially web) apps. Use one of JVM langs insted of C# because ecosystem is much bigger (and it has fresher langs as well like Kotlin - if that's what you care about)

Re:Was Rust Worth It? by Const-me on Friday October 27, 2023 @09:09AM (#38037946)
> use C++ or Rust instead of Java or C# in that case?

Despite having to spend extra time translating C API headers into C#, the productivity gains of the higher-level memory safe language were enormous.

Another example, I have shipped commercial embedded software running on ARM Linux, and based on .NET Core runtime. The major parts of the implementation were written in idiomatic memory-safe C#.

> doing business (especially web) apps

Well, these business web apps are precisely the long-running servers I have mentioned. Still, the software ecosystem is not limited to that class of problems, and due to different tradeoffs Java is not great for anything else.

Re:Was Rust Worth It? by hiAndrewQuinn on Saturday October 28, 2023 @12:56AM (#38047265)
#1 => agree

#2 => don't know enough about Kotlin to comment

#3 => agree but quality > quantity

#4 => not terribly important to me (Clojure is cool but it's not "switch to the JVM" level cool)