Facebook releases its own PHP-based programming language

Spread the love

Facebook has released a programming language that supports both dynamic and static typing. The language, called Hack, is largely compatible with PHP and allows you to run statically typed code without having to compile it.

The programming language is already used for the vast majority of Facebook, but is only now being shown to the world. The developers of the programming language have released it as open source. Hack works in conjunction with HipHop, a combination of just-in-time compiler and virtual machine previously released by Facebook under an open source license.

What makes the programming language special is that it supports both dynamic and static typing. Languages ​​with dynamic typing such as PHP and Ruby make it easier to write code, while languages ​​with static typing such as Java yield more stable, clutter-free code. Hack supports both side by side, so that new features can, for example, be built dynamically first and later be provided with static characterizations.

Hack relies heavily on PHP: most PHP files can even be run as Hack scripts without modification. However, some deprecated PHP functions are not supported, as well as some functions that proved incompatible with static typing. What’s special is that Hack makes it possible to run code with static typing without the need to compile the code.

Facebook has also released tools to transform code with dynamic typing into statically typed code. The social network has used those tools to convert most of its code to Hack. Facebook has been running on php since its inception.

alpha(); }

Example of code in Facebook Hack

You might also like