Wednesday, March 26, 2014

Facebook Q&A: Hack brings static typing to PHP world

Facebook Q&A: Hack brings static typing

 to PHP world


Wednesday, 26 March 2014

Julien Verlaguet, a designer of the Facebook-driven 

language, talks about how Hack marries static typing

 with the benefits of fast PHP development


USE STORY HED HERE
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.
CrazyWorld 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.
Crazy World: 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 that 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. And that's the kind of thing that 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.
Crazy World: 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.

Crazy World: Hack compiles to the HHVM?
Verlaguet: [Hack] runs on the exact same [HHVM] virtual machine indeed. And that's why it tends to operate very well with PHP because HHVM was designed to run PHP so the two interoperate seamlessly. What it means is that from Hack code you can call PHP code and PHP code can call Hack code and it's all compatible.
CrazyWorld: Where have you used Hack in Facebook?
Verlaguet: We converted nearly all of our [PHP] code base to Hack. 
Crazy World: What's the next step for Hack? Is there a 1.0 version coming out?
Verlaguet: We still have plenty of things to do on the language itself. We have to keep aware of the fact that for now it's a tool for Facebook. Now that we have open-sourced it, we need to take into account the feedback of the new users who are going to try to use Hack for their own needs and we are probably going to spend some time doing that. People are going to try Hack on their own projects. They're going to have problems because they are probably using PHP and Hack in a different way than we do it at Facebook and we will have to go after these problems one after another. So that's what I expect is happening. When we are comfortable with the version that we have, I hope we can [offer] a first stable release.
Crazy World: When do you think that might happen?
Verlaguet: It depends how much adoption we get. If we have a lot of feedback, a lot of people engaging, it could be a few months. It will depend on how many people engage [and the number of problems found]. That's very hard to predict.

0 comments:

Post a Comment