Facebook has announced a new programming language called Hack. Hack is an open-source language for programmers. Hack is developed for HHVM that interoperates seamlessly with PHP.
The new programming language helps developers to program faster and also catch errors more easily. This is what Facebook post says about Hack language:
Hack has deep roots in PHP. In fact, most PHP files are already valid Hack files. We made a conscious choice not to support a handful of deprecated functions and features that were incompatible with static typing (e.g. “variable variables” and the extract() function). We have also added many new features that we believe will help make developers more productive.
Our principal addition is static typing. We have developed a system to annotate function signatures and class members with type information; our type checking algorithm (the “type checker”) infers the rest. Type checking is incremental, such that even within a single file some code can be converted to Hack while the rest remains dynamically typed. Technically speaking, Hack is a “gradually typed*”* language: dynamically typed code interoperates seamlessly with statically typed code.
Within Hack’s type system, we have introduced several features such as generics, nullable types, type aliasing, and constraints on type parameters. These new language features are unobtrusive, so the code you write with Hack will still look and feel like the dynamic language to which PHP programmers are accustomed.
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.
To know more about Hack programming language head over to Facebook post.