Facebook Releases Open Source Hack Language to Improve on PHP
Facebook has released a new open source language, called Hack, that integrates with the popular PHP language and includes many of the safety features in older languages such as C++. You can try Hack now at http://hacklang.org/ During the past year, Facebook has been converting nearly its entire PHP code base to Hack.
According to a post on Hack:
"Today we're releasing Hack, a programming language we developed for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.We have deployed Hack at Facebook and it has been a great success."
"Traditionally, dynamically typed languages allow for rapid development but sacrifice the ability to catch errors early and introspect code quickly, particularly on larger codebases. Conversely, statically typed languages provide more of a safety net, but often at the cost of quick iteration. We believed there had to be a sweet spot. Thus, Hack was born. We believe that it offers the best of both dynamically typed and statically typed languages, and that it will be valuable to projects of all sizes."
According to Facebook, most PHP files are already valid Hack files, so developers with large blocks of PHP code can hit the ground running with the new language. Interestingly, Facebook has implemented a type checker in Hack as a local server that watches the filesystem. The server keeps all information about the source code in memory and automatically updates itself when a file changes on disk.
The announcement post adds:
"We are delighted to open source both Hack and the tools you can use to automatically convert your codebase. This is just the first step, and we are dedicated to continuing to evolve this software to make development even easier for both our own engineers and the broader community. Hack's value is *not* limited to big projects: with type information, good error messages, and fast feedback, small codebases can reap the benefits of Hack as well. Next month, we will also introduce the language at the Hack Developer Day on the Facebook campus in Menlo Park, and we hope to see you there in person or online."