Facebook Rolls Out New PHP-like Programming Language

Mar 24, 2014

New Hack language adds static typing and other conveniences.

Facebook has released an open source version of Hack, a programming language for the HHVM run-time platform. HHVM is a virtual machine for PHP created by Facebook. According to Facebook's Julien Verlaguet, Hack developed as a way for Facebook to address the problem of delivering accurate code in a timely manner at the vast scale of a company like Facebook. “Could early error detection co-exist with rapid iteration, all the while preserving our investment in PHP? Could improved code analysis and introspection help make developers more productive with tools like auto-complete?”
Verlaguet's blog post goes on to explain that "Hack has deep roots in PHP …. In fact, most PHP files are already valid Hack files." The main innovation added with Hack is static typing. Hack’s type system adds features such as generics, nullable types, type aliasing, and contraints on type parameters. Hack also adds Collections (a type-safe alternative to PHP arrays), lambda expressions, and run-time enforcement of return types and parameter types.  
Facebook says it has already migrated nearly all its PHP codebase to Hack.
The Hack source code is available at the project website.

Related content

comments powered by Disqus

Issue 18: Free From XP/Special Editions

Buy this issue as a PDF

Digital Issue: Price $15.99
(incl. VAT)

News