3 ms·
> but a description of the algorithm plus language-specific information that's supposed to help the particular platform execute the algorithm efficiently Traci
by derefr 12y ago
> but a description of the algorithm plus language-specific information that's supposed to help the particular platform execute the algorithm efficiently
Tracing JITs should be able to spit out, as they run, the tables of Bayesian confidences they've built up for various static properties of the code, which can sit along with things like source maps, and be confirmed/rejected by the programmer in their IDE, or just live-reloaded into a new VM ala a Smalltalk image. (Future-tech, remember.) You can see the potential for this in things like Erlang's typer+dialyzer system.
Likewise, static analysis tools should be able to work on foreign code after transpilation. There's nothing stopping you from transforming C code into Rust code in order to get the Rust compiler's opinion on its ownership semantics.
Note that I'm not saying that there's one universal underlying language semantics. Just that language semantics (which consist of such things as a type system, a threading/memory model, etc.) have no reason to be tied to either a particular syntax, or a particular VM. (Effectively, a language semantics forms an abstract machine that executes more or less efficiently on the substrate of any given VM. MRI Ruby is a direct substrate for Ruby semantics; IronRuby is less-clear substrate; etc.)
> those may significantly affect the suitability of an algorithm for a certain language
This is a problem of transparent distribution. I've been working on an Elixir DSL for writing Haskell "inside" Elixir for efficiency. The result is not a Haskell compiled module getting linked into the Erlang VM, but rather a separate Erlang-VM-managed Haskell "application server" being run as a port program. I foresee much more of this, and much more cleverness about it: writing code that compiles to a bunch of separate modules for separate VMs, which then form a micro-distributed-system all within a Docker container or somesuch.
Again, it's not about eliminating the plurality of runtimes—it's about rendering that plurality moot, abstracting it away from the perspective of the programmer and leaving it up to the implementation to decide how to optimize abstract-machine-to-VM allocation.
There's no reason that you can't have every language semantics available to any library, to use in any combination (this parameterized type system with that green-threading and this other GC, etc.) It's just that, in so doing, you're either transparently importing into your single runtime some virtualization layers for all the other abstract machines you've coded in terms of (somewhat like writing a Windows app on Linux by linking it to Wine), or you've let the Sufficiently Smart Code-generator go beyond the premise of having a single target platform.
- pron 12y ago> Future-tech, remember. Not so much future tech. The most sophisticated JIT in production use nowadays is HotSpot's optimizing JIT, and next year it's getting this: http://openjdk.java.net/jeps/165 http://openjdk.java.net/jeps/165 (basically, metadata that the programmer can use to help the JIT with some decisions). HotSpot's next-gen JIT, Graal, takes five more steps forward and allow a full programmer-controlled JITting, that can suggest and improve various speculations on the semantic AST: https://wiki.openjdk.java.net/display/Graal/Publications+and+Presentations https://wiki.openjdk.java.net/display/Graal/Publications+and... I have full confidence in the general utility of JITs for server-side applications, but JITs themselves are a tradeoff (require warmup or caching, more RAM and more energy). > There's nothing stopping you from transforming C code into Rust code Not really, because Rust requires manual type annotations. Either they are added manually -- in which case you may as well translate manually -- or automatically, in which case the tranlator would need to infer the very same properties you want to verify. > Just that language semantics (which consist of such things as a type system, a threading/memory model, etc.) have no reason to be tied to either a particular syntax, or a particular VM. But they do because it's not just syntax -- the language and runtime are really a part of the algorithm (in fact, most algorithms presuppose a certain execution context like random, constant-time access to memory). The threading/memory model is what determines whether certain algorithms can be implemented at all; functional purity can completely change the complexity (by more than a constant) etc. > I foresee much more of this, and much more cleverness about it: writing code that compiles to a bunch of separate modules for separate VMs, which then form a micro-distributed-system all within a Docker container or somesuch. The problem with that is that once you go distributed (even on the same machine) there are tremendous performance costs involved. Not only marshalling/demarshalling of data, but fanning-in and then fanning out your concurrency on each end. There's no way you can use, say, a Java parallel stream, whose parallel operation is performed over the wire. There are only very specific places where you can place that boundary. I do, however, think that a platform such as OpenJDK, with such powerful GCs and JITs, can -- and indeed does -- contribute significantly to the ability to interoperate among various languages -- but certainly not all of them.
- derefr 12y ago> But they do because it's not just syntax -- the language and runtime are really a part of the algorithm. I don't think you understood my statement above—what you're attributing to the runtime (memory-model et al) is part of the abstract machine specified by the language's semantics, but that's orthogonal to the runtime. A runtime can be a better or worse fit for a given language's semantics, but any VM can virtualize any abstract machine with enough glue. VMs are Turing machines, after all. (In practice, the overhead can be surprisingly low; you don't have to emulate what you can trace or dynamically recompile. The work around ASM.js is rich in data about how to squeeze performance out of the not-particularly-direct mapping of the C abstract-machine to the JS VM.) The abstract machine formed by the language semantics can, of course, demand live support machinery of the underlying runtime (like a GC, say) that may have to be "polyfilled." This is what we've been doing forever—a PIT signalling a processor interrupt which is checked for between each cycle is just a polyfill for having concurrent processes on other processors sitting in blocking-sleep for a bounded time, for example. Any hardware emulator is full of these. Usually you can find ways to make them less necessary—IronRuby doesn't contain its own GC with Ruby semantics, it just translates Ruby's GCing requirements into calls to the CLR allocator+GC and the result works "well enough." > Not only marshalling/demarshalling of data, but fanning-in and then fanning out your concurrency on each end. Why are you assuming message-passing distribution? Shared-memory cross-runtime distribution works too. That's how ZeroMQ works, for example.