3 ms·
Ah, thanks for the feedback! I'd written that article before Mu got function headers, and never gone back to re-read it. a) next-ingredient is still around, an
by akkartik 10y ago
Ah, thanks for the feedback! I'd written that article before Mu got function headers, and never gone back to re-read it.
a) next-ingredient is still around, and I still teach it first before graduating students to headers.
b) Headers get translated to next-ingredient calls behind the scenes, but without the need to type-check ingredients at runtime.
c) You might still choose to use next-ingredient if you want to implement optional arguments, or variadic functions. A weird one is interpolate (in http://akkartik.github.io/mu/html/061text.mu.html http://akkartik.github.io/mu/html/061text.mu.html), which scans through its arguments twice, first to compute the size of the array to allocate to hold them, and then a second time to copy them over. Since calls to next-ingredient can get arbitrarily complex, Mu doesn't bother type-checking them. It just moves the type-checking for explicit calls to next-ingredient to run-time.
I'll update that post. Thanks again.
- marvy 10y agoCool. Two more silly questions. (1) How fast is mu these days? Is it roughly competitive with CPython? (2) You mentioned it would be nice to have a compiler someday. It occurred that maybe something like the JVM would be closed to the existing semantics than x86. It's also strongly typed and has bounds-checked arrays and stuff. Hm. I guess that's not a question. Never mind.
- akkartik 10y agoNot silly at all! (1) It's a good question. I think small benchmarks will likely be much slower in Mu since Python probably has optimized primitives for the common things whereas Mu is still (naïvely) interpreted. On larger apps I think the gap might come down, since Python will start relying more on unoptimized primitives. But I should probably measure at some point.. (2) Lol. I actually modeled Mu's on JVM to some extent, so it's intended to be a better replacement of that layer of the stack, something that compiles down to native rather than relying on a bytecode interpreter, and also something that is designed with higher-order functional programming in mind, as well as generics out of the box (so no type erasure and so on).
- marvy 10y agoThanks again!