都2019年了,PHP还是世界上最好的语言吗?
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">晓查 乾明 发自 凹非寺 </p>量子位 <span style="color: black;">报告</span> | 公众号 QbitAI<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当下,<span style="color: black;">倘若</span>你打开搜索引擎,搜索关键词“PHP过时”,能找到714万个<span style="color: black;">关联</span>结果。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYeK5koZsKQ8WwCn6O9IdYQo6X6eHkyBolRdgczEV9TlSmMnzxvxicaetQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这些结果之中,不乏有2016年、2018年的结果,说PHP<span style="color: black;">已然</span>过时了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">现已2019年,这个曾经自<span style="color: black;">叫作</span>为“世界上最好的语言”PHP,<span style="color: black;">状况</span><span style="color: black;">怎样</span>?</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一位名叫Brent的程序员小哥,写了一篇博客<span style="color: black;">文案</span>,介绍了PHP在2019年的<span style="color: black;">状况</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">他说,<span style="color: black;">此刻</span>的PHP每年都会积极<span style="color: black;">研发</span>新版本,从2004年发布PHP 5<span style="color: black;">败兴</span>性能<span style="color: black;">已然</span><span style="color: black;">提高</span>了两到三倍。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">况且</span>,有很活跃的生态系统,里面有<span style="color: black;">各样</span>各样的框架、包和平台。过去几年,PHP<span style="color: black;">亦</span>添了<span style="color: black;">非常多</span>新功能,语言<span style="color: black;">持续</span>发展等等。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">他<span style="color: black;">期盼</span>,<span style="color: black;">大众</span>都放弃偏见,重新认识下<span style="color: black;">此刻</span>的PHP。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_jpg/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYe8vddRS744bd7uBonnDndWm0CXMd1nnEIoibH1C6IUmfQdRXAEyxzA0w/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">博客<span style="color: black;">文案</span>被po到HackerNews上之后,半天就有700多热度,<span style="color: black;">导致</span>近400条讨论。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">有人<span style="color: black;">暗示</span>,自己还是不<span style="color: black;">爱好</span>PHP的代码和架构,<span style="color: black;">由于</span>代码很难看,还是围绕着静态<span style="color: black;">办法</span>构建的,<span style="color: black;">不易</span>阅读。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">亦</span>有人给点了赞,说从生态系统、性能、语言本身上来看,PHP这几年的发展的确不错。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">那样</span>,PHP<span style="color: black;">此刻</span>到底怎样呢?来<span style="color: black;">一块</span><span style="color: black;">瞧瞧</span>。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">PHP的性能:7.0版本<span style="color: black;">提高</span>两到三倍</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>,PHP<span style="color: black;">已然</span>更新到了7.3版本,2019年底将会跟新7.4版本,之后会升级到8.0版本。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">小哥<span style="color: black;">暗示</span>,PHP5.0版本在2004年发布的时候,它的性能就<span style="color: black;">已然</span>达到了平均水平。在升级到7.0版本的时候,又从头<span style="color: black;">起始</span>重写了一遍核心部分,运行WordPress 5.0时,性能<span style="color: black;">提高</span>了两到三倍。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYeuyZNBgF4vdLdKDhLsOibbptIia7Cny1bWynlia7fankg4V3vbF2LZJZ0A/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在Web应用程序中,PHP与其他语言<span style="color: black;">亦</span>有可比性,在某些<span style="color: black;">状况</span>下性能表现还更好。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">虽然与C和Rust相比,PHP还是略逊一筹,但比Rails或Django要好得多,性能<span style="color: black;">亦</span>比得上ExpressJS。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">框架和生态系统:<span style="color: black;">不仅</span>是WordPress</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在HackerNews的讨论中,<span style="color: black;">非常多</span>人都<span style="color: black;">说到</span>,<span style="color: black;">由于</span>WordPress的存在才让PHP有了些存在感。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">但小哥在博客中说,WordPress绝<span style="color: black;">不可</span><span style="color: black;">表率</span>PHP当前的生态系统。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">通常</span><span style="color: black;">来讲</span>,PHP中有两个<span style="color: black;">重点</span>的Web应用程序框架,分别是Symfony和Laravel。<span style="color: black;">此刻</span><span style="color: black;">运用</span>PHP做<span style="color: black;">研发</span>,基本上都会<span style="color: black;">选取</span>其中的一个。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这两个框架<span style="color: black;">背面</span>,都有一个庞大的包和<span style="color: black;">制品</span>生态系统,从管理面板和CRM到独立软件包,分析工具,支付集成等等。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">虽然这些框架适用于<span style="color: black;">实质</span><span style="color: black;">研发</span>,但<span style="color: black;">倘若</span>只需要进行内容管理,WordPress和CraftCMS是更好的<span style="color: black;">选取</span>,<span style="color: black;">况且</span>它们<span style="color: black;">亦</span>会进一步改进。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">另外</span>,衡量PHP生态系统当前状态的一种<span style="color: black;">办法</span>是看Packagist中的<span style="color: black;">状况</span>,这是PHP的<span style="color: black;">重点</span>软件包的存储库。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYezv2gHuwRT2WicL1xkN7eDPHrKkNibeWZOdCXY1fGuC2EkF27tvLtnuGg/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">PHP<span style="color: black;">重点</span>软件包近年来已呈指数级增长,<span style="color: black;">每日</span>下载量达到2500万次。这足以证明,PHP生态系统<span style="color: black;">已然</span>远非昔日可比。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">除了应用程序框架和CMS之外,过去几年PHP中的异步框架<span style="color: black;">亦</span><span style="color: black;">起始</span>兴起,<span style="color: black;">例如</span>Swoole、Amp和ReactPHP等等,都是用PHP或其他语言编写的框架和服务器,能够让用户运行真正的异步PHP。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>, PHP<span style="color: black;">已然</span>进入了异步世界,像WebSocket和<span style="color: black;">拥有</span><span style="color: black;">海量</span>输入输出的应用程序之类的东西,<span style="color: black;">已然</span><span style="color: black;">起始</span>与PHP世界<span style="color: black;">关联</span>了。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">语言本身</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">尽管async和await<span style="color: black;">此刻</span>还不可用,但在过去的几年里,PHP语言本身<span style="color: black;">已然</span>做了<span style="color: black;">非常多</span>改进。下面是一个不完全的PHP新特性列表:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">短闭包</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Null合并运算符</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Traits代码复用机制</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">类型化属性</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">展开运算符</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">JIT编译器</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">外边</span>函数接口</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">匿名类</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">返回类型声明</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">现代加密库</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">生成器</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">更加多</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当谈到PHP语言特性的时候,让<span style="color: black;">咱们</span><span style="color: black;">亦</span>来<span style="color: black;">瞧瞧</span>今天PHP语言是<span style="color: black;">怎样</span>发展的。PHP有一个活跃的志愿者核心团队推动语言的发展,向社区征求意见(RFC,Request for Comments)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">接下来,这些RFC在“内部”邮件列表中讨论,<span style="color: black;">亦</span><span style="color: black;">能够</span>在线浏览。在添加新的功能之前,必须进行投票。<span style="color: black;">仅有</span><span style="color: black;">最少</span>占2/3<span style="color: black;">都数</span>的RFC才被<span style="color: black;">准许</span>进入核心。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYelam2IY5unpHW8OuRq0WDcAOEEO9WaXowD667b2PNJiboCblmicYn7Aeg/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">大<span style="color: black;">大概</span>100人<span style="color: black;">准许</span>参与投票。核心团队的成员当然有权投票,<span style="color: black;">由于</span><span style="color: black;">她们</span>必须<span style="color: black;">守护</span>代码<span style="color: black;">基本</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">除此之外,还有一群人是从PHP社区中单独挑选出来的。这些人<span style="color: black;">包含</span>PHP文档的<span style="color: black;">守护</span>者,<span style="color: black;">全部</span>PHP项目的贡献者,以及PHP社区中杰出的<span style="color: black;">研发</span>人员。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">虽然大部分核心<span style="color: black;">研发</span>是在自愿的<span style="color: black;">基本</span>上完成的,<span style="color: black;">然则</span>核心PHP<span style="color: black;">研发</span>人员之一Nikita Popov<span style="color: black;">近期</span>加入了软件<span style="color: black;">机构</span>JetBrains,全职从事编程语言工作。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">另一个例子是<span style="color: black;">近期</span>决定投资Zend框架的Linux基金会。像<span style="color: black;">这般</span>的雇佣方式和收购<span style="color: black;">保证</span>了PHP<span style="color: black;">将来</span>发展的稳定性。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">静态分析工具</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">过去几年里,围绕PHP本身的工具<span style="color: black;">已然</span>有所<span style="color: black;">增多</span>,<span style="color: black;">例如</span>由Vimeo<span style="color: black;">研发</span>的静态分析工具Psalm等等。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这些工具能够对你的PHP代码进行静态分析,并报告其中<span style="color: black;">显现</span>的错误以及可能会<span style="color: black;">显现</span>的错误。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtAlgiavJroCeV1icHW6k60HYeSqLvwXovibzYDHT8icPgEBUh0icrHQVefJlK6uEmneAPcn7BqT0v2hkgw/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">尽管PHP还<span style="color: black;">无</span>被编译,不<span style="color: black;">准许</span><span style="color: black;">运用</span>自定义语法,但在某种程度上,它们<span style="color: black;">供给</span>的功能能够媲美TypeScript。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这<span style="color: black;">寓意</span>着,<span style="color: black;">此刻</span>的PHP<span style="color: black;">研发</span>者要依赖文档块。但PHP的原始创建者Rasmus Lerdorf,<span style="color: black;">已然</span><span style="color: black;">知道</span><span style="color: black;">说到</span>了要在内核中添加静态分析引擎。这一想法的<span style="color: black;">潜能</span>很大,但任务<span style="color: black;">一样</span>艰巨。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在传输方面,受到JavaScript社区的启发,PHP<span style="color: black;">研发</span>者社区<span style="color: black;">已然</span>在<span style="color: black;">奋斗</span>的拓展PHP语法。<span style="color: black;">例如</span>一个名为Pre的项目,<span style="color: black;">能够</span>把新的PHP语法转换成普通的PHP代码。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这个想法虽然<span style="color: black;">已然</span>在JavaScript世界中得到了证明,<span style="color: black;">然则</span><span style="color: black;">仅有</span>在<span style="color: black;">供给</span>了适当的集成<span style="color: black;">研发</span>环境和静态分析支持的<span style="color: black;">状况</span>下,它<span style="color: black;">才可</span>在PHP中发挥<span style="color: black;">功效</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">尽管这是一个非常有趣的想法,<span style="color: black;">然则</span>在能够<span style="color: black;">叫作</span>之为“主流”之前,它还有很长的路要走。</p>
<h2 style="color: black; text-align: left; margin-bottom: 10px;">PHP<span style="color: black;">已然</span>过时了吗?</h2>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">再次把<span style="color: black;">专题</span>回到开头提出的问题上,PHP<span style="color: black;">已然</span>过时了吗?</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">除了上面的<span style="color: black;">有些</span>动态,还有一份报告<span style="color: black;">能够</span>参考。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">去年10月,GitHub发布2018年的年度报告。在热门编程语言中,PHP排名第四。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/YicUhk5aAGtBs3a3XcLO9BPDmQ1XNczsuY2CibkMMBABzpFZNxfaF0icciaTicgWiblVoECNuOwFCxwCsKakZXibDokdg/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">虽然比不上JavaScript、Java,后来又被Python超过,但依旧比C++、C#等语言热度要高。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">— <strong style="color: blue;">完</strong> —</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">小程序|get<span style="color: black;">更加多</span>AI学习干货</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><a style="color: black;"><img src="https://mmbiz.qpic.cn/mmbiz_jpg/YicUhk5aAGtDpADEKp9rvicB48XgA8ueVdwNbXM1wibYx0ic2pYicwu3UCU5BM6fpDvbH8c4e9JV3uGvYaWAhvGiaTVQ/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></a></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">加入社群</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">量子位AI社群<span style="color: black;">起始</span>招募啦,量子位社群分:AI讨论群、AI+行业群、AI技术群;</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">欢迎对AI感兴趣的<span style="color: black;">朋友</span>,在量子位公众号(QbitAI)对话界面回复关键字“<span style="color: black;">微X</span>群”,获取入群方式。(技术群与AI+行业群需经过审核,审核较严,敬请谅解)</p><img src="https://mmbiz.qpic.cn/mmbiz_jpg/YicUhk5aAGtCQYLj62wpY5xicKlLfDCpKV2aTXlvJODSNPV9Q3zHNEu7UibkwluIwr0TN705vZawerScqBhC67HDQ/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;">量子位 </strong></span><span style="color: black;">QbitAI · 头条号签约作者</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">վᴗ ի <span style="color: black;">跟踪</span>AI技术和<span style="color: black;">制品</span>新动态</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">爱好</span>就点「在看」吧 !</p>
感谢楼主分享,祝愿外链论坛越办越好!
页:
[1]