97 points · by networked · 8y ago · 75 comments
In the examples though, clearly the goal is to have some provability in the core language, make that provability feasible with a small language, and keep that as the language becomes further optimized. It seems subtly different than an optimizing compiler.
One use of jets, in the secure code setting, is to provide a core language that is so simple that it can obviously be compiled in a "fully abstract" way.
That is my understanding, anyway. The notion of fully abstract compilation seems to be quite hot, and it comes originally from Abadi's paper: http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-154.pdf
> An intrinsic function is applied as a method substitution [...] and the compiler will replace it's apparent source-level implementation with a pre-cooked implementation. In some cases intrinsics are sort of compilation cheats [...]
> The intrinsics are all set up in vmSymbols.hpp and if you look, you'll see Arrays.fill is NOT on the list. [...] Because it is something like an intrinsic... [...] What is it then? Arrays.fill is a code pattern substitution kind of compiler shortcut, basically looking for this kind of loop:
``` for (int i = 0; i < arrayB.length; i++) { arrayB[i] = b; } ```
And replacing it with a call into the JVM memset implementation.
[0]: http://psy-lob-saw.blogspot.com/2015/04/on-arraysfill-intrin...
Put it this way: the JVM is perhaps the most sophisticated JIT on the planet, maybe a million lines of code, the product of decades of programming research and billions of programmer-hours, and it still needs intrinsics to improve performance. So how about we skip the billions of programmer hours and just use lots of intrinsics?
I don't know if it's going to work, but it's interesting enough to be worth a try.
> So how about we skip the billions of programmer hours and just use lots of intrinsics?
This is very nearly the equivalent of: Why don't we skip writing a compiler and just USE glibc?
My post was about the opportunity to forgo the use of an intrinsic and instead do pattern recognition as part of compilation. The point being that the "jet-like" pattern matching phase that exists in many compilers today, my example being from the hotspot JVM's JIT compiler, but GCC will match the for loop and INTRODUCE a call to memset too.
Reminds me of nothing so much as INTERCAL.
This is exactly how GPU drivers get gradually more optimized for existing games: the driver's shader compiler actually has an ever-growing library of shader-source-code patterns, with hardware-vendor-optimized replacement sections.
Look if you replace 1 representation with another that is _correct_ (to within the human author's reason), but faster. You have the identical discussion, and an answer (yes).
Running any normal language without an optimizing compiler is totally fine and routinely done. Here we're talking about languages that might be thousands or millions of times slower.
And then you end up speeding up the compiler to reach a decent state, to speed up the code
But time to reach initial compiler is much faster with a jet-based one (there's barely anything to the language).
and then you end up adding jets to reach a decent state
I'm not sure there's a significant difference in this regard. The main question, I think, is which is easier/simpler/faster to optimize into a proper state, and in the case of compiler optimization being better, if its sufficiently better to beat the ease of initial implementation for a jet-dependent language
My day job is writing compilers (for traditional languages), and I have no doubt that it's significantly easier/simpler/faster to implement the jet based one.
However, the jets only apply to known algorithms, so it's really more like an optimized library than a compiler technique. Code that uses the "library" will be really fast with little effort, but anything that requires functionality not directly found in the library will get the 1000-1000000x overhead, while the traditional compiler will run it all with ~10x overhead.
I totally agree that it's the perfect fit for long-lived, highly heterogenous, correctness first applications like blockchain, but I don't see how it'll be useful for general purpose languages.
There's also this; a fascinating study that investigated the ways people intuitively try to articulate algorithms when they haven't been biased by experience with existing programming paradigms: https://dl.acm.org/citation.cfm?id=373422
Of course, this means nothing pertaining to a preferred language, formal or natural, for encoding it such notions.
>a fascinating study that investigated the ways people intuitively try to articulate algorithms
Try to articulate algorithms. And generally fail, because they don't have any experience expressing complex systems in their shoddy, careless notation.
Naturally, when the physicist sits down to express her algorithm using Lie theory and tensor calculus, she's really a moron because one should obviously grab an inexperience lay person and have them dictate your notation for you. The natural consequence of this is that you'll see things you couldn't have seen before and discover many novel and interesting structures in the language, through a process of lay magic.
I've yet to see a better approach than Ruby's.
I don't necessarily care for the data as code, most of the time; but I do like that most everything has a sensible way to serialize to a file. Even better, unless I am wanting to get optimized, the round trip can take care of itself.
Curious what the syntax is for a basic list of key value pairs? Well, it is the same as any list of pairs. Which is the same as any list, unless you are trying to get fancy.
This freedom really is liberating, at times. Yes, some folks have made macros so that they have a syntax to have a different literal for different styles of maps/tables/etc. By and large, life is easier if you don't use those and just stick to the minimal syntax necessary to do this.
Which really helps with your concern. When I can see what the transformation is, I can literally substitute into my mental model what the macro is doing, so that I don't have to juggle a bunch of crap around.
And all of this, oddly enough, lands you into not caring if you are calling to a function or a macro. I have more trust in calling things in most lisps I've worked with, because I can understand both ways in terms of themselves easily enough. With ruby, I'm often wary of using a new method in a source file, because I really can't trust all of the interactions that are assumed for it to work out.
Urbit is very real, though whether it will go anywhere or not is a different question. You can run the code today, the language is.... weird as, but there it is, running and doing what it does.
With jets, a string of many very simple human-visible instructions gets translated to just a few actual machine instructions.
So it's the opposite in the sense that a microcoded system expands each instruction you write, while a jet system contracts strings of the programmer's instructions into more efficient code.
As one of the comments says: "The point is that jets create a particularly vicious abstraction inversion whereby a programmer must simultaneously think inside the object language and a kind of metalanguage."
To take advantage of jets, the programmer has to get the shape of the code right as well as the semantics. It's a bit like writing poetry, with the extra requirements of rhyme and meter in addition to the semantic requirements of straight prose. You have to keep an eye on what jets might match the code you write if you are going to get the required performance.
ASM and microcode have none of this intricacy.