1. Hack 是什么?
Hack 是一种编程语言,用以实现HHVM与PHP的无缝互操作。Hack通过静态编辑确保了PHP的快速开发周期,与此同时又添加其它主流语言的很多通用功能。
Hack通过检索本地服务器的文件系统表提供即时的类型校验,校验耗时通常小于200毫秒,因此它很容易集成到你的开发流程中而不引入明显的延时。
下面是Hack语言一些非常重要的特性:
1 <?hh 2 class MyClass { 3 const int MyConst = 0; 4 private string $x = ‘‘; 5 public function increment(int $x): int { 6 $y = $x + 1; 7 return $y; 8 } 9 }
1 <?hh 2 class Box<T> { 3 protected T $data; 4 5 public function __construct(T $data) { 6 $this->data = $data; 7 } 8 9 public function getData(): T { 10 return $this->data; 11 } 12 }
<?hh function foo(): (function(string): string) { $x = ‘bar‘; return $y ==> $x . $y; } function test(): void { $fn = foo(); echo $fn(‘baz‘); // barbaz }
Other significant features of Hack include Shapes, Type Aliasing, Async support, and much more.
Hack其他一些重要特性包括Shapes, Type Aliasing, Async support等。
更多详细信息请查阅:http://hacklang.org/
Facebook Hack 语言 简介,布布扣,bubuko.com
原文:http://www.cnblogs.com/Jack8Chen/p/3616801.html