What exactly is HHVM and/or PHP execution engines?
Asked Answered
N

1

6

I've been reading about Facebook's Hack which lead me to reading about HipHop Virtual Machine. I wanted a better understanding of this and could not find a clear definition. Wikipedia defines it as: HipHop for PHP (shortened as HipHop) describes a series of PHP execution engines and improvements created by Facebook. I don't understand what PHP engines are...

So I guess then my question is: What exactly are "PHP execution engines?" and how exactly do the benefit PHP applications?

Thanks!

Nik answered 24/3, 2014 at 15:26 Comment(0)
G
9

You can run your PHP code with the standard (Zend) engine that you download from php.net, that works great. If you download WAMP, MAMP, or any of the other pre-packaged PHP & MySQL for your Operating system packages, this is what you're getting.

Alternately you can run (most of[1]) your PHP code with HipHop, that works great.

Which one you're using should be effectively invisible to your end users. Your developers, and operations teams will need to know.

You may choose to use HipHop if you're running a site that gets a lot of traffic. HipHop while not supporting all of the features of PHP, does run a bunch faster. It also has some new features not available in the main PHP distribution mostly to do with type hinting. These can provide some pretty attractive tools to read through your code checking for bugs.

Reasons you may want to use HipHop:

  • Performance is a big deal for you
  • The static analysis tools available with HipHop have serious worth to your team
  • The new features in HipHop but not in Zend PHP are attractive to your team.

Reasons you may want to use Zend PHP

  • You need an extension not available for HipHop (there's lots of extensions out there, think: gd, curl, imagemagik, etc. Many are available for HipHop now, many aren't).
  • Your code, or framework is making use of unsupported features.
  • You have a lot of expertise in hosting your current Webserver & PHP stack, and don't want to start from scratch.

This post goes into some HHVM vs HACK differences, and gives a nice run down: http://www.marco.org/2014/03/21/hack

[1] Not all code that you can run with the regular PHP engine currently works on HipHop. They're working on most of the issues, some they've just decided not to fix (I think variable variables may be an example of this e.g. $$var)

Guitar answered 24/3, 2014 at 15:30 Comment(1)
Re [1] -- HHVM is a runtime for both the standard PHP language, and the Hack language. While Hack does outlaw certain features of PHP such as $$var in Hack code, HHVM will still allow those features when running PHP code.Abisha

© 2022 - 2024 — McMap. All rights reserved.