6 ms·
It's interesting how .NET is converging on the same runtime techniques used in Java and yet how drastically far behind they are. The Java guys realised that an
by peoplewindow 9y ago
It's interesting how .NET is converging on the same runtime techniques used in Java and yet how drastically far behind they are. The Java guys realised that an interpreter was still useful decades ago. Tiered compilation shipped in Java 8, and that was more complex to implement as there were two JITs, so JITd code still had to do profiling.
It's also quite interesting that the interpreter was dropped due to the complexity introduced by having generics in the runtime. A long time ago I thought it was self evident that type erasure was a poor way to do generics, but Brian Goetz has been arguing persistently for years now that type erasure isn't necessarily a bug, just a different tradeoff. With runtime complexity being one of the factors that weighed into the decision ... something that's easier to understand now I read this blog post.
There are some things I like about .NET though it was a long time since I did any, but HotSpot seems so dramatically far ahead and the distance is increasing. The major selling point of .NET over Java originally was supposed to be great multi-language support (well, and better Windows support), but there are way more languages targeting the JVM than the CLR these days. HotSpot does tiered compilation, it now does AOT compilation too, it has a new JIT called Graal that either matches or completely smokes the best available runtimes for almost every language, and IntelliJ is every bit the match for Visual Studio. And it's all cross platform.
So what's .NET's major selling point these days?
- jackmott 9y ago>but HotSpot seems so dramatically far ahead and the distance is increasing. Benchmarkgame scores reached basically parity between java and C# once .net core 2.0 dropped .NET selling points: * you can do some SIMD explicitly, more is coming * you have control over when things are stack allocated or not. structs, stackalloc, slices * you have unsigned ints
- peoplewindow 9y agoHm, seems like the big win for C# was actually someone going in and optimising the benchmark programs themselves: http://anthonylloyd.github.io/blog/2017/08/15/dotnetcore-performance http://anthonylloyd.github.io/blog/2017/08/15/dotnetcore-per... The point of explicit control is usually performance though. So if Java can give you near equal or better performance but without the developer having to explicitly specify as much, isn't that a win? Benchmark game also lacks the benchmark the Mono blog post is all about - developer iteration time.
- int_19h 9y agoIn many cases, Java actually can't give you near equal or better perf. "Our optimizer is smart enough, you don't need to care about stack-allocating things" has been the promise for as long as Java existed, but it doesn't really deliver that outside of fairly simple cases (which are also the ones that are typically benchmarked).
- sanxiyn 9y agoJava's new partial escape analysis should help with that.
- jackmott 9y ago>So if Java can give you near equal or better performance but without the developer having to explicitly specify as much, isn't that a win? It would be, but often times the lack of explicit control causes you to need more verbosity in Java to get around it, because the JIT isn't all knowing. For instance say you want an array of 2D vectors (x,y) and you want them in line in the array for data locality. In C# you just make Vector a struct, and put the structs in the array. In Java you would have to just put float primitives in the array and alternate the x and y and keep track of it by hand. Minecraft suffers greatly from this. As well, Java won't do anything but the most trivial automatic vectorization, and only on integers, and SIMD can be a huge win at times. I'm looking forward to more complete support droping for .net >Benchmark game also lacks the benchmark the Mono blog post is all about - developer iteration time.
- sitkack 9y agoF# Single file static AoT compilation. Does the JDK support this yet?
- pjmlp 9y agoSince the early days for anyone willing to pay for commercial JDKs, only Sun was against AOT compilation. For those that rather use only OpenJDK, there is Linux x64 AOT support on Java 9, with improved support for other platforms in Java 10 roadmap, some of it already in master. As for F#, currently it is lacking some love from.NET Framework, UWP and Visual Studio teams, which always think about C# and VB.NET terms. Even C++ seems to be better supported.
- guelo 9y agoI would say Scala is on par with F#. And there's also Kotlin if you're looking to transition a Java team to a static FP language more gently. And there's Clojure if you prefer a dynamic Lisp.
- migueldeicaza 9y agoIt is worth pointing out that when we dropped the interpreter, we only had two or three engineers working on the VM and they had to both develop the JIT and maintain the interpreter, plus work on the GC, io-layer and other VM features. Without a reason to keep the interpreter (the world was a JIT-friendly place back then), it made no sense to maintain it. But times change, statically compiled environments are more common nowadays (iOS, PlayStation, Xbox, tvOS, watchOS) and with it the need to have dynamic capabilities. To put things in perspective, adding generics to the revived interpreter probably took an engineer that was not familiar with .NET about 4-6 weeks of work.
- Rapzid 9y agoI'm very confused as to if you believe that to be fast or slow. That seems incredibly fast for "an engineer"...
- Const-me 9y agoExcellent GUI frameworks on most platforms. Much better unmanaged interop story: [DllImport] (btw it works on all platforms, e.g. on Linux it imports from .so libraries), structures, unsigned integers. Better multithreading: thread pool, synchronization contexts, async-await. Unsafe code, pointer arithmetic. LINQ
- int_19h 9y agoSpeaking of interop - the nice thing about .NET type system, is that it has facilities to do complete mapping to C, with the sole exception of setjmp/longjmp (which is generally a sore point with everything, even C++ doesn't handle it well). You already pointed out unsigned integers and structs; it's also worth pointing out raw (non-GC-aware) pointers, and explicit layout structs; the latter can handle C unions seamlessly, in particular (you just say that all fields have offset 0).
- Const-me 9y agoVariable-length C structures don’t map. Example of such structure: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365521(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa3... But they’re rarely found in APIs, and there’s Marshal class in the framework to implement manual marshaling by reading/writing stuff at unmanaged memory addresses, even without /unsafe compiler switch.
- int_19h 9y agoWith a little syntactic sugar in C#, they do map, in the same exact way you do this in C - you just use a "fixed" array of one as the last element: struct VariableLength { public int fixedSize; public fixed int varSize[1]; } Of course, this also means that you have to use stackalloc or other manual allocation to actually get a properly sized block of memory, computing said size yourself; but you also have to do it in C with malloc: byte* p = stackalloc byte[sizeof(VariableLength) + 10 * sizeof(int)]; var vl = (VariableLength*) p; Once you have a pointer, though, you can do vl->varSize[i] etc - this works because the type of vl->varSize when you access it is int*.
- JamesBarney 9y ago.NET is the perfect stack for the generalist. - As a consultant if I am handed a .NET project, even if it's a ios, android, web app, or a wpf application, then I'm usually familiar with 100% of the ORMs/PDF libraries/GUIs/build systems/source controls/IDEs/web frameworks they use(excluding client side web). I can come up to speed and get running quickly whether it was built last year or 10 years ago. It's the exact opposite of the javascript environment where two different javascript apps have less in common than a ruby and python app. It also allows me to meet all my clients need well enough on one platform. - Because of the previous item, it's perfect for enterprise which needs to be able to scale up and down teams internally. - Tooling is built for ease of use and is amazing. A lot of tooling from my experience in the java world is more powerful but with much much steeper learning curves. Leading to far more specialization. - Visual studio is a best in class IDE. - It's not java. From a language perspective java is still playing catch-up. Java is great, there are a lot of amazing open source projects on it, the big data story on java is far more compelling, you can write much better Android apps, and and large multi-department transactions financial/enterprise software. But it is in no way shape or form superior to .Net in all ways.
- pjmlp 9y agoAs generalist I find being able to do Java, .NET and the occasional C++ dive, a nice way to have the best part of all cakes. :)
- cjsuk 9y ago.Net does have two major downsides that kill it for me entirely (as someone who has used it for 15 years now): schizophrenic roadmap and deprecation, immature libraries. The deprecation means you can't rely on the longevity of the vendor's whims to build your product on. The library issue is a biggie - there are just so much more higher quality libraries in Java. The language matters considerably less than the libraries do when you want to get from A to B.
- redcalx 9y agoOn the library front we've used IKVM a few times where there was a java lib that did what we wanted with no equal in .NET land, e.g. Saxon XPath2 would be a primary example. However, with the developer of IKVM stepping down this has created a possible future risk.
- ZenoArrow 9y ago> "IntelliJ is every bit the match for Visual Studio" What debugging features does IntelliJ have that are of equal or superior utility compared to IntelliTrace? https://blogs.msdn.microsoft.com/zainnab/2013/02/12/understanding-intellitrace-part-i-what-the-is-intellitrace/ https://blogs.msdn.microsoft.com/zainnab/2013/02/12/understa...
- sievebrain 9y agoIt has the same feature, called chronon
- noblethrasher 9y ago> but there are way more languages targeting the JVM than the CLR these days This is often repeated, but it turns out that the JVM and CLR have roughly the same number of high profile languages: Specifically, the CLR enjoys the following mature languages: C# F# VB (which has some distinct advantages over C#) C++/CLI PowerShell IronPython Nemerle It's also worth noting that Clojure absolutely works on the CLR, and F* (F# with a more powerful type system) just hit version 0.9. C# (and VB), get a bit of love of HN, but they're even more powerful than they get credit for. C# has monad comprehensions, a metaobject protocol[1], and can straight-forwardly simulate type classes (in the form of implicit conversions to constructed classes). So, as a language, C# can get close to both Scala and Clojure even without having higher-kinded types, multimethods, or macros. [1] https://books.google.com/books?id=QGciuyBRyU0C&pg=PA119&lpg=PA119&dq=DLR+metaobject+protocol&source=bl&ots=NdZ5DnfN38&sig=pW8mWlGSAiLltPsYxYRf9Egbtuw&hl=en&sa=X&ved=0ahUKEwjX3Iu0xr7XAhWB34MKHRyZC38Q6AEIKDAA#v=onepage&q=DLR%20metaobject%20protocol&f=false https://books.google.com/books?id=QGciuyBRyU0C&pg=PA119&lpg=...