Comment by Lerc
10 months ago
Really interesting. I considered having a go at a RPN to WASM converter when I was making https://c50.fingswotidun.com/
I ended up converting the RPN style notation into a JavaScript string and creating a new function, which lets the JIT sort it out.
https://c50.fingswotidun.com/show/?code=xy!2*!2y!*6%2Bo2%2Fv...
which has the code
xy!2*!2y!*6+o2/vy#!*:Cy#*+z#d!;*:ze!xy*4s*43/*e+*+
becomes
((round(z) * ((v * (1 - round(y))) + (clamp((( ((x*(2**((2 * (1 - y)) + 6))) ^ ((1 - ((1 - y) * 2))*(2**((2 * (1 - y)) + 6)))) /(2**((2 * (1 - y)) + 6))) / 2)) * round(y)))) + ((1 - round(z)) * ((1 - smoothStep(z)) + smoothStep((((x * y) * sin(4)) * (4 / 3))))))
It would be interesting to see the performance difference from a wasm version, but in the end I found the human(ish) readable expression to be quite useful too.
Originally I created an interpreter for a code as a texture maker for code golfed javascripted games. https://github.com/Lerc/stackie
There's potential for a WASM implementation to be both smaller than the small version and Faster than the fast version.
No comments yet
Contribute on Hacker News ↗