Hacker News new | past | comments | ask | show | jobs | submit login

> ... but Lua still creates issues now and then. Like if you forget return, the return value is that of the last expression.

Is this true? Or was it true for some Lua 2.X versions? Because it does not seem to be the case for Lua 3.0 and on: [1]

> If control reaches the end of a function without a return instruction, then the function returns with no results.

As to the idea of using an emulator for scripting, it seems a bit similar to approaches using WebAssembly. But looking into the benchmarks [2] provided by libriscv, it is quite interesting to see it outperforms luajit and wasm3 (in its "hand-picked" tests, at the very least).

[1] https://www.lua.org/manual/3.0/manual.html [2] https://github.com/fwsGonzo/libriscv?tab=readme-ov-file#benc...




I've forgotten `return` plenty of times and to the best of my recollection it's always returned `nil` to the caller.

Maybe he's talking about something else than pure lua? Something with the game's bindings?


Maybe I'm old now. I'll remove it from the article! Reading back on it, it seems like I'm writing negatively about Lua, despite using it for many years. I think highly of Lua, and especially think it has made so many things easier for people over the years. I actually chose Nelua as one of the examples (Part 3) because of it!


I spent a lot of time on those benchmarks. I think my conclusion is just that because WASM isn't a register-machine architecture, you basically have to implement a register allocator to be really fast. wasmtime uses a complex allocator to great success. wasm3 has done it too, but it's just a basic one and it won't be able to compete with GCC or Clang. I could be wrong here, but what else is there? During my testing, it was never in question if libriscv was faster.

I used my usual benchmarks: STREAM (memory) and CoreMark (CPU).


Posted a few hours ago: Wasmi 0.32 performs a register-based translation which gets great benchmark results. https://news.ycombinator.com/item?id=40499130


I saw that. Keep in mind that libriscv is 35% faster than wasm3, and it looks like wasmi is not as fast as wasm3 yet. But they are making good progress.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: