Why does Facebook use the PHP programming language?
PHP enables a leap from designing a website to writing a Web application, with a small investment. You do not need to become a professional.
When Japanese computer scientists song benhong decided to create a programming language called Ruby (which supported Twitter, Hulu, and many other modern Web popular websites, he was inspired by a sci-fi movie named Babel-17 in 1966. This book focuses on a new invention language that allows those who use it to upgrade their minds. "Babel-17 is an extremely accurate analysis language that ensures technical advantages in almost any situation ." The hero in the film has such a line. By inventing Ruby, he hopes to achieve the same effect: recompile and improve the way Programmers think.
This goal sounds great, but his idea is a mainstream one. As a type of work, software developers generally think that the language of a program has an influence on thinking and is large enough to change the way you solve the problem-or even the problems you choose to solve. This is how they expand the company, improve products, and recruit teams: "What programming language are you using ?"
Understanding this helps outsiders understand the operation of software companies, especially when they become so powerful and profitable, and the products and services they make enter every corner of our lives. If you want to know why Facebook looks and works in the current state, and Facebook can do something for us or for us in the future, you need to know something about PHP, because this is Mark? Mark Zuckerberg initially created the programming language used by Facebook.
Among programmers, PHP may be the least "visible" in all programming languages. Some people comment on it as "bad design" in blog posts, and those who are willing to use PHP are considered as amateurs. "There is such a legend that top engineers who work on Facebook write PHP code on Windows XP," said Jeff Atwood, founder of Stack Overflow on the Q & A website, "They are the type of hackers who destroy the three views." In the last 10 minutes, Jeff used the following words to describe PHP: "A thin monster", "a plague", and a guest in a ghost house fell in love with the ghost.
Most recognized programming languages have an overall design philosophy or guiding principles, it is used to organize keywords and syntaxes-that is, a set of commands handed to programmers-and form a logical whole. PHP does not. Its designer, Rasmus Lerdorf, admitted that he had been working together. "I don't know how to stop it," he said in an interview in 2003, "I don't know how to write a program language at all-I just add new logic modules while using them."
A favorite example for programmers is the PHP function "mysql_escape_string", which can remove a mix of characters and then submit it to the database. (For examples of mixed characters, refer to common websites that require you to enter an email address or the like. Hackers can embed a piece of code to obtain your password from the website .) When a vulnerability in this function is found, a new version is called "mysql_real_escape_string", but the original version is not replaced. The result is as if there are two buttons in the airplane driving warehouse that look close to each other: one is used to put the landing gear down, and the other is used to safely put the landing gear down. This is not a friendly operation-it is the cause of the disaster.
However, although PHP is everywhere, many of today's Web networks are designed based on PHP, and 39% of all websites use PHP. Facebook, Wikipedia, and WordPress are both PHP projects. This is because PHP has many defects, but it is very quick to get started. The PHP name comes from the original "Personal Homepage" and allows users to easily add dynamic content such as dates and user names to static HTML pages. PHP enables a leap from designing a website to writing a Web application, with a small investment. You do not need to become a professional.
The "instant running" feature of PHP is crucial to Wikipedia's success, as Ori Livneh, managing software engineer at the Wikipedia Foundation, believes. "I always hate PHP," he told me. Wikipedia relies too much on PHP, leading to large-scale design defects. (This is why the mobile version was not released until Wikipedia in 2008, and the editing page was not friendly until 2013 .) But PHP allows those who are not -- or almost just -- software engineers to submit new features: That's why Wikipedia entries can display hieroglyphics on the ancient Egyptian civilization page, it can also handle the cause of the Five-line spectrum.
But you cannot design Google with PHP, because Google needs to do the best thing-search results. Google is designed with more refined and powerful languages, such as Java and C ++. Facebook, on the contrary, is more like a series of small experiments: buttons, information flows, information modules, and so on, just to catch your attention. PHP was born to quickly create new things.
You can imagine Zuckerberg finished Facebook in the Harvard dormitory. As the Internet develops so fast and users change, the only way to seize the opportunity is fast. Whether it's a ball of mud, a disk of spaghetti, or even anything. He made things into something that people can use. He didn't think about the elegant code at the time. He wanted friends to log on to Thefacebook to see pictures of girls they knew.
For example, Facebook is already a company worth more than $200 billion today, and the office can see the saying "complete is more important than perfection"; "fast advancing, breaking the regular ". This is Facebook's "hacker" culture, but it is also the value of PHP. Breaking the regular expression quickly is actually the essence of PHP. Anyone who uses this language will think like this. You may say that this programming language creates and maintains the Facebook culture.
At the end of 2010, Facebook ushered in a crisis. PHP is not a performance optimization design, but it is now required to improve performance. Facebook is growing too fast. If there are no major adjustments, it may seem like a problem.
The whole-body language change is not an optional solution: Facebook has millions of lines of PHP code, thousands of PHP engineers and experts, and more than 0.5 billion users. Facebook's approach is to assign a small team of senior engineers to a special task. One of them is to design a compiler that converts Facebook's PHP code into a faster C ++ code. Another task is done by computer language experts who want Facebook programmers to maintain a PHP style culture, but to write more reliable code.
As a branch version of PHP, Hack came into being. This language is PHP with an optional type system. That is to say, you can either use an old-fashioned method to quickly write PHP code, or choose to let the type system check your code degree. Facebook hopes that their programmers will continue to push fast in their familiar language, but does not want them to break things as before. (Last year, Zuckerberg announced a new engineer's slogan: "rapid advancement and stable architecture ".)
When a startup company finally solves the revenue problem and becomes "mature", they can use the power of programming languages to manipulate the culture of the enterprise organization. Guido van Rossum, a programming language designer who once worked for Google for seven years, believes that once a software company grows to a certain volume, the only way to solve the chaos is, is to use a language that requires programmers to do more work in the first line. "It feels like you have been slowed down, because you have to say everything three times ." This is also why many startups want to wait longer and better before changing their languages. You will lose some awesome hackers who initially helped you get started, and the possibility of new features from small teams. But a more accurate language will help other people in the company understand each other's code and obtain product stability, which is also necessary for the company's daily operation.
The ability of software startups to make such adjustments may help explain why they are so powerful. The same applies to areas where computer misoperations are being expanded. These software companies also have unique capabilities to rebuild themselves. As they change and develop, they can do more than just organizational adjustment, because they are designed based on code, so they can achieve even greater changes. They can recompile themselves, their culture, and their ways of thinking.