Foreword

In 2012, I started working on a project called “strict-mode” with Alok Menghrajani. The goal was, in a nutshell, to build a statically typed version of PHP on top of HHVM.

The success of that project (which later became Hack) has amazed me ever since. What began as a basic typechecker has become a full-blown programming language with industrial-strength tools to back it up.

Looking back, we have come a long way. When we first pitched the idea to the HHVM team, I am pretty sure they thought we were crazy. But somehow, we convinced them to join us in the adventure.

At the end of June 2012, Facebook deployed Hack code to production for the first time. Just like that, without any management approval, without any process of any kind, Facebook had a new language in production.

At that time, I was expecting someone to knock on our door to stop us, but somehow that day never came.

Many engineers followed after that, and before we knew it, most new code within Facebook was written in Hack. We then decided to automatically convert the rest of our PHP codebase to Hack. We went from a dynamically typed to a statically typed codebase at a gigantic scale (tens of millions of lines).

That process was especially challenging given the client/server architecture that we adopted for the typechecker. We wanted instantaneous response times from the typechecker, because PHP developers were used to a very fast edit/refresh cycle. That’s why we needed the Hack typechecking server: a daemon maintaining the typing information in the background at all times. Of course, the tricky part was to keep the state of the server consistent with the filesystem.

It took many sleepless nights to stabilize the typechecking server, but that approach is really what makes Hack so special today. The typechecker response times are instantaneous (so fast we use it for auto-complete), and it can keep up with a huge volume of updates.

I am very pleased that there’s now a definitive reference book on Hack and HHVM. Owen has done a very good job of explaining even the subtlest parts of the language (such as type inference), and everything else you need to know to be productive in Hack/HHVM (debugging, etc.).

Have fun with Hack and HHVM!

Get Hack and HHVM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.