2 ms·
I think the first thing I'd do if told to "write a game from scratch, in C" is to write a bytecode interpreter for a higher-level language. Actually, it'd be ki
by derefr 12y ago
I think the first thing I'd do if told to "write a game from scratch, in C" is to write a bytecode interpreter for a higher-level language. Actually, it'd be kind of fun to start from a machine that only has a machine-code assembler, and bootstrap your way up to something like a Smalltalk GUI.
- krig 12y agoIt's interesting that one of the first things he does is to effectively build a REPL - the executable is a shim and the actual game code is kept in a shared library which is recompiled and reloaded on the fly. Together with manually laying out memory instead of relying on the runtime malloc/free mechanism for allocations, it seems to work pretty well. Make a code change, compile, the game updates immediately. Thanks to sticking to C the compile times are short enough to make the reload cycle near instantaneous as well.
- ANTSANTS 12y agoOne of the points Casey is trying to make with this series is that, at least in games, dynamic languages aren't quite the silver bullet for productivity that people make them out to be, and you can write your gameplay code just fine in C or C++. It might even work out to be a net productivity win, because native code debuggers are far superior to "managed" language debuggers (most of which don't handle the boundary between managed and native code at all), and because even moderately well written C or C++ is much less likely to cause performance problems down the line than anything garbage collected.
- tonyarkles 12y agoThis is totally tangential to this discussion, but I thought I'd throw it out there in case it helps anyone. The python-gdb macros are fantastic for debugging those painful managed-native problems one occasionally encounters. https://wiki.python.org/moin/DebuggingWithGdb https://wiki.python.org/moin/DebuggingWithGdb I've used it to debug some really gnarly issues over the years. They're not perfect, but they're good enough to solve all of the problems I've encountered and used them with.