Hack 语言学习/参考---1.2 Hack Background

原文链接http://www.cnblogs.com/Jack8Chen/p/3620895.html

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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...