I've really warmed up to @jckarter's suggestion of using template instantiation for hot generic functions and an interpreter for cold generic functions. You often want an interpreter for your language anyway, so it's an elegant way to reduce code bloat.
-
-
All the way to an interpreter embedded in every app? Not Swift-like polymorphic native code with dynamic dispatch?
2 replies 0 retweets 1 like -
Replying to @SimonSapin @pcwalton
Fully polymorphic code is pretty large too in machine code, and is full of indirect branches already. Byte code has the opportunity to be a lot smaller, and an interpreter could be nearly as fast while using up less instruction cache space
1 reply 0 retweets 2 likes -
I rely heavily on LTO and dead code elimination in generic code for the Rust I write on microcontrollers (< 100kB ROM, < 10kB RAM). I don't think my code would appreciate embedding a full interpreter just because a few cold code paths couldn't be optimized out LOL.
2 replies 0 retweets 1 like -
Sure, there are definitely places where you don’t want to introduce dependencies on a runtime. Across a full blown OS on a desktop CPU, being able to make better use of memory and cache by sharing code is a big systemic optimization; for a single purpose controller not so much
1 reply 0 retweets 2 likes -
Cool! I like your idea/think it's worth trying out. Just want an option to back out of embedding a runtime in the cases where "I know what I'm doing" :P.
2 replies 0 retweets 0 likes -
Of course. Back in the day, though, even Woz wrote chunks of the Apple II rom in his “SWEET16” bytecode to save code size on 16 bit arithmetic heavy code
1 reply 0 retweets 0 likes -
I'm not against bytecode (though I'd prefer to have full control over where it's used, which unlike S16- I won't get if the compiler is using inline heuristics to decide whether something should be bytecode). I simply envision real cases where interpreter overhead is a net loss.
1 reply 0 retweets 1 like -
Also, I have msp430 code in Rust I deployed that needs to fit in 2kB ROM and 128 BYTES of RAM; and it does with proper optimizations turned on, minus RefCell panic string misoptimizations :/ An interpreter would NEVER fit there unless it's the worlds tiniest stack machine lmao.
2 replies 0 retweets 0 likes
Oh, if this were deployed in Rust it would definitely be an opt-in thing. No runtime means no runtime.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.