Hack 语言学习/参考---1.1 What is Hack?

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.

posted @ 2014-03-24 14:35  Mr 88  阅读(324)  评论(0编辑  收藏  举报