News for hackers. Stuff that matters.
Re:John Carmack: Script Interpreters Considered Harmful by rwmj on Saturday August 13, 2011 @02:03PM (#2881527)
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.

Re:John Carmack: Script Interpreters Considered Harmful by ootachi on Saturday August 13, 2011 @04:43PM (#2881952)
Ahead-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.
Re:John Carmack: Script Interpreters Considered Harmful by rwmj on Saturday August 13, 2011 @05:37PM (#2882068)
So 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.

Re:John Carmack: Script Interpreters Considered Harmful by kingkilr on Saturday August 13, 2011 @07:17PM (#2882258)
Err, 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.
Re:John Carmack: Script Interpreters Considered Harmful by jrockway on Saturday August 13, 2011 @08:19PM (#2882368)
Wait, 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.

Re:John Carmack: Script Interpreters Considered Harmful by tomp on Sunday August 14, 2011 @05:46AM (#2883262)
> 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

Really? You should definitely show us how.

I've been thinking about the issues of dynamic/static languages for a long time, and haven't yet thought of a unifying design (maybe I'm just stupid).

The big difference isn't type inference/dynamic type system, it's the difference between compile-time and run-time. In Go and Haskell, classes are compiled. In Python, classes are created at runtime, so if you wanted type-inference in such a language, it would have to be performed at runtime... Also, proper typing of OO languages is very complicated, see Scala (e.g. sometimes you want the function to return the type of this object, even when it is inherited...).

Re:John Carmack: Script Interpreters Considered Harmful by kingkilr on Saturday August 13, 2011 @11:33PM (#2882722)
Maybe 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".
Re:John Carmack: Script Interpreters Considered Harmful by jrockway on Sunday August 14, 2011 @03:13AM (#2883026)
Why? Python already requires type annotations. For example, if you have a string "42", you can't just add 1 to it to get the number 43, you have to say int("42") + 1 or it will throw a type error.
Re:John Carmack: Script Interpreters Considered Harmful by joesb on Sunday August 14, 2011 @05:41AM (#2883254)
It throws type error at run time, not compile time.

To be a statically type language you would need to throw the error at compile time.

How do you raise (or not raise) error of this code at compile time and still make it feel like dynamic type language?

    x = (rand() > 0.5) ? 42 : "42"
    y = x + 1;
Re:John Carmack: Script Interpreters Considered Harmful by jrockway on Sunday August 14, 2011 @08:05AM (#2883428)
The type of x is Int|String

The type of (+ 1) is Int -> Int

The type of y is Int

Because x is of type Int|String and it's passed to a function that can only operate on Int, the program fails to compile.

Re:John Carmack: Script Interpreters Considered Harmful by kingkilr on Sunday August 14, 2011 @11:10AM (#2883797)
I highly reccomend you read, "Localized type inference of atomic types in python" by Brett Cannon (2005), it shines a light on just how much this doesn't work.
Re:John Carmack: Script Interpreters Considered Harmful by ned_batchelder on Monday August 15, 2011 @11:29AM (#2887276)
So when you said, "looks just like Python," you literally meant, "lexically looks like Python," because you aren't building a language that works just like Python.
Re:John Carmack: Script Interpreters Considered Harmful by DasIch on Sunday August 14, 2011 @11:11AM (#2883800)
That is not a type annotation. Python is simply strongly typed that has nothing to do with whether or not the language is dynamically or statically typed.
Re:John Carmack: Script Interpreters Considered Harmful by cpeterso on Monday August 15, 2011 @05:36PM (#2888824)
PyPy's RPython language is a subset of Python that can be compiled. Unfortunately, RPython was designed to bootstrap PyPy and not general-purpose applications.

Python 3 added optional type annotations for function parameters and return types. Unfortunately, Python does not use these annotations for compile-time or run-time type checking. The annotations are just for documentation or tools that want to analyze the type attributes.

Re:John Carmack: Script Interpreters Considered Harmful by mathgladiator on Saturday August 13, 2011 @03:31PM (#2881767)
The 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

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).

Re:John Carmack: Script Interpreters Considered Harmful by richcollins on Saturday August 13, 2011 @04:42PM (#2881944)
The 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.
Re:John Carmack: Script Interpreters Considered Harmful by marijn on Saturday August 13, 2011 @04:22PM (#2881900)
Both 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.
Re:John Carmack: Script Interpreters Considered Harmful by Scaevolus on Saturday August 13, 2011 @05:02PM (#2881996)
People 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).

Re:John Carmack: Script Interpreters Considered Harmful by marijn on Monday August 15, 2011 @02:42PM (#2888131)
Which 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.
Re:John Carmack: Script Interpreters Considered Harmful by malkia on Saturday August 13, 2011 @03:41PM (#2881799)
Turn-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".

Re:John Carmack: Script Interpreters Considered Harmful by delinka on Saturday August 13, 2011 @02:29PM (#2881596)
With 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.

Re:John Carmack: Script Interpreters Considered Harmful by nostrademons on Saturday August 13, 2011 @02:53PM (#2881676)
If 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.
Re:John Carmack: Script Interpreters Considered Harmful by prodigal_erik on Saturday August 13, 2011 @03:09PM (#2881710)
I 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... which attacks a native XML toolset (some "data binding" IE feature I don't understand) without breaking any javascript rules.
Re:John Carmack: Script Interpreters Considered Harmful by krakensden on Saturday August 13, 2011 @03:19PM (#2881740)
> 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.

Re:John Carmack: Script Interpreters Considered Harmful by teamonkey on Sunday August 14, 2011 @11:52AM (#2883850)
Also, 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.

Re:John Carmack: Script Interpreters Considered Harmful by jacques_chester on Monday August 15, 2011 @02:07AM (#2885737)
> 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.

Re:John Carmack: Script Interpreters Considered Harmful by swah on Saturday August 13, 2011 @03:16PM (#2881732)
Not hard comparing to what? Its still pretty hard... even jonesforth is kinda hard to get for most developers.
Re:John Carmack: Script Interpreters Considered Harmful by rwmj on Saturday August 13, 2011 @05:40PM (#2882078)
I hope no one uses jonesforth [or FORTH] for real development. It's a beautiful thing to learn and I encourage everyone to learn how to write a FORTH, but it's an anti-pattern for real world programming. (Edit: this is not a contradiction)
Re:John Carmack: Script Interpreters Considered Harmful by Ralith on Saturday August 13, 2011 @09:39PM (#2882507)
Why do you say that?