Social media leader Facebook has just released a new open-source language named, Hack, that integrates with the ever-popular language PHP. The new language will allow their engineers to increase their speed in code writing while at the same time Hack easily avoids common programming errors.
One of the best features of Hack is the ability to combine elements of static web page coding and dynamic languages, such as Ruby or PHP. The new language has been built to detect early mistakes before the runtime occurs and which is sometimes seen only with static programming languages.
Facebook has already migrated their newly released open source language into their PHP-based website. The transition of integrating their language into their site was aided by Hack’s ability to work side-by-side with PHP. With Facebook released Hack as “open-source” means that any engineer or programmer can add to the language or improve on it. This should also invite more integration with third-party app creators and contributors to Facebook add-ons.
Facebook engineer, Gabe Levi, led the conversion to Hack, says that the new language allows faster coding. Features of Hack include: adding safety nets, adding language features, ease of code conversion from PHP, and the ability to run side-by-side with PHP to allow a gradual progression to total code conversion.
Levi stated that a lot of hard work went into the new language by Facebook engineers. “There are many great, original ideas in Hack” said Levi, but the majority of time was spent on a lot of fine tuning opposed to having large breakthroughs.
Last year Facebook solved some server issues by running all of their Facebook PHP code on a “Hip Hop Virtual Machine” or HHVM for short. The HHVM allowed Facebook to run the entire company with a lot fewer servers. Now Hack will also run on the HHVM and allow them to manage their code easier and eliminate errors at the same time.
Some engineers say that you can basically call Hack a new version of PHP. The big difference from Hack to PHP is that it allows “gradual typing” which is a combination of static and dynamic typing. Until now, there really hasn’t been a language that allowed gradual typing, which makes the new language have “industrial strength.”
The gradual typing means that static code can be added into dynamic code and vice versa. This allows a coder to work on both code snippets and improve either one or both at the same time. By using Hack, Facebook engineers are creating much more precise code and code with a lot less flaws. Because Hack runs without the need to be compiled first, an engineer can add code, refresh the page and immediately see the changes without any delays like there would be if they were solely working with a language such as PHP.
PHP is the most widely used language on the web, but still the language struggles to address many inconsistencies. Hack addresses these existing challenges with PHP.
In the past, new programming languages had to be promoted to have them gain in popularity. Facebook has already endorsed the new language by deploying it on their own servers before releasing Hack to the public which negates the need for them to promote Hack. With the new open-source language already used by the biggest social media site on the internet, even non-PHP engineers are expected to make the transition to Hack as well.
By Brent Matsalla