4 ms·
It's interesting that "sound gradual typing" (i.e. static analysis with runtime type checks, AIUI) has supposedly caused large performance problems in some lang
by TazeTSchnitzel 11y ago
It's interesting that "sound gradual typing" (i.e. static analysis with runtime type checks, AIUI) has supposedly caused large performance problems in some languages. Hack, Facebook's sound, gradually-typed dialect of PHP, doesn't seem to have this problem. And PHP itself, which doesn't do any static type checks itself (you must use a separate static analyser if you want that), only runtime ones, has had limited type checking for eleven years, without apparent performance problems.
Are these systems with performance issues doing something fundamentally different, or more complicated? Perhaps I am misunderstanding something.
- ben_greenman 11y agoThe systems with performance issues are the sound ones! Hack does not have a type soundness guarantee. The compiler statically checks your type annotations, but then generates untyped PHP code. If Hack-generated PHP interacts with PHP from 5 years ago, "type errors" are possible. (I have to say "type errors" in quotes because a mismatch between originally-typed and originally-untyped PHP could result in any kind of error message, or no error at all!) Systems like Typed Racket do type checking at runtime when interacting with untyped Racket code. These runtime checks are the performance problem, but they do accurately diagnose type errors.
- TazeTSchnitzel 11y ago> The compiler statically checks your type annotations, but then generates untyped PHP code. If Hack-generated PHP interacts with PHP from 5 years ago, "type errors" are possible. That's not entirely true. Though some parts of Hack's annotations are not enforced by the runtime, if you say a function takes an int and pass it a float at runtime, it does throw an error from what I remember. It's correct that Hack doesn't guarantee runtime soundness, though.