What is Hack? ¶
Hack is a language for HHVM that interopates seamlessly with PHP. The barrier to entry for Hack is low. To get started, all that is needed is to generally understand the features that Hack provides and how to call the Hack type checker(hh_client invokes the type checker at the command line)
The goal of Hack to offer developers a way to write cleaner, safer and refactorable code while trying to maintain a level of compatibility with current PHP codebases. The primary way that this goal is achieved is to provide developers a way to annotate PHP functions and classes with type information, providing a type checking tool to validate those annotations. In addition, Hack also provides specific language feature additions such as:
Each of the Hack features, and more, is discussed in great detail in this documentation.
Hack code is indicated through the <?hh marker at the top of a file, as opposed to the canonical <?PHP marker.
Very important note: The type checker is invoked before runtime to determine whether code is typesafe. While HHVM kNows about and understands the Hack language, it does not necessarily strictly enforce them. This is different from a true statically-typed language like C# where code is type checked at compile time and enforced (usually via some sort of exception mechanism) at runtime.
转载于:https://www.cnblogs.com/Jack8Chen/p/3620802.html