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".
[ Parent
| on HN ]
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.