PHP Evolved: Facebook's New Hack Programming Language

| by Jeff Martin Follow 11 Followers on Mar 27, 2014. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

Facebook's propensity for PHP is fairly well-known. Dating back to the company's early days, PHP has powered many of the company's offerings. One of PHP's strengths is that it is a dynamic language well-suited to rapid prototyping, but this same attribute tends to complicate the development and maintenance of large code bases. To address these concerns, Facebook has released Hack, a new programming language intended to maintain PHP's strengths while augmenting this with what they call gradual-typing and several new language features.


This use of gradual typing means in Hack dynamic and statically-type code can inter-operate in the same file. This lets existing PHP code be converted to Hack according to the needs of each project it is used in without requiring a large up-front conversion cost. To assist with a PHP to Hack migration, Facebook is providing conversion tools. Hack itself works by monitoring your source file as you edit it. A system daemon monitors your local filesystem, and when changes are saved to disk a type checker will quickly analyze the changes. Facebook indicates that this turnaround averages 200ms and should rarely exceed 60 seconds.


Hack isn't just bringing typing characteristics, it is also providing several additional language features. These include type annotations, nullable types, generics, collections, and lambdas. The Hack language reference provides full details on all features currently available. Just like the PHP code at Facebook, Hack runs on Facebook's Hip Hop Virtual Machine (HVVM) which uses just-in-time compilation to boost program performance.


For more background on PHP at Facebook, InfoQ published an interview with Facebook's Keith Adams this past December.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Hack Language Tutorial by santosh tewari

Hey Friends find tutorial of Hack language here:

have fun

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you