John Carmack: Script Interpreters Considered Harmful
Friday, August 12, 2011The most interesting part of John Carmack's keynote at QuakeCon this year wasn't the stuff on megatextures or static code analysis. It was his assertion, right around the 1:07:32 mark, that script interpreters are evil. Well, as evil as it's possible for a script interpreter to be. Which is still pretty evil.
And I quote:
One of the lessons that we took away from Doom 3 was that script interpreters are bad, from a performance, debugging, development standpoint. It's kind of that argument "oh but you want a free-form dynamically typed language here so you can do all of your quick, flexible stuff, and people that aren't really programmers can do this stuff", but you know one of the big lessons of a big project is you don't want people that aren't really programmers programming, you'll suffer for it!
But one of the things that we did is—because the other side of it is also performance—you'd think that with our million-times faster systems that, it's like "ah, scripting some things, performance should be a non-issue." And it's striking almost how much that isn't the case. In the last month of Rage's development we're taking some of our Flash GUI stuff and converting it to C++ because the interpreter for doing the ActionScript stuff in the GUI is taking multiple milliseconds sometimes. Even with all of our wealth of processing power, we still don't have enough performance; performance still matters.
This is a strong statement for a guy with Carmack's reputation and influence. Hundreds of modern games use lightweight scripting languages like ActionScript or Lua to handle things like scripted NPC encounters or environmental events. Carmack's most successful game of all time (Doom 3, by the numbers) employed over half a million lines of scripting for the in-game computer terminals alone!
According to the Doom 3 manual, GUI designer Patrick Duffy wrote over 500,000 lines of script code, and generated more than 25,000 image files to create all of the graphical interfaces, computer screens, and displays throughout Doom 3.[49] Other important features of the game engine are normal mapping and specular highlighting of textures, realistic handling of object physics, dynamic, ambient soundtrack, and multi-channel sound.
If those figures are accurate, no wonder Carmack thinks script interpreters are evil. In-game "toy user interfaces"—like this one from Fallout 3—
—probably shouldn't consume more lines of code than certain early builds of the entire Unix operating system. While a little scripting goes a long way, scripting languages weren't really designed for large-scale development efforts involving millions of lines of code. They typically lack the code-reuse abstractions and development toolsets, not to mention the runtime characteristics, that make large-scale development feasible. Anyway, hopefully when the Doom 3 source code is released we'll get a chance to dig in and see what's what.
Use the form below to leave a comment.

