Computer programmers know that misplacing a decimal point could mean their entire program is broken, but Facebook Inc (NASDAQ:FB) believes its new programming language will change that. The social network unveiled the language it calls “Hack” today, saying that it should speed up programming while also making it easier to catch errors in code.
Facebook runs on Hack
In a post today, Facebook said its engineers developed the new programming language for HHVM and that it “interoperates seamlessly with PHP.” They also said it “reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming language.”
Facebook Inc (NASDAQ:FB) engineers said they have already had success in deploying the new programming language at the social network. At this point, they have been able to migrate almost the entire PHP codebase over to Hack using organic adoption and some “homegrown” refactoring tools. They even released an open-source version of the programming language so that anyone can use it.
Facebook wants to speed up programming
The social network showed an example of how Hack makes it easier to catch errors made in coding. The engineers say the error in the example wouldn’t have been caught until runtime, which would slow down the process because that error wouldn’t be caught until later. So they began to look for ways to detect errors earlier while also speeding up programming and “preserving” Facebook Inc (NASDAQ:FB)’s investment into PHP.
They note that traditional languages which are dynamically typed make it possible to develop programs quickly, but they lack the ability to detect errors early in the process and quickly introspect code. On the other hand, statically typed languages usually lack quick iteration, so they basically incorporated the best of both words into the Hack programming language.
Hack and PHP
The Facebook Inc (NASDAQ:FB) engineers say there’s a deep connection between Hack and PHP and that most PHP files are already valid for Hack. They added static typing and made type checking incremental so that not all of the code in a single file must be converted to Hack. They call Hack a “gradually typed” language in which “dynamically typed code interoperates seamlessly with statically typed code.”
They also added Collections, lambda expressions and run-time enforcement of return and parameter types.