4 ms·
The real question is: why do people keep writing interpreters, when writing compilers is not hard. It's not "interpreters vs C++" as Carmack supposedly said, b
by rwmj 15y ago
The real question is: why do people keep writing interpreters, when writing compilers is not hard.
It's not "interpreters vs C++" as Carmack supposedly said, but crappy slow badly implemented user languages vs efficiently implemented user languages vs a guru writing C++. The middle option is the one to go for.
Especially with LLVM which makes compiling your code very easy, and it's got a BSD-ish license, so no problem linking it with your awesome proprietary game.
- delinka 15y agoWith an interpreter you sort of get an automatic sandbox because your badly implemented user language is handled by a buch of switch-case or if-else statements. Not literally, but the 'user language' is entirely limited within the interpreter and doesn't mingle with the real game code unless you code up that specific interface. Enter compiled code. Now we have the opportunity to run unknown binary code right within the game's address space. Bad News in many ways. To get the Happy Medium (compile code within the game engine, load and run the resulting executable safely) requires implementing operating system concepts. It's a Big Job. This leads my thoughts on a slight tangent: why isn't there a Super Awesome Open Source Game Engine that's the heart of all 3D games? SAOSGE could even provide the extensibility framework (compiling, loading), ready for you to expose parts of your games to player programmers.
- nostrademons 15y agoIf you control the compiler and the language is memory-safe, you get the same guarantees with JIT-compilation that you do with interpretation. All execution runs within the memory boundaries specifically allocated by the runtime system, and any other interaction with the machine must go through the runtime libraries, where you can perform any checks you want.
- prodigal_erik 15y agoI don't see this kind of sandboxing as likely to help. Whether your scripting language is compiled or interpreted, if any accessible portion of your system is written in a memory-unsafe language like C, that is where crackers will find the most damaging exploits. E.g., http://stackoverflow.com/questions/381171/help-me-understand-this-javascript-exploit http://stackoverflow.com/questions/381171/help-me-understand... which attacks a native XML toolset (some "data binding" IE feature I don't understand) without breaking any javascript rules.
- krakensden 15y ago> why isn't there a Super Awesome Open Source Game Engine that's the heart of all 3D games? Unreal is the closest thing, but there's still lots of new/strange/innovative stuff going on in rendering, which means that lots of bits are hard to reuse. Rage, for instance, has a pretty nifty virtual-memory for textures scheme, which no one else has really done.
- teamonkey 15y agoAlso, licencing costs. Why pay a rival company money when you can create your own engine in-house? Unreal has various licencing agreements, from (probably) 8 figures for an unlimited license down to 99$ + 25% of any revenue above $50k per title (and anywhere in between). In particular I'm thinking of Criterion's Renderware engine. Originally funded by Canon it was very popular. Then Criterion was sold to EA and everyone dropped it.
- jacques_chester 15y ago> Also, licencing costs. Why pay a rival company money when you can create your own engine in-house? Because developing a AAA engine from scratch is a multi-million dollar enterprise at this point. You actually need to develop your system faster than the leading edge so you can catch up. That's an expensive ask. Most companies arrive, after 2-5 years, with something that was as good as UDK or idTech n was ... years ago. Paying the $500,000 or x% of revenues is often the fastest, cheapest way to get your game out.
- swah 15y agoNot hard comparing to what? Its still pretty hard... even jonesforth is kinda hard to get for most developers.
- mathgladiator 15y agoThe reality it is the reliance on tools and sucky education. I wrote a compiler for taking a less-sucky C#/C hybrid compiler to PHP (why php? so I could get things done and hack it when needed): See: http://news.ycombinator.com/item?id=226480 http://news.ycombinator.com/item?id=226480 Reality: taking it to production was nice, but debugging and other tools are not available. I spent a lot of time making it possible to debug the PHP and trace that back to C#. This was less than idea. Then IDE support. While I can happy without an IDE, most people can hardly function. Trying to educate people on it was (a) marketing fail [web devs hate static typing], and (b) too hard for people to grasp (functional programming + new stuff = fail sauce).
- malkia 15y agoTurn-around time is what matters most. (I work on a console game). You need very fast turn-around time for a designer to test his ideas. If something turns slow, later it can be put in a C/C++ function and exported. Also sand-boxing, but this is not of concern to the actual scriptures, it's to the rest of the team. And something to easy deal with tasks/threads, or state machines, and such. Also a language that allows you to declare easy what needs to be kept persistent (goes in the game save), what can go through the network (game-play related feature affecting all in multiplayer), or what can be local "effect".
- marijn 15y agoBoth ActionScript and Lua are compiled, one way or another. Unfortunately, not everyone seems to have caught on to this an people are still widely referring to all dynamic languages as interpreted. Dynamic typing, garbage collection, and just-in-time compilation have a cost, which I guess is what Carmack was referring to, but the term 'interpreter' seems poorly applied here.
- Scaevolus 15y agoPeople usually use "compiled" to refer to languages that lower programs into machine code. Lowering the program into a bytecode isn't sufficient. Bytecode interpreters must be carefully optimized, and still usually have an unavoidable performance hit from their cache usage patterns (e.g. from bytecode being in d-cache).
- marijn 15y agoWhich is why dynamic languages are compiled to machine code nowadays. I'm not sure about ActionScript, but both JavaScript and Lua are compiled to machine code when speed matters.
- richcollins 15y agoThe real question is why would you write either when there are perfectly good languages that you can already use. It seems insane to me that Blizzard dumped Lua for their own homebrew scripting language. I wonder what the rationale was.
- ootachi 15y agoAhead-of-time compilation of a dynamic language with LLVM will scarcely be faster than an interpreter. This is a very common misconception. Good performance for dynamic languages requires dynamic techniques -- polymorphic inline caches, tracing, dynamic type inference, and so on.
- rwmj 15y agoSo use a static language with type inference instead. Most people don't know about these things because of the poor / non-existent education in computer science and lack of any recognized qualifications, but that's no excuse. One day this branch of engineering will need to grow up.
- kingkilr 15y agoErr, no thanks? I like my dynamically typed, interpreted + JIT compiled language thank you very much. I'm not ignorant of the type inferenced languages (in fact I use one almost every day), I just don't like it as much.
- jrockway 15y agoWait, you're both wrong. It's perfectly possible to write a statically-typed language that looks exactly like Python or Perl or Ruby. It's just that nobody's done it yet. So in the mean time, you have to pick between expressiveness and ease of development versus safety and speed. There's no concept in computer science that prevents us from having all four other than "it's hard and people are lazy". Haskell and Go are good examples of good progress in this direction, though.
- kingkilr 15y agoMaybe it could look like Python, but for damned sure it wouldn't have the same semantics, unless by statically typed, you really mean "trivially typed".
- 15y ago