What is at stake? ● Consequence of subtle bugs: – Corrupt database, etc.. ● Consequence of difficult APIs: – Copy pasta, $needle or $haystack first ● Consequence of difficult refactoring – Bad APIs stay bad
● A statically typed language for HHVM ● Compatible with PHP: – Interoperates with no overhead – Same representation at runtime ● Evolved from PHP: – If you know PHP, you know Hack! ● Designed for incremental adoption: – Gradual typing
Type annotations at run time function foo(int $x): void { .. } foo('baz'); // Output Fatal error: Expected int, string given function bar(): bool { return 3.14; } // Output Fatal error: Expected bool, float given
The Hack Collections framework is a set of language features and APIs that serve as a complete alternative to PHP arrays // PHP arrays $a = array(1, 2, 3); $b = array('a' => 4, 'b' => 5); function foo(array $c): void { .. } // Hack collections $a = Vector {1, 2, 3}; $b = Map {'a' => 4, 'b' => 5}; function foo(Map $c): void { .. }
More features ● Async/await ● Constructor promotion ● Trailing comma's in function calls ● Trait requirements ● User attributes (<> class C {}) ● <> ● ...