3 ms·
Interactive Programming in C (2014)
- lkuty 1y agoTsoding made a video about hot code reloading in C (https://www.youtube.com/watch?v=Y57ruDOwH1g https://www.youtube.com/watch?v=Y57ruDOwH1g) and also used the same concept in "My Own 3b1b Animation Engine but in C" (https://www.youtube.com/watch?v=RVwuYgXNUCM https://www.youtube.com/watch?v=RVwuYgXNUCM).
- uticus 1y ago> When the library loads without error, look up the GAME_API struct.... If looking up the GAME_API fails, close the handle and consider it a failure. Error handling strategies, and what fallback state things fall into when the hot code breaks, would be great to hear about.
- 90s_dev 1y agoI did something similar ones as a vs code extension for love2d which I called live2d, so that you could develop your game while it was running. It was incredibly fun, but incredibly hard to use, and nobody had any interest in it, so I abandoned it and lost the source code eventually. But it worked so well. I had invented this thing called magic tables to go along with it and make it easier to use, I forgot what they did, I just remember the name and how cool it was.
- RustyRussell 1y agoAndrew Tridgell's KnightCap did this differently: it's a network chess server, and it would dump its data to a file and re-exec. The trick here is that it would keep the (network) fds open for zero downtime. IIRC he used a Perl script called datadumper to gen the code marshal/demarshal the structures. This has the advantage that reboots can be handled fairly seemlessly too (though there will be reconnections then of).
- sitkack 1y agohttps://man7.org/linux/man-pages/man2/pidfd_getfd.2.html https://man7.org/linux/man-pages/man2/pidfd_getfd.2.html https://gist.github.com/kentonv/bc7592af98c68ba2738f4436920868dc https://gist.github.com/kentonv/bc7592af98c68ba2738f44369208... For those curious research "SCM_RIGHTS" (Socket-Level Control Message) and sendmsg/recvmsg
- o11c 1y agoThe main disadvantage of this is that most encryption libraries don't support serializing their state.
- fao_ 1y agoEh, you could probably get away with it if you use BearSSL[0]. The only difficulty would be: These elements can be allocated anywhere in (writable) memory, e.g. heap, data segment or stack. They must not be moved while in use (they may contain pointers to each other and to themselves). Which you could probably get around with by just keeping track of offsets and using mmap [0]: https://www.bearssl.org/api1.html https://www.bearssl.org/api1.html
- zoom6628 1y agoMaybe TinyC from Ballard et al could also be used given its ability to be a C interpreter?
- mrheosuper 1y agoiirc HolyC is an interpret language.
- saagarjha 1y agoI use the debugger a lot for REPL-like workflows.