5 ms·
C# is underrated by the HN crowd, I find. I quite like how mid sized firms (100-1000 employees) use it.
by hiAndrewQuinn 3y ago
C# is underrated by the HN crowd, I find. I quite like how mid sized firms (100-1000 employees) use it.
- eddtries 3y agoI've always found those sort of firms with C#, in my experience, have the best architected code. Proper domain-driven design, onion architectures, clean testable code... Some have legacy issues where they might not have the most cutting edge CI/CD pipeline or high automated test coverage, but the code itself can be very nice. I've never really experienced that level of consistency with a different language/company size.
- tkubacki 3y agoI 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.
- hiAndrewQuinn 3y ago#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)
- pjmlp 3y agoKind 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.
- Ygg2 3y agoTo 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.
- pjmlp 3y agoIt 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.
- Ygg2 3y agoI 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.
- neonsunset 3y agoThis 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.
- mpawelski 3y agoJava 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?)
- pjmlp 3y agoDepending 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.
- tkubacki 3y agoKotlin 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...)
- lenkite 3y agoAlso 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#.
- metaltyphoon 3y agoWhich makes C interop worse, just like Go
- Const-me 3y agoI 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 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.
- generichuman 3y agoProjects 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 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 https://openjdk.org/jeps/454 [1] https://docs.oracle.com/en/java/javase/21/core/foreign-function-and-memory-api.html https://docs.oracle.com/en/java/javase/21/core/foreign-funct... [2] https://openjdk.org/jeps/460 https://openjdk.org/jeps/460 [3] https://openjdk.org/projects/valhalla/ https://openjdk.org/projects/valhalla/
- 3y ago
- hutattedonmyarm 3y agoIs it? Every time I see C# being mentioned here people agree how awesome it is. Not that I'm complaining, I love C#
- GuestHNUser 3y agoAgreed. I feel C# is appropriately rated on HN and other programming forums. It has perfomant memory options that other GC languages lack, and great builtin packages to use. Overall, it is a good language. My biggest issue with C# though is how badly exceptions are handled given that it is a statically typed langauge. I wish functions explicitly defined the exceptions it can throw since a minor package bump could add an exception without your compiler warning you that it isn't handled. I much prefer Rust, Go and Zig's error handling to C#'s since those kind of issues don't happen.
- pjmlp 3y ago> It has perfomant memory options that other GC languages lack, and great builtin packages to use. As clarification for the audience, it isn't the only GC enabled language with C and C++ like capabilities, in fact there are several examples since the early 1980's. The adoption push for Java and scripting languages distorced the understanding of what was already available out there.
- Rapzid 3y agoWell, I see it as lack of fanboyism which is interesting and almost unique to the Java/C# ecosystem. A lot C# experts(and I mean REAL, low level experts) seem to also have very high Java expertise.. And those that have Java expertise but not C# seem to demur to those that do; image! But it's still niche(around here and in the startup world) and gets lumped in with Java and together they are not "hip" or "agile" or whatever.
- leeman2016 3y agoC# is a lovely language to work with. The only issue I have is with the .NET ... that is, building self-contained binaries to distribute. For comparison: * Hello World win-x64 binary self-contained in .NET 7 is around 70 MB * The same for Go results in 1.2 MB Edit: Missed 'trimming' in .NET, which would result in a binary of size around 11 MB in win-x64
- pjmlp 3y agoUsually that means you aren't using trimming, .NET speak for dead code removal during linking. Also remember that standard .NET runtime does a little bit more than Go's runtime, so it might happen that even with trimming, for basic applications Go ends up having an upper hand on file size. On the other hand, I have had Go static binaries grow up to 200 MB and being require to use UPX to make it manageable, e.g. trivy.
- leeman2016 3y agoYou're right. But even with trimming I get around 10x the size of the Go binary
- pjmlp 3y agoSince I edited my comment, see my additional remarks regarding runtime capabilities, and the counterpoint of big Go binaries. Also note that triming only works properly if the libraries have taken the effort to be trimmable, as the linker errs on the safe side and won't trim unless certain that it is really dead code, and not called via reflection.
- neonsunset 3y agodotnet publish -c release -p:PublishAot=true
- neonsunset 3y agoThis is an unfair comparison of apples to oranges by building the binary with the wrong flags. .NET produces smaller binaries than Go with NativeAOT (despite including more features).
- Ygg2 3y agoC# is fine, but it feels like a slightly better Java, just without the huge ecosystem of libraries.
- Rapzid 3y agoSlightly... The difference in type erasure is pretty huge IMHO. But what libraries are you lacking?
- Ygg2 3y agoType reification is planned and so is value types. And type erasure isn't as negative as you seem to make it. Bunch of really obscure use cases - fluent localization, roaring bitmaps and so on.