Not exactly backend but that kinda fits my use case. I have a C embedded application that I need scripting on. Nothing unsecure from the user, from my own backend, but it requires a foreign function interface, and its a super constrained device.
Lua, JavaScript, forth, etc. None I’ve been able to find anything I like under 50 kB flash or are even slightly “friendly”.
Found one in JavaScript was close, but it’s an interpreted language which means every letter of code is a byte I need to transfer then have parsed.
I’ll look into this. Esp if it’s still possible to send just bytecode in.
I think you’re right that Lua is the way to go. But I have yet to see someone package it nicely for gcc and to be included and built from an MCU IDE (Keil, Segger Emebbeded, IAR, etc). I’ll keep looking.
https://gist.github.com/Vesnica/3672425
It loads and runs a Lua source code file which calls the exported C function. Lua compiles the source code into byte code before running it but that can also be done ahead of time with the Lua compiler:
https://www.lua.org/manual/5.3/luac.html
It can also be done manually with the dump and load functions:
A typical JavaScript system first compiles the JS source code into bytecode. Then it starts executing (interpreting) the bytecode.
If there is a JIT, that is a second compiler. It monitors the execution of the bytecode to find hot spots where it compiles the bytecode into machine language.
Or I'll upload a fork.
Found it also at https://github.com/richardhundt/tvmjit
EDIT: To clarify, the big advantage of RaptorJIT is that it takes dramatically less time and effort to profile and optimize programs to become competitive with C. If you're spending a lot of time scratching your head over long 'jit.dump' reports then RaptorJIT will save you lots of time. That's a big win for Snabb hackers but we seem to spend much more time on JIT-optimization than other LuaJIT users.
(Anecdotally it seems like most other LuaJIT users eventually give up on understanding the JIT entirely because they don't see it as being worth the effort. This doesn't really bode well for LuaJIT world domination.)
Your live streams are a massive resource.
They are so dazzling to others that they'll sit through an explanation of phi nodes, while I assure you they would not otherwise. If you ever want a change of pace, we'd probably be interested in bringing you on board in 2020. Cheers, and I hope the fellas are doing well. :- )