Home  >  Article  >  Backend Development  >  Why does Facebook use PHP programming language? _PHP Tutorial

Why does Facebook use PHP programming language? _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 09:57:38884browse

Why does Facebook use PHP programming language?

PHP allows you to go from designing a website to writing a web application with very little investment. You don’t need to be a professional to do it.

Why does Facebook use PHP programming language? _PHP Tutorial

When Japanese computer scientist Yukihiro Matsumoto decided to create a programming language called Ruby (the technology that underpins Twitter, Hulu, and many other popular modern Web sites), he was starting in 1966 It was inspired by a science fiction movie called Babel-17. This book is mainly about a newly invented language that allows those who use it to upgrade their thinking. "Babel-17 is an extremely precise analytical language that can ensure technical advantage in almost any situation." The protagonist in the film has such a line. By inventing Ruby, Yukihiro Matsumoto hoped to achieve the same effect: reprogram and improve the way programmers think.

This goal sounds ambitious, but his idea is mainstream. As a profession, software developers generally believe that programming languages ​​have an impact on thinking, big enough to change the way you solve problems—even the problems you choose to solve. This is how they scale their companies, improve their products, hire their teams: "What programming language do you use?"

Understanding this allows outsiders to understand the workings of software companies, especially now that they have become so powerful and profitable, making products and services that have entered every corner of our lives. If you want to know why Facebook looks and works the way it does and what Facebook can do or do to us in the future, you need to know something about PHP, because this is Mark Zuckerberg The programming language used to originally build Facebook.

Among programmers, PHP may be the least "looked up" of all programming languages. It was called "bad design" in blog posts, and those who were willing to use PHP were dismissed as amateurs. “There is this legend that the top engineers who went to work at Facebook wrote PHP code on Windows XP,” said Jeff Atwood, founder of the programming question and answer website Stack Overflow. Hacker." In the nearly 10-minute conversation, Jeff described PHP in the following terms: "a emaciated monster," "a great plague," and a haunted house guest who fell in love with a ghost.

Most recognized programming languages ​​have an overall design philosophy or guiding principles that organize keywords and syntax - that is, a set of instructions given to programmers - and form a logical whole . PHP does not. Its designer, Rasmus Lerdorf, readily admitted that he had pieced it all together. "I don't know how to stop," he said in an interview in 2003. "I have no idea how to write a programming language - I just add new logic modules as I go."

A favorite example used by programmers is the PHP function "mysql_escape_string", which can remove a section of mixed characters before submitting it to the database. (An example of mixed characters can be seen in general websites that ask you to enter your email address. Hackers can embed a piece of code to obtain your password from the website.) When a vulnerability in this function was discovered, a new version appeared, called "mysql_real_escape_string", but the original version has not been replaced. The result is as if there are two similar-looking buttons placed side by side on the cockpit of an airplane: one is used to lower the landing gear, and the other is used to lower the landing gear safely. This is not a friendly practice—it's a recipe for disaster.

But despite the disdain for PHP, many of today's Web networks are designed based on PHP, with 39% of websites on the Internet using PHP. Facebook, Wikipedia, and WordPress are all PHP projects. This is because PHP, despite its many shortcomings, is fast to get started with. PHP, whose name comes from the original "personal homepage," made it easy for users to add dynamic content such as dates and usernames to static HTML pages. PHP allows you to go from designing a website to writing a web application with very little investment, and you don't need to be a professional to do it.

The "run-now" feature of PHP is crucial to the success of Wikipedia, Ori Livneh, chief software engineer of the Wikimedia Foundation, believes this. "I've always hated PHP," he told me. Wikipedia relied too much on PHP, which resulted in massive design flaws. (This is why Wikipedia didn’t launch a mobile version until 2008, and the editing interface didn’t become user-friendly until 2013.) But PHP allows people who are not—or almost are—software engineers to submit new features: this This is also why the Wikipedia entry can display hieroglyphics on the Ancient Egyptian Civilization page and can handle staffs.

But you can’t design Google with PHP, because the reason why Google becomes Google is to do one thing best - search results. Google was designed with more refined and powerful languages ​​like Java and C. Facebook, on the other hand, is more like a series of little experiments: buttons, feeds, blocks, etc. just to grab your attention. PHP is made for making new things quickly.

You can imagine Zuckerberg finishing Facebook in his Harvard dorm room. The Internet is developing so fast and users are ever-changing. The only way to seize opportunities is to be fast. It doesn't matter if it's a ball of puree, or a plate of spaghetti, or whatever. He made things that people could use. He wasn't thinking about elegant coding at the time; he was thinking about allowing friends to log into Thefacebook to see pictures of girls they met.

Now that Facebook is a company worth over $200 billion, slogans like “Done is better than perfect” and “Move fast and break things” can be seen everywhere in the office. This is the "hacker" culture of Facebook, but it is also the value of PHP. Moving fast and breaking things is actually the essence of PHP, and anyone who uses the language will think this way. You might say that it is this programming language that creates and maintains the culture of Facebook.

In late 2010, Facebook faced a crisis. PHP was not designed to be performance-optimized, but performance improvements are now required. Facebook is growing so fast that without major changes, it looks like something might go wrong.

Changing the entire programming language is not an option: Facebook has millions of lines of PHP code, thousands of PHP engineering experts, and more than 500 million users. What Facebook does is that a small team of senior engineers is assigned a specific task. One of them was designing a compiler that could convert Facebook's PHP code into C code that ran faster. Another task is done by computer language experts, who want Facebook programmers to maintain the PHP style culture, but write more reliable code.

So Hack, a fork of PHP, came into being. This language is PHP with an optional type system. That means you can write PHP code quickly the old-fashioned way, or you can choose to have the type system check your code for correctness. Facebook wants their programmers to continue moving quickly in languages ​​they know well, but doesn't want them to break things like they did before. (Zuckerberg announced a new engineer slogan last year: “Advance quickly, stabilize the architecture.”)

When startups finally solve the revenue problem and "mature", they can cleverly use the power of programming languages ​​to manipulate the culture of the enterprise organization. Guido van Rossum, a programming language designer who has worked at Google for seven years, believes that once a software company develops to a certain size, the only way to solve the chaos is to use a system that requires programmers to do more work on the front line. language. “It feels like you’re being slowed down because you’re saying everything three times.” That’s why many startups want to wait as long as possible before switching languages. You'll lose some of the awesome hackers who got you started in the first place, and you'll also lose the possibility of a small team attacking new features. But a more precise language would help others in the company understand each other's code and gain product stability, which is necessary for the company to function every day.

The ability of software startups to make this adjustment may help explain why they are so powerful. The same goes for the reach of computer misuse. These software companies also have the unique ability to reinvent themselves. As they change and evolve, they can do more than just organizational adjustments, because they are designed based on code, so they can achieve even more dramatic changes. They can reprogram themselves, their culture, and the way they think.



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/980582.htmlTechArticleWhy does Facebook use PHP programming language? PHP enables you to go from designing a website to writing a web application with very little investment. You don’t need to be a professional at all...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn