Hack: a new programming language

April 10, 2014

Today facebook are releasing Hack, a programming language 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.
Hack had been deployed at Facebook and it has been a great success. Over the last year, they have migrated nearly entire PHP codebase to Hack. 


Every PHP programmer is familiar with day-to-day tasks that can be tricky or cumbersome. The code above is a great example of a common mistake where a method could unexpectedly be called on a null object, causing an error that wouldn't be caught until runtime. Another example is a complex API, where developers may have a solid understanding of its semantics but still spend time looking up mundane method names in documentation.

At Facebook scale — with thousands of engineers shipping new code twice a day — slowdowns like these are even more problematic. Before Hack, facebook had a simple language with a quick feedback loop — but how could they mitigate the sorts of problems described above? Could early error detection coexist with rapid iteration, all while preserving their investment in PHP? Could improved code analysis and introspection help make developers more productive with tools like auto-complete?
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. It offers the best of both dynamically typed and statically typed languages, and that it will be valuable to projects of all sizes.


0 komen:

Followers

Borak

Popular Posts