Question

Facebook have introduced a new programming language, which looks mostly like an extension to PHP. They've called it Hack and it's running on their HHVM engine.

After seeing their website and reading a bit about it, I wondered how fluid a migration from PHP to Hack could potentially be.

Let's base this discussion around a web application already deployed to a LEMP or LAMP stack.

Some of my initial thoughts and list of actions include:

  • How do I run both PHP and Hack in the process of migrating the code base?
  • Migrate from nginx/Apache to HHVM
  • Migrate code base iteratively

So, how would you approach this?

Était-ce utile?

La solution

I'm an engineer at Facebook who worked on Hack. In particular, I wrote several parts of the conversion tools and then applied them across Facebook's codebase. This indeed should probably be several questions -- it depends on how exactly your project is set up, what PHP feature you're using, and so forth. Some good starting resources include:

  • Get HHVM installed. Right now, Hack is only available if you use the nightly packages (only available for Debian and Ubuntu) or if you compile from our github source, so make sure you do one or the other.
  • Get your code running on HHVM with nginx and fastcgi. This should be pretty straightforward -- HHVM is supposed to run PHP code out of the box. If it doesn't, it's a bug.
  • Get the Hack typechecker running on your project. This won't do much since all your code is PHP.
  • Start running our conversion tools and getting more Hack code in your codebase. We seamlessly interoperate with PHP, so you can do as much or as little of this as you want, as quickly or as slowly as you want. From here, you're golden -- do whatever makes sense for your project!

That's what you need to get started. Specific followups would be best asked as a separate question. I'll try to keep an eye on SO and answer where I can to help folks get started! You can also join us on IRC, #hhvm on Freenode.

Autres conseils

From the sounds of it, it will be nearly seamless to transition. From the Wired Article about it:

Hack will be particularly attractive, Adermann says, to existing PHP shops. “Ironically,” he says, “its chief advantage is how little it differs from PHP.” Like Facebook, these shops can gradually move their operations from one language to the another.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top