It seems Facebook wasn't satisfied with merely building a virtual machine for PHP, HHVM, which compiles that language to C++ for faster execution. Facebook has now gone ahead and made a full-blown spin-off of PHP, called Hack, which purports to fix many of the lingering issues with PHP and adds some new features that Facebook feels the language has long needed.
Unveiled earlier this week, Hack runs on the HHVM and uses the PHP language as a starting point for its syntax. "In fact, most PHP files are already valid Hack files," the company has noted in a post to its engineering blog. Certain functions have been deprecated, but many others added. The biggest set of additions involves the ability to statically type objects, but also mix code where statically and dynamically typed objects are used.
Many of Facebook's goals for the language revolve around making software development fast and much more robust. PHP has traditionally been known for its ease in developing software, but also for being difficult to debug without third-party support (such as by using Zend for code tracing). Another touted goal was to run as much unmodified PHP-5 code as possible, so existing codebases and libraries can be dropped in and run as-is.
Another long-term design goal -- more implied by the language's construction than explicitly stated by Facebook -- is making Hack safer with fewer inherent vulnerabilities than PHP. In addition to the type-checking constraints now available in the language, there's also the way Hack was written; rather than being coded in C, as PHP was, Hack was designed using the OCaml language -- the same platform used by the Xen Project folks to develop its secure-by-design Mirage OS. PHP has had its share of low-level vulnerabilities over the years, not all of them obvious (or specific to that platform), so it makes sense to adopt a new design methodology that makes casual exploits more difficult to pull off.
Facebook is pushing hard on third parties to pick up Hack and run with it. The company has stressed how its own engineering team voluntarily converted the Facebook codebase to Hack and has released the source code under the same license as PHP itself. Getting Hack up and running may require a little more work than PHP at this stage, since only Debian and Ubuntu Linux have pre-built packages; versions for other editions of Linux need to be compiled from scratch using OCaml 3.12 -- another item that needs to be obtained and set up -- and there's currently no official builds or binaries for other platorms (such as Windows). PHP's main advantages its ubiquity and the minimal effort needed to get a PHP application running on most any commodity operating system.
Davey Shafik of PaaS vendor Engine Yard looked at Hack and had generally positive impressions, but did note several possible short-term stumbling blocks: lack of IDE support and lack of support for some standard PHP extensions (Facebook is adding them as it goes).
There's also the larger question of whether Hack and HHVM will end up contributing toward a long-term fragmentation of PHP, with PHP going one way, Hack going another, and programmers feeling torn between the two.
The way Shafik saw it, Hack and HHVM "are a great place to trial new potential features for PHP in general, and we can hope to see a lot of the great features back ported to PHP.net in the future." If Hack turns out to be the Fedora Project to PHP's Red Hat Enterprise Linux -- a staging ground for cutting-edge ideas that may eventually be ported into the mainstream product -- it might come as big a surprise to Facebook as it does to the rest of the PHP community.
This story, "Facebook's Hack language builds on PHP," was originally published at InfoWorld.com. Get the first word on what the important tech news really means with the InfoWorld Tech Watch blog. For the latest developments in business technology news, follow InfoWorld.com on Twitter.