Facebook announces Hack

Julian Verlauget and Alok Menghrajani of Facebook have announced Hack, a gradually-typed variant of PHP. Hack is released open-source, features support for generic types and higher-order functions, and and compiles to HHVM. The core team for Hack features a number of the usual suspects, including Bryan O'Sullivan and Erik Meijer. Meanwhile, Simon Marlow and others at Facebook are pressing ahead with Haxl, a Haskell-based project.
However, Hack adds additional features beyond static type checking, including Collections, lambda expressions, and run-time enforcement of return types and parameter types.
Collections provide a clean, type-safe alternative to PHP arrays. We designed them specifically to work well with static typing and generics. The Collections API offers many classic higher-order functions such as map() and filter() to facilitate functional programming styles.
Lambda expressions give a concise syntax for creating closures. While PHP has closures, it requires the programmer to explicitly name the variables they need to use from enclosing scopes. With Hack's lambda expressions, we automatically infer these uses, saving you needless work. Lambda expressions make it more convenient to take full advantage of the Collections API.
Run-time enforcement of return types and parameter types (including scalar types like int and string) provides safety beyond what can be checked statically while type annotations are being gradually added to a codebase. Run-time enforcement helps programmers detect and diagnose certain kinds of problems more easily, and it helps HHVM's JIT produce more efficient code by making it safe to trust type annotations for optimization purposes.
Spotted by Shayan Najd.

Labels: , ,

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?