Hack is a programming language for the HipHop Virtual Machine (HHVM) invented by Facebook.Hack can be seen as a new version of PHP that also runs on the HHVM, but it allows programmers to use both dynamic typing and static typing. This is what is called gradual typing, which has been mostly seen as an academic exercise; as described by Facebook, it is the first to bring gradual typing to a “real, industrial strength” language.


Hack Features

Hack interoperates seamlessly with PHP, which is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Majority of scripts that are valid in PHP are also valid in Hack.[4] Hack’s type system allows types to be specified for function arguments, function return values, and class properties; types of local variables cannot be specified.

Syntax and Example

The basic file structure of a Hack script is similar to a PHP script with a few changes. A Hack file starts with


There are many people who have contributed to the development of Hack.

The core Hack team consists of Julien Verlaguet, Joel Beales, Eugene Letuchy, Gabriel Levi, Joel Marcey, Erik Meijer, Alok Menghrajani, Bryan O’Sullivan, Drew Paroski, James Pearce, Joel Pobar, and Joshua Van Dyke Watzman.

A special thanks goes to our early community adopters for providing valuable feedback to make the language better: James Miller, Simon Welsh, Nils Adermann, Fabien Potencier, and Alexander Mols.

Hack is written primarily in OCaml. We would like to thank the Gallium team (INRIA) for the development of the OCaml language, and the Ocsigen team (CNRS – University of Paris Diderot – INRIA) for the development of the js_of_ocaml part of Ocsigen.

And, of course, thank you to everyone else who has helped make Hack the language it is today. The list is too exhaustive for a blog post, but you know who you are.