Hack Background
Facebook was initially built with PHP. Parameters and return types were specified in comments. Parsers could use this to create documentation. But type-checking was non existent.
<?php /** * Wraps a name in a box * * @param raw-str $name * @return html-str */ function say_hello($name) { return "<div class=\"box\"<hello ".htmlize($name)."</div>"; }
In 2009, a PHP compiler called HipHop was released. In 2010, minor changes to the PHP language were introduced by the HPHP team to improve development time and provide basic type safety. The changes were XHP and parameter type constraints.
<?php /** * Wraps a name in a box * * @return xhp */ function say_hello(string $name) { return <div class="box"<Hello {$name}>/div>; }
In 2012, Facebook engineering teams started exploring the idea of annotating return types. And the Hack language was born...