4 ms·
Educational article. Is luajit becoming a tool of choice for this kind of hacking, rather than C or perl? Seems like a library of helper functions or some sugar
by versteegen 11y ago
Educational article. Is luajit becoming a tool of choice for this kind of hacking, rather than C or perl? Seems like a library of helper functions or some sugar could be added to make it more suitable, note the need for a readptr function and use of tonumber()
- hwh 11y agoArguably, the FFI gives easier access to stuff (TM) than Perl would allow. C would be easier if the aim was clear and you can just write the code down (well, string handling is probably easier in Lua, and there's the memory handling with GC). When the way there is what drives you instead, Lua(JIT) is nice. Sprinkle in some print here and there, try this and that without compiling stuff (though that is the smallest gain, I think)... tonumber() is LuaJITs cast for pointers to integers. There are some arguments for it to stay.
- versteegen 11y agoMake sense, dynamic languages have a lot of conveniences. If having a REPL helps, there are REPLs for interpreted C I meant to refer to "tonumber(oldsize[0])" used to cast from a ctype size_t to a lua number (doubles) (I missed that's it's also used for casting pointers). Now I realise that this is needed because implicit casting from 64 bit ints to a double would reduce precision. It's just a very minor thing that "for" loop bounds must be lua numbers.