4 ms·
Not only async, but C# had LINQ, lambdas, records, pattern matching, pointers, hardware instructions via intrinsics, stackalloc etc. before similar constructs
by DeathArrow 4y ago
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/fastest/csharp.html 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.
- krzyk 4y ago> 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.
- shellac 4y agoAnd pattern matching was started in java first (goes hand-in-hand with records to some extent).
- pron 4y agoThere'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.
- DeathArrow 4y agoI'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?
- wathef 4y agoBoth of those (sum and products) are ADTs.
- pron 4y agoBoth. Java has records for products, sealed hierarchies for sums, and offers pattern matching over them. See https://www.infoq.com/articles/data-oriented-programming-java/ https://www.infoq.com/articles/data-oriented-programming-jav...
- DeathArrow 4y ago>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
- pron 4y agoIt'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.
- xmcqdpt2 4y ago> 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.
- vips7L 4y agoHave 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.
- vijucat 4y agoYes! 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.