PHP future: Facebook's Hack_PHP tutorial

Source: Internet
Author: User
Tags hhvm
The future of PHP: Facebook's Hack. The future of PHP: Facebook's HackFacebook released a new programming language, Hack, which is similar to the popular PHP language from any perspective. Its large number of features are better than PHP's future: Facebook's Hack

Facebook released a new programming language, Hack, which is similar to the popular PHP language, from whatever perspective. Its many functions, such as static types, are consistent with the long-term requirements of PHP developers. Aside from the syntax, Hack is not actually PHP. Hack runs on Facebook's virtual machine HHVM, while its competitors run on the traditional PHP Zend Engine.

Why does Facebook need to establish Hack?

First, Facebook's internal code is written in PHP. at the same time, Facebook allows many new developers to use PHP, because the language is easy to learn and use. Of course, Facebook's PHP code may be converted to C derivatives and pushed to the previous production environment. The key to the problem is that Facebook is strongly dependent on the PHP language to attract new talents and improve the efficiency of developers.

Strict type

Unfortunately, PHP cannot be executed on Facebook scale. Because PHP is a loose language, many type errors may not be detected during running. This means that Facebook had to write a lot of tests to execute type error checks early on, or spend more time rebuilding post-release running errors. To solve this problem, Facebook adds a strict type to launch attacks on the return type at runtime. Strict types eliminate the necessity of many related unit tests and encourage developers to capture type-related errors during early development.

Instantaneous type check

To make it easier to capture errors during development, Facebook's HHVM engine contains a type of check server that monitors Hack code when running locally. The developer's code editor and IDE can use this type check server to immediately report errors related to syntax or type during code development.

What about the existing PHP code?

Most of the existing PHP code will run on Facebook's HHVM engine, which is necessary because Facebook's existing code base is mainly PHP code. Hack code has some exceptions. after all, it is not equivalent to the traditional PHP code, such as some language features such as variables) and Zend extensions are still not supported. With the passage of time, HHVM will also implement parity verification with the Zend Engine as soon as possible.

In addition, the Hack language created by Facebook is gradually migrated from the traditional PHP code.

Does this mean that PHP is "dead?

If the Hack is so good, does it mean that there are only a handful of PHP days? Of course, the answer is: NO! The traditional PHP Zend is approved by the management of specialized institutions. any new function must be approved by the members of the institutions before it can be published. such a vote is 100% fair and open.

However, Hack is very good. it has many unique features, so it is never possible to become a traditional PHP language. Facebook's HHVM engine has better performance than the Zend Engine, and it has more internal developers who are committed to continuously making the HHVM engine better.

This does not mean that PHP's Zend Engine will disappear, and Zend and HHVM engines will coexist. Competition is a good thing. I hope the two Zend and HHVM will benefit from each other's advantages.

Is Facebook responsible?

Hack is a product of Facebook, mainly because of Facebook engineers. Although the public now hopes it can be published, Hack and HHVM are largely dependent on Facebook's continuous investment and participation.

Future

Thanks to the advantages of Hack and HHVM, I think to some extent, Hack is the future of PHP.

Facebook has released a new programming language, Hack, which is similar to the popular PHP language from any perspective. A large number of features, such...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.