2 ms·
C# has some at least some slight advantages to Java for the Linux ecosystem when building complex applications where you want a garbage collected and at-least s
by WorldMaker 8y ago
C# has some at least some slight advantages to Java for the Linux ecosystem when building complex applications where you want a garbage collected and at-least semi-portable application.
1) C#'s interface to C/C++ (P/Invoke or Platform Invoke) is generally easier than the Java equivalent (JNI or Java Native Interfaces).
2) C#'s interface to COM and COM-like systems (Bonobo and Gnome/Gtk's GObject world, for instance) is a little bit stronger and again somewhat easier than the Java equivalent.
Admittedly, some of that "easier" is subjective, depending on one's background and training, but C# coming from working with complex platform combinations of Win32 and COM has had to have some focus on making platform and object system interop work well, whereas Java always felt like (to me, at least) platform interop was more often a "bug" to eventually work around with a "pure" Java library given the chance.
Semi-related aside: It's still something of a shame that anti-.NET sentiment several years back damaged so much of the reputations of so many of the best C# Linux applications. There was briefly a time where there were several very strong Gnome-environment C# applications in-box in Ubuntu, and I still think it was a mistake they were dropped. A lot of the arguments from that period somewhat soured me on running Ubuntu as a daily driver and some of my opinion of the larger Linux open source community. It was exciting seeing apps that I could so easily contribute to (as someone's whose day job efforts typically were C# at the time) in the box, it was angering seeing them denigrated not on their own merits but by indirect association with Microsoft (despite Mono's distance at the time, open patent promises, etc).
- GordonS 8y agoThere has also been a big push on performance and minimising heap allocations in .NET recently, and it's really been paying dividends. .NET also makes it relatively simple to work with memory on the stack (especially via `stackalloc`), as well as unmanaged memory on the heap. Of course, many developers never have optimisation problems that require these tools, but they are fantastic when you do need them.
- WorldMaker 8y agoYeah, I've been very impressed with .NET Core's efforts in performance lately. Span<T>, the stack allocation support, and greater "semi-managed" heap memory support, are a major performance breakthrough taken together. It gives the garbage-collected "safe" C# code most of the performance characteristics of pointer-heavy "unsafe" code. It's maybe still too early to make predictions of long-term impact, but it really does seem like it puts C# into a good position to take on even more "performance critical" work day-to-day, possibly keeping C# competitive with (and even mentionable in the same sentence as) languages such as Rust and Go. (Especially when combined with AOT/.NET Native compilation.) It is definitely something I'm keeping an eye on.
- GordonS 8y agoOh, I forgot about intrinsics too! Those will be in .NET Core 3.0, so you'll be able to use SSE, AVX, BMI etc instructions!