Hack, the future of PHP?

2 views
Skip to first unread message

Michael Beck

unread,
Mar 22, 2014, 9:53:14 PM3/22/14
to oin...@googlegroups.com
Anybody had a chance to look into it?
 
 

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.

Some of the other additions, like lambda expressions and collections, are clearly inspired by similar features present in other languages in wide use. JavaScript, for instance, uses lambda expressions in the form of anonymous functions. And while PHP itself has anonymous functions, Facebook claims Hack requires less work than PHP on the part of the programmer to make them useful.

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.

Reply all
Reply to author
Forward
0 new messages