I don't know who the hell Shooter is. But 700 freaking thousand dollars??????? For a tourney nobody's ever heard of?
I really need to find a better racket...
Coding the Wheel has appeared on the New York Time's Freakonomics blog, Jeff Atwood's Coding Horror, and the front page of Reddit, Slashdot, Digg.
27 comment(s)
Am quite looking forward to the Doom 3 source code release. My expertise isn't in gaming but getting a chance to peek under the hood of a commercial mass market game will be a learning experience to say the least. If they ever do it that is. This isn't the 1st time Carmack has promised "teh source codez". Holding my breath...
FWIW most of Firefox's UI and suck is written in JS and it is a rather large project...
Excuse me... I may not have read you correctly here, but, did you mention ActionScript as a LIGHTWEIGHT language? Fuck you. Really. Lua is lightweight, but ActionScript DEFINITELY IS NOT.
Lua is way faster than ActionScript (even without using LuaJIT, which is many times faster again), and Flash uses software rendering to draw GUIs. There are lots of reasons you wouldn't want to use Flash in a game.
Lua is used in hundreds of games because it IS really fast, and you can use whatever abstractions you want in it. It's a really powerful and flexible language. People can abuse it, but you can also write extremely elegant code that executes nearly as fast as C/C++.
So rather than "scripting languages are evil," the only real take-away here is the Flash sucks. Which all real game programmers knew already (likely Carmack included, though he seems to have underestimated the degree of suck).
@Markus: the comparison is to C or C++ so yes, ActionScript is lightweight.
Uhm, Carmack promised code a lot of times and delivered. Not his fault that the engine is still being licensed for very recent games and there being some legal hold-ups until now with the D3 one.
And that is precisely the reason why the browser performs with the zeal of an overfed, paraplegic cow.
Woah here come the Flash-suck-trolls... AS, LUA whatever: Carmack's problem is that these are not good-enough scripting languages because he didn't write their VM himself and he can't use static code analysis tools & stuff to be sure code is optimal.
For what is worth games usually use ScaleForm which is a runtime somewhat compatible with Flash but nothing really like Flash Player - also it's coded in AS2 which, like LUA and unlike AS3, isn't strongly and doesn't offer any code analysis tools.
LUA = Lua Uppercase Accident?
He also mentions two important things:
Strip down C++ dialect: yes please.
"They typically lack the code-reuse abstractions and development toolsets, not to mention the runtime characteristics, that make large-scale development feasible."
This statement is false. Counterexample is Python, which has all of the above.
Which is why we said "typically". So that somebody would come along and pretend we didn't say typically, when we did. "Typically" allows for counterexamples like Python and PHP. Which have more in common with large-scale development languages like C#, C++, and Java than they do with ActionScript or Lua anyway.
Guys. We should view his statements in the context: big game projects. It's not hard to imagine that breadth and duration of the project minimizing benefits of script languages and maximizing management cost.
Keep in mind that JC's idea of a "scripting" language is interpreted subsets of c and c++. To my mind, it's extremely likely such languages will end up with the worst of both, vs using something like lua.
Ugh.
Let's break this down:
1) Doom 3 was essentially "pop in a box" that relied heavily on scripted events to provide "tension / fear" and "game play". Oh.. I've opened an "object" or used an "object" ... what are the chances that you just scripted a pop up spawn behind me? HEAVY. The real issue isn't language, it is engine constraints. We get that modern games have moved from Doom open maps to Black-Ops "scripted events along a pretty tunnel" but... Both are doing it wrong, and need to die out.
Comment - this isn't a problem with the language, this is a problem with design.
2) LUA. LUA is fucking magic pixie land if you know what you're doing. LUA was first used in games and now is being used in... Oh. Ok. If you're reading this, you should be educated, and in touch, right? Then go find out which companies are using LUA for non-games, then come back with your tails between your legs. [Disclosure - used LUA in its infancy, and saw the potential right away].
Comment: A decent GUI engine + pre-made LUA scripts CAN allow non-coders to make games. Fact. Proof? Hmm.. $500mil+ in sales says I'm right.
3) At some point, the 90's cease to matter. As do the 00's. It is 2011 now. Carmack hasn't produced a groundbreaking game / engine in ... 10+ years. He looks like a meth addict. Why are you still listening to a person who personally did DaiKatana, and Doom III was a flop? Remind me why he's relevant now? Unreal Engine kinda won the battle (along the lines of "Oasis vrs Blur" in the 90's)
Comment: Stop crying, make a decent game this decade. I dare you. OH....
Disclosure: Anachronox was the best game ID never made. If you've not played it, then GTFO and don't bother commenting.
p.s.
Your code is fracking insane. Correct tags => insane issues. Blog is retarded. Grats.
Third try now. Nice to know that "modern" blogs not only badly format proper HTML, but also rape to death < and > etc etc.
/fail
I'd say he looks like an otherwise healthy guy who doesn't get a lot of sun. (Programming, ever heard of it?)
Ion Storm make Daikatana and Anachronox.
I've been following this site for about a year and you sir have a way of phrasing things that polarizes people. Sometimes this is a good thing, sometimes a bad thing, but I've seen far worse writers get far more praise and take a lot less flack. Not one tech writer out there bothered to listen to the keynote in its entirety or they would've been all over this. If they did listen, they didn't know enough about programming to understand why the quote you isolated would be interesting to a programmer. Thanks for a great little discussion and for whetting my interest in game programming for a 2nd time.
Christ people, the title is a reference to GOTO Considered Harmful a famous opinion paper by Dijkstra. He's not actually saying that script interpreters are harmful what are they teaching you kids in CS these days? http://en.wikipedia.org/wiki/Considered_harmful
This guy is so overcome by his celebrity, he believes his own BS. You are better off using programmers to code games. Deep! We needed that bit of arcane wisdom.
Notice how he has a really, really bad case of console envy. Instead of producing a decent follow up to the DOOM franchise, he is working on a console like rail shooter type game.
When they dispense with the creatives, i.e. writers for storyline and plot development, you basically get console tunnel creeps like Rage sounds more and more like it is going to be.
You are probably misinterpreting what Carmack said. I saw it a while ago and I remember him saying in "in retrospect" and "what we learned is" several times.
This time is about what he thinks now. Not about what they did it in the past. It's a talk about if you had to do it again, how differently would you do it. And he even mentioned "contraints", "small teams".
Listen to a bunch of people who couldn't build a 2D asteroids criticize the man who singlehandedly invented modern FPSes...seriously...what have you guys ever built?
Hmm
@Jason You don't actually know who you're talking about, do you? Carmack never touched Daikatana. That whole post was embarrassing...
You actually don't have to wait until the Doom 3 source code is released to see "what's what," the source code to the entire scripting system is in the gamecode, which means you can grab the Doom 3 SDK and look at it right now.
Well yeah. Using scripting the wrong way can be evil.
duh!
Crock. Of. Shit.