News for hackers. Stuff that matters.
Re:Anders Hejlsberg – What brought about the birth of the CL... by pron on Sunday May 03, 2015 @03:30PM (#9482651)
People often say "managed runtime" or "VM" but those things are not clearly defined. For example, if we look at Java and .NET, the two best known language VMs, they really provide few completely orthogonal features:

1. OS isolation -- the VM provides a platform-neutral API for OS services, and abstracts away details like clocks etc.

2. Intermediate language representation, a JIT (or several JITs, in the case of the JVM) and dynamic code loading/manipulation.

3. A GC (or several GCs, in the case of the JVM).

Each of these features is completely independent (in fact, some JVMs don't even provide #2, opting for AOT compilation. Golang, OTOH, is not perceived to run in a "VM" -- simply because its "managed runtime" is statically compiled with the program, and no JIT is available -- yet it provides #1 and #3, just like some JVMs).

Now, as to why you'd want to provide each of those features -- well, there are different reasons. #1 is great for cross-platform portability. #3 is great for simplifying programming, esp. in multithreaded settings. #2, the JIT, is actually an optimization layer with some tradeoffs. A JIT can always produce machine code at least as efficient as the most sophisticated profile-guided optimizing compiler, and then some; to do that, it trades off warmup-time, and extra CPU cycles that can make a difference on energy-constrained platforms (although a JIT with caching might enjoy both worlds). In addition, a JIT is an absolute necessity when trying to achieve high-performance when running dynamically-typed languages. Another downside to JITs is that they're very hard to write well (i.e. while they can surpass the code quality emitted by AOT compilers, it takes more effort to even match that quality).

So, in general, there is no such thing as a "managed runtime" -- just a collection of features, each with its own motivation. That name also has a connotation of overhead, which again, is completely false. A GC may add some overhead (RAM, latency) but may also reduce overhead (throughput, more scalable concurrency) -- depending on your application. A JIT may add overhead -- warmup time, extra cycles -- but may also reduce overhead (more efficient generated code).

Re:Anders Hejlsberg – What brought about the birth of the CL... by zerr on Monday May 04, 2015 @04:13AM (#9484927)
> So, in general, there is no such thing as a "managed runtime" -- just a collection of features

To rephrase my question - why it is not possible to have statically linked this collection of features into standalone executable? Like Go. I understand that Go is bare-bones compared to .NET, but Delphi/C++Builder also supports fully standalone executables. As for cross-platform (source) portability - it could use Ahead-Of-Time compilation into native exe.

Re:Anders Hejlsberg – What brought about the birth of the CL... by pron on Monday May 04, 2015 @04:29AM (#9484972)
OK, so you're talking about AOT compilation, i.e. doing away with the JIT. Of course it is possible. There are even JVMs that do just that. The question, then, is when is AOT compilation (and static linking) desirable? There are, of course, many situations where it is and many when it isn't.

Go is designed mostly for smallish programs (command line programs like Docker or simple services), so static AOT compilation and static linking makes sense.

Java, OTOH, is mostly used in large, important, performance-critical server-side services, where the added performance offered by having a JIT is important, and the warmup time isn't, while dynamic linking allows for dynamic code loading/swapping.

Just like there are JVMs that do AOT compilation to a native binary, there's nothing stopping .NET from doing the same[1]. There's also nothing stopping a single SDK from providing both options. It usually boils down to a question of what the users of that SDK need.

[1]: I would bet that that's exactly where MS is going. Like I said before, writing a good JIT is hard, and OpenJDK's HotSpot is years ahead of the CLR in that respect and only widening the gap with its next-gen JIT, Graal. I think MS would realize that it's easier for them to just do AOT.