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...
转载于:https://www.cnblogs.com/Jack8Chen/p/3620895.html