The Hack language, which brings static typing to the dynamically typed PHP realm, recently was released by developers at Facebook, who have linked the language to Facebook's HipHop Virtual Machine (HHVM) for PHP. Already deployed at Facebook, Hack has been the work of engineers Julien Verlaguet, Alok Menghrajani, and a team of developers.
InfoWorld Editor at Large Paul Krill recently spoke with Verlaguet, who is a designer of the language and a tech lead for languages and tools at Facebook, about the intention of Hack and where the language goes from here.
InfoWorld: What is the purpose of Hack?
Verlaguet: What is happening is that Facebook started using PHP because PHP has a very fast feedback loop and that's something you want. It's extremely valuable when you are building a website. What it means is that when you're writing your program, the code -- when you're editing it, when you're changing it -- the time it takes to try your change and run it is very, very [minimal]. That's extremely valuable and that's something that we wanted to keep.
However, dynamically typed languages in general -- and that's not a problem just with PHP -- they offer [fewer] guarantees, like static guarantees. What it means is that there is an enormous amount of tooling available for programmers that check that your program is correct in other languages, in languages known as statically typed, such as Java. Tools such as a type checker, they provide a safety net in the sense that they're going to find errors in your program before you even run it. That's the kind of thing we were interested in building for Facebook, and that's why we developed Hack, which is a language that is compatible with PHP but adds static typing and other language features that make the life of developers easier.
InfoWorld: What other features?
Verlaguet: One important contribution from [Hack team member] Drew Paroski is collections. Collections are designed to replace arrays. PHP arrays are useful, but they have had too many use cases and some of them can be misleading for programmers. What Drew did is that he took all these use cases and designed a collection API that was separating them in clean subsets. So now you have an object set, an object vector, an object map that is specialized for each use case, while arrays were used for everything before that.