103 points · by beef3333 · 12y ago · 71 comments
I have several game maker projects which are long dead and gone because I got bogged down trying to write nifty engines and crap for them. In one case, I spent probably weeks working on my own custom (and, to be fair, only barely passable) physics engine for a game which can now be accomplished in a few lines now that game maker studio comes with a physics engine.
I can only imagine how deep the rabbithole would go if I ever started to learn game design in C++ or something (which, of course, I plan to) and then added language design on top of that. Would probably be really fun though.
For that reason I think things like indie game jams (Global Game Jam & Ludum dare) are a good idea because you will write crappy code, but you will actually make a game.
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp"
Any project that runs some sort of external script would count. Soon a config file has some sort of conditional (#define grows #ifdef) and variables.
Also any project that has a VM (in the traditional sense) such as SCUMM.
It incorporates the notion that Lisp will do everything already, the code as data as code that Lisp gives you is a win that coders dismiss until it's too late and they have spent years learning C++
This section is somewhat important: http://gameprogrammingpatterns.com/bytecode.html#how-is-the-...
While you're at it, you'll probably want to write some debugging tools since your designers are bound to dream up some complicated scripts you never imagined your system needing to handle...
Also very interesting is the Emscripten port of ioquake3, which includes a custom compiler for Quake 3 VMs to Javascript.
[1] http://fabiensanglard.net/anotherWorld_code_review/
[2] http://www.inolen.com/articles/compiling-quake-3-virtual-mac...
You then have systems that operate on the components. This solves the problem of needing components to interact with each other, since a system can look at as many components as it wants.
https://en.wikipedia.org/wiki/Entity_component_system http://t-machine.org/index.php/2007/11/11/entity-systems-are... http://piemaster.net/2011/07/entity-component-artemis/
I say seems to be because while ECS is clearly being talked about a lot, I'm not sure how many shipped games are actually architected around it. The blogosphere doesn't always accurately reflect reality.
I've looked at a few ECS implementations and many of the ones I saw had such bizarre implementations that they more than nullified the performance benefits of components.
I do see the advantage of systems that work on multiple components, but I think some proponents are starting to cargo cult this model. That happens frequently in games because you have so many amateurs that want to know the "best" way to do things, and the constraints are challenging.
Hmm, this ended up sounding overly negative which I didn't intend. I think ECS is interesting, but I'll be interested to see how it matures over time. Right now it feels a bit like the OOP fads of the 90s to me. There's good ideas in it, but any good idea can be taken too far.
(I should know, I've certainly killed enough projects by doing it.)
'''In what situation would "just use linux/freebsd/etc." not be the appropriate solution to this problem?'''?
It's hard to sandbox python or lua and block I/O and all system calls. 1 mistake and player computers are compromised.
Even with JS in browser you can't just eval(), you need sandboxing like https://code.google.com/p/google-caja/ or https://github.com/jterrace/js.js/ (200 times slower than js).
Nowadays, you'd probably be better served by embedding a general-purpose dynamic language in most of these scenarios, but hand-rolled bytecode can still win in certain situations that need high performance and/or low latency. Imagine, for instance, one of those fancy "danmaku" shooters with hundreds or even thousands of bullets on screen moving in intricate patterns. You just might want a language more dynamically manipulable than C to script the behavior of those bullets, but using a dynamic language that furiously generates garbage and demands collection pauses for something that must happen 60 frames per second on so many objects is probably going to cause hitches eventually that will get your player killed (in the game, at least). You'll then be subject to a very harsh but valid criticism: "I played games like this on my PlayStation back in the day with no slowdown, this guy must be a crappy programmer if his 2D game stutters on my monster PC." Sure, it's great that you don't need to break out the optimized assembly to do a Breakout clone anymore, but at the same time, you should feel bad if a 1Mhz 6502 provides a considerably more reliable experience than your game on a modern x86.
A certain popular 2D shooter series made by an ex-Taito arcade game programmer uses a bytecode DSL for its intricate bullet patterns for this reason. It was probably an easier decision to make when the series started in the late 90s, but today it lets the author be productive without adding wildly variable latency into the mix that would kill the gameplay. People should not forget that running smoothly even on poor hardware is a real feature. Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP. If you make the only new games/apps/whatever that run well on these computers, you have a captive audience.
At the same time, I think you could extract 99% of the performance benefits of the bytecode approach if your language had a well-defined heapless, stackless "tasklet/microthread" subset that centered around mutating existing objects and making certain limited kinds of allocations (allocating from a memory pool and manually "freeing" by marking the object as unused later). Knowing that a piece of code will never generate garbage and that a garbage collection cycle will never happen during its execution makes a huge difference.
Oh hey, I think you just described asm.js
Don't forget low-end mobile devices.
I sorta doubt there are many games targeting these devices (and, more particularly, the people who still use these devices in 2014) in the first place, but even fewer which are pushing their headroom so hard that, if they decide they need what amounts to a scripting language, they can't fit one in off-the-rack.