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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。