The paper is divided into three parts 2401 word , Estimated length of study 7 minute

Picture source :Google

In the past year ,Vimeo Developers write back-end code in a variety of programming languages ——PHP,Go,Ruby,Python,NodeJS,Java,C language ,C++ and Rust.

2004 year ,Vimeo Start using PHP. For example Vimeo For startups like this ,PHP It is undoubtedly an ideal programming language .PHP The interpreter enables entrepreneurs to develop prototypes quickly , It comes with a large standard library , Some common task steps can be omitted , E-mail , Access database, etc .

Most start-ups are in the middle of nowhere , But some are based on PHP Ten years later, the start-up companies in China are still standing , Some even grow rapidly , Jump to the forefront . Some of them are companies ( The most famous is Facebook) think PHP It is the bottleneck that hinders the development of the company , Start from PHP Move out . There are two main reasons for this small-scale migration : everything PHP Poor performance of , The second is to maintain large-scale enterprises PHP Code base is difficult .

2014 From ,PHP The performance development of the system is not keeping up with the demand , The consumption of array memory exceeds the necessary limit . Due to the lack of static analysis tools that can detect errors on a large scale , Maintenance of large PHP The code base becomes more and more difficult .

since 2004 In the ten years since ,Vimeo The scale of the project has expanded many times ,PHP The code base also expanded , But it is not big enough to hinder its own development . But when Facebook Public abandonment PHP Time , Some developers think that PHP It will become a new era of Internet FORTRAN. How does a new wave of back-end engineers plan to bring 50 Wanhang PHP It's better to break it down into a series of designs , Faster , More testable Go service .

For a while , The matter seems imminent , But actually we never give up PHP. The reason is obvious —— Rewriting the entire code base is resource intensive and error prone ; But there is a less obvious reason , That's it PHP It's getting better .

 

In the last six years ,PHP Execution time has been reduced by more than half , The community is growing rapidly , Now there is a popular driver that can be improved by using the solution obtained from static analysis PHP Code base ( Old and new ).

PHP It took some time to improve Vimeo application . first , We have to get rid of the old version PHP5.4, The version is still in production years after it expired . Move to PHP
7 It can make the back-end response faster , in addition to ,PHP 7 The improved syntax makes it easier for developers to write code , It also provides comprehensive language level support for return and parameter types .

PHP Innovation all the time —— Not long ago 8 The version has made many improvements in the language level , So that developers can express business logic more concisely . We look forward to the upgrade early next year .

PHP It's very easy to get started , however “ It's easy to get started ” There is no guarantee that there will be no backfire . these years , Countless developers have tried crash PHP, I picked up the stone and hit my foot , Then he gave up . I've been caught occasionally PHP The agony of torture , But I didn't give up , Instead, they decided to build a tool that would improve accuracy . That's it. ,Psalm(PHP Static analysis type checker based on ) It was born .

Psalm The core functions and functions of TypeScript The inspectors are roughly similar , Reference Facebook
Hack language ( From PHP Of ) Some of my thoughts . When PHP When code causes type error and language logic failure in production ,PHP A notification will be sent .Psalm Some additional features have been added , Such as unused class and method detection , At the same time, it can automatically repair many detected problems .

In the past few years , We will Psalm be used as CI A part of a pipe , It's good for us in the world Vimeo to write PHP It has a transformative effect :Psalm Give us the confidence to make big changes , Don't worry about destroying everything . These changes ( Modern PHP Coding standards are introduced into our code base ) Helps eliminate traces of old code : When code can be changed safely , It's no longer really legacy code .

I create Psalm To solve my own problems , But now Psalm Open source , It also helps solve many other people's problems .Psalm Recently, it has also helped us to identify a large number of security vulnerabilities in the code base , So as not to be used maliciously .

By the way , If you're afraid of a big legacy PHP Major changes to the project , Then I strongly recommend using the static analysis type checking tool .Psalm( And other similar tools ) It can solve the existing problems in the code base , Help you slowly improve the quality of the code .

stay 20 Mid Century , It's not perfect yet PHP ORMs, So we built our own PHP
ORM.PHP Provides a large number of building blocks , Used to create a simple ActiveRecord Stylistic ORM, include MySQL support , Query parameter binding and magic get and set , And this also helps us gather a group of excellent engineers to complete this task .

ours ORM The last major upgrade was a decade ago . Some minor improvements have been made ——Bug repair , Type upgrade and some new features —— But the basic structure has not changed . these years , We've also tried to use different types of ORM, But none of these attempts are intended to respond to new business needs , It's about being right ActiveRecord Dissatisfaction with the model .

Picture source :unsplash

final , None of these proposals has been implemented . It turns out , If the old code can have the following advantages , So they're better than the new code :

· Work efficiently

· The static analysis is concise

· The test runs well

· It's a common code

thank goodness , What we have ORM Meet the above four requirements .

Retaining reliable old code also gives us the opportunity to focus on things that are of real benefit to the business . And I say it responsibly ,Vimeo It has been developing recently , There are lots of images Vimeo
Record This is a great new product .

Ten years ago , Many developers have written part of the PHP And then they moved on to other, more popular languages . They are often eager to tell others not to write any more PHP. I want to tell you ,PHP It can be successful .Vimeo stay PHP The continued success on the Internet proves that it is 2020 A sharp weapon for the rapid development of the company in .

PHP The rise of at least one opponent has changed his mind . A colleague of mine , I've been criticizing before PHP, One day he pulled me aside , Thank you very sincerely for telling him “ use PHP The work doesn't have to be bad ”.

 

Technology
©2020 ioDraw All rights reserved
Gude Haowen serial - You deserve to be an engineer ( We should work around ourselves )vue elementUI use v-for Create three level navigation bar Unity Scene loading asynchronously ( Implementation of loading interface ) One and a half years JAVA Summary of work experience dropout I have a math problem 《 Deep learning 》“ Flower Book ” Can't read on ? Here's a trick Python Basic steps of crawling web data Valentine's Day , rose , The one in your heart ~SSM— User module ( two ) Forget the password , Change Password , Get user information Vue + ElementUI Used in the project vue-pdf Realize simple Preview