3 ms·
> Maybe, but Java programmer would have a lot of issues the moment they go beyond regular LOB application code. Nope, I wrote a zero copy parser for a game loc
by Ygg2 2y ago
> Maybe, but Java programmer would have a lot of issues the moment they go beyond regular LOB application code.
Nope, I wrote a zero copy parser for a game localization. C# is essentially Java with value types, reified generics and some other nifty features (extension methods, stuff like `stackalloc` etc.).
> And no, C# has generics, like in Rust, while Java has "generics".
While I agree to there is some difference in behaviour, most of the time it's not important. The difference starts with method/argument overloading, and generic type information at runtime.
> I find the mention of .NET origins as an argument unfortunate, because events that happened more than 20 years ago have no relevance whatsoever to what .NET (the non-Framework one) is today.
If that's the case, the same can be said of this argument. Java is working towards reified generics and value types, the biggest distinctions between C# and Java.
Knowing how we got here and why is important.
> C# extension methods are Rust associated functions.
They aren't. In Rust: Define an implementation of struct outside its owning crate.
> Also, C# has Kotlin-style nullability, but nullable structs (e.g. int?) are a sugar for Nullable<T> which is similar to Rust's Option<T>
Similar yes, but hey a dolphin and a pig are similar - genetically. In practice, Rust is built around the Option<T>, while Nullable<T> feels like absolute kludge especially with ref vs value types.
> In general, if you think that low-level and performance-oriented features are comparable with Java, I'd like to ask you to look into this again.
I didn't ever say that. Sure, it has some low-level perf oriented features. Java is working towards adding them (in a way that doesn't break compatibility). You can write performance oriented code in Java, however it's much harder compared to C#.
Coding high-perf C# code is similarly like a bit of a different dialect, and not most help from other libs.
- neonsunset 2y agoYou must be trolling and not evaluating either on their current state, or have little understanding of the subject matter as others have pointed out. Please write an efficient text element scanner that uses all AVX512 vector width in Java that matches LLVM codegen and can take any* source of memory? You can easily do that in C#, it's impossible to do it in Java alone. https://github.com/dotnet/runtime/blob/7cd8459e7bd3883f0aa86961c518948630dc2e49/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs#L1566-L1577 https://github.com/dotnet/runtime/blob/7cd8459e7bd3883f0aa86... (it uses portable SIMD and monomorphized generics to express negation to deduplicate vectorized paths, just like you would do so in Rust, except it doesn't have portable SIMD in its standard library yet) *C# 'ref' variables also known as byrefs also work as special GC-aware pointers which can target any memory - stack, GC heap or anything else including unmanaged source and GC is able to disambiguate that and handle that in a performant manner during mark and sweep. This way you can pass a slice from Rust, construct a Span<T> from its ptr and length and then transparently interoperate with the rest of CoreLib, you could do so with the pointers already to an extent, but those required object pinning which was undesirable for something that would be used so ubiquitously in the code that 99% of users end up utilizing without realizing so.
- Ygg2 2y ago> You must be trolling and not evaluating either on their current state I'm not trolling, are you projecting? You don't seem to understand the difference between Rust trait and C# interface, and confuse extension methods for `impl` blocks. I'm evaluating on the current state of the LANGUAGE, not the LIBRARIES. Likewise, I do this because language syntax changes tend to be much slower than libraries. Think of it this way: In one year or twenty, Java and C# will have GC, while Rust will not (at least not by default), versus C# having Portable SIMD and Java and Rust not having it atm. I'm searching for truths that hold for as long as possible. > Please write an efficient text element scanner that uses all AVX512 you can easily do that in C#, it's impossible to do it in Java alone. You can use the Vector API (see https://openjdk.org/jeps/469 https://openjdk.org/jeps/469). See what I mean, when I say talking about something that's unlikely to change? If you were using older versions of Java you would abuse primitive types/ Unsafe package to get extra performance, and yes, dip into JNI if you really need some SIMD tricks. Yes, please tell me more about Span/ReadOnlySpan C# it's not like I wrote a parser (re)using them ad infinitum... /sarcasm The problem with C# and low-level coding, is that in GC-free C# land, you're on your own. Libraries are missing (i.e. they allocate a lot) or proprietary, Nullable is a horrible compromise, and C# enums are a joke compared to ADTs.
- neonsunset 2y agoPlease try using Vector API in Java, tell me how it goes (you demonstrably have no idea what you are talking about if you compare these with C# SIMD or think ADTs are not expressible in C#, I guess my last few years of experience with it were a mirage). But I will argue with you no more, you are welcome to stay in the swamp.
- Ygg2 2y ago> You demonstrably have no idea what you are talking about. Do you? You said you can't use AVX512 in Java I pointed out, yes you can. Especially now, but support for auto vectorization in Java has existed for quite some time. Also you have demonstrably no idea what ADTs are if you think you can use both sum and product types in C# see https://github.com/dotnet/csharplang/issues/113 https://github.com/dotnet/csharplang/issues/113 You argue that Rust a no-GC language is going to be similar to a GC language, especially one that was designed as direct competitor to Java? You're going to have to have post more proof than that. Sure Rust copied C# syntax, and C# copied some stuff from Rust, but C# copied way more of Java's semantics/syntax. You never addressed issues like way generics, trait and impl blocks work in Rust. You never addressed existence of inheritance in C#/Java. Or Rust trait solver or it's tagged (enum)/untagged unions. Nor its borrow checker, nor its AutoTraits, nor its Affine types. I've tried to argue with you in good faith, but you seem to have some issue with projecting your own issues onto me. > Please write an efficient text element scanner that uses AVX512 Here you go: https://github.com/simdjson/simdjson-java https://github.com/simdjson/simdjson-java