219mze 发表于 2024-10-5 11:47:10

JavaScript、PHP、Golang、Haskell、Elixir,哪个才是最佳编程语言?


    <div style="color: black; text-align: left; margin-bottom: 10px;">
      <div style="color: black; text-align: left; margin-bottom: 10px;">
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">【CSDN 编者按】哪个语言是你心中的最佳编程语言呢?</span></p><span style="color: black;">作者 | Michele Riva </span><span style="color: black;">译者 | 弯月 责编 | 欧阳姝黎</span><span style="color: black;">出品 | CSDN(ID:CSDNnews)</span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">以下为译文:</span></strong></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SZo4gXYAkKyMA7~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=XiTjr%2FY2o5WD4p5jXofu1y7DWZo%3D" 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 style="color: black;">区别</span>的编程语言。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">我非常<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>的,在本文中,<span style="color: black;">咱们</span>来讨论一下以下五大编程语言的优点以及缺点。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">JavaScript</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Haskell</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Go</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">PHP</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Elixir</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SNITKRIBqnnhoh~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=gCwAP3K7s8dLesdB4QUpy162bpQ%3D" style="width: 50%; margin-bottom: 20px;"></p>
            <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">JavaScript</span></strong></span></h1>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">优点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">快速的原型设计:你<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>Node.js 在最短的时间内构建后端的概念证明。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">灵活性:在 ES6 元编程功能的助力下,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> JavaScript 编写<span style="color: black;">有些</span>非常通用的功能,并利用它编写客户端、服务器<span style="color: black;">乃至</span>移动应用(例如 React Native等)。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">社区:JavaScript 的社区非常棒。每次遇到问题,都<span style="color: black;">能够</span><span style="color: black;">经过</span> StackOverflow 寻找到答案。npm 仓库是一个非常了不起的软件包的<span style="color: black;">源自</span>,有了它,你只需要<span style="color: black;">运用</span> JavaScript 一种语言就能够编写<span style="color: black;">全部</span>应用程序。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">函数式编程:你可能<span style="color: black;">晓得</span>,刚<span style="color: black;">起始</span>的时候 JavaScript 是“一种类似于 Scheme 的浏览器编程语言,只<span style="color: black;">不外</span><span style="color: black;">运用</span>的是 Java 语法。”如今即使 JavaScript 不是纯粹的函数式编程语言,但它<span style="color: black;">亦</span><span style="color: black;">保存</span>了<span style="color: black;">有些</span>函数式编程的特性,例如高阶函数、匿名函数(ES6+ 中的箭头函数)等等。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">语法:最新版的 JavaScript 引入了<span style="color: black;">有些</span>语法糖,<span style="color: black;">能够</span>让你<span style="color: black;">容易</span>地编写更具可读性的代码。<span style="color: black;">例如</span>对象/数组解构、箭头函数、展开运算符等。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">异步:你<span style="color: black;">能够</span>尝试一下<span style="color: black;">怎样</span>处理异步代码,相信你会<span style="color: black;">爱好</span>的。</span></p>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">缺点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">动态类型:JavaScript 的动态类型非常糟糕。<span style="color: black;">例如</span>,我<span style="color: black;">晓得</span><span style="color: black;">为何</span> 10 + "10" === "1010",<span style="color: black;">然则</span>我不<span style="color: black;">爱好</span>这种方式。类型的强制转换很可能会在运行时出问题(而不是在编译或构建时出问题)。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">其他编译语言(例如 ReasonML 或 Haskell)<span style="color: black;">实质</span>上不需要类型注释,它们<span style="color: black;">能够</span>在编译时推断类型。<span style="color: black;">然则</span><span style="color: black;">倘若</span>遇到一个整数和一个字符串求和,它们会抛出错误(可能这个例子不太适合)。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">顺便说一下,TypeScript 和 Flow 都<span style="color: black;">能够</span><span style="color: black;">处理</span>这个问题。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">荒唐的特性:JavaScript的<span style="color: black;">有些</span>荒唐的特性<span style="color: black;">一般</span>都<span style="color: black;">是由于</span>类型的强制转换<span style="color: black;">诱发</span>的。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">例如</span>,[] + {} === ,<span style="color: black;">然则</span>{} + [] === 0</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">typeof NaN === "number",但 NaN <span style="color: black;">实质</span>的意思是:“不是数字”。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">倘若</span>你是一名JavaScript 程序员,<span style="color: black;">那样</span>就会明白我所说的这些荒唐的特性了。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">尾调用优化(Tail call optimization,TCO):虽然 EcmaScript 为递归函数指定了 TCO,但似乎<span style="color: black;">仅有</span> WebKit 支持。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">对象/数组常量是可变的:就像 Java 的 final <span style="color: black;">同样</span>,你<span style="color: black;">能够</span>在初始化后修改对象和数组,即便它们是常量。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SLyLiCO6agR9fu~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=4soX6Jz%2BnFrScu8DrorwCNnqg1s%3D" style="width: 50%; margin-bottom: 20px;"></p>
            <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Haskell</span></strong></span></h1>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">优点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">思想的转变:在接触 Haskell 之后,你将以完全<span style="color: black;">区别</span>的方式思考代码。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">性能:Haskell 是一种编译语言,<span style="color: black;">因为</span>其纯函数式的性质,编译器<span style="color: black;">能够</span>在编译时采用<span style="color: black;">非常多</span>优化。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">类型系统:Hindley-Milner 类型系统很棒。类型声明清晰且易于理解。<span style="color: black;">另外</span>,Haskell 类型系统<span style="color: black;">能够</span>在编译时推断类型并<span style="color: black;">检测</span>错误。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">语法:在习惯了 Haskell 的语法后,阅读 Haskell 代码<span style="color: black;">便是</span>一种乐趣。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">类:非常类似于 Java 的接口,但<span style="color: black;">因为</span>分层设计而更加强大。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">设计良好:Haskell <span style="color: black;">无</span><span style="color: black;">平常</span>的设计错误(例如 JavaScript 犯的错误),<span style="color: black;">况且</span>更偏向于软件的正确性,而不是“<span style="color: black;">不吝</span>一切代价<span style="color: black;">持有</span> X 功能”。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">模式匹配:无需多说,Haskell 模式匹配既有趣又强大:</span></p><span style="color: black;">sayMe :: <span style="color: black;"><span style="color: black;"><span style="color: black;">(</span></span><span style="color: black;"><span style="color: black;"><span style="color: black;">Integral a</span></span></span><span style="color: black;"><span style="color: black;">)</span> =&gt;</span></span> a -&gt; <span style="color: black;">String</span></span><span style="color: black;">sayMe <span style="color: black;"><span style="color: black;">1</span></span> = <span style="color: black;"><span style="color: black;">"One!"</span></span></span><span style="color: black;">sayMe <span style="color: black;"><span style="color: black;">2</span></span> = <span style="color: black;"><span style="color: black;">"Two!"</span></span></span><span style="color: black;">sayMe <span style="color: black;"><span style="color: black;">3</span></span> = <span style="color: black;"><span style="color: black;">"Three!"</span></span></span><span style="color: black;">sayMe <span style="color: black;"><span style="color: black;">4</span></span> = <span style="color: black;"><span style="color: black;">"Four!"</span></span></span><span style="color: black;">sayMe <span style="color: black;"><span style="color: black;">5</span></span> = <span style="color: black;"><span style="color: black;">"Five!"</span></span></span><span style="color: black;">sayMe x = <span style="color: black;"><span style="color: black;">"Not between 1 and 5"</span></span></span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">惰性求值:<span style="color: black;">仅有</span>在绝对必要时,函数才会被计算。</span></p>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">缺点</span></strong></span></h2>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;">学习难度过高:<span style="color: black;">Haskell 是一门<span style="color: black;">特别有</span>魅力的编程语言,但有时让你感觉<span style="color: black;">无</span>范畴论的博士学位就不配学这门语言。学习曲线真的很陡峭。</span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">缺乏有效的资源:学习 Haskell 真的非常非常困难。我阅读了 5 本书并参加了 3 门在线课程,但仍然<span style="color: black;">没法</span>得心应手。很难找到导师。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Monad:基本上<span style="color: black;">便是</span>自函子范畴的幺半群。听懂了?顺便说一句,问题不在于 monad,而是我压根搞不明白这是个什么玩意儿。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">术语:你之前所学的关于编程的术语都没用,在 Haskell 中,你基本<span style="color: black;">不消</span>纠结列表、整数、循环以及其他<span style="color: black;">平常</span>的编程关键字,你需要花费<span style="color: black;">许多</span>时间讨论monad、幺半群、函子、可应用性。感觉就像从头<span style="color: black;">起始</span>学习编程。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SNINCltGCH6V4r~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=5MuoLVfiL8Ue0oYTgaCwY6GEUX4%3D" style="width: 50%; margin-bottom: 20px;"></p>
            <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Go</span></strong></span></h1>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">优点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">学习难度低:我在<span style="color: black;">第1</span>次接触 Go 语言的时候,大约<span style="color: black;">运用</span>了一个小时就构建了一个Web服务器。Go 的语法与 C 有点类似,<span style="color: black;">因此呢</span><span style="color: black;">倘若</span>你有JavaScript、PHP、Java、C 的经验的话,学习 Go 会非常容易。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">出色的性能:即使不怎么关心代码的编写方式,<span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">得到</span>不错的性能。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">并发处理很简单:<span style="color: black;">运用</span> goroutines 编写并发代码非常简单。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">了不起的生态系统:Go 的生态系统庞大且<span style="color: black;">持有</span><span style="color: black;">海量</span>高质量的软件包。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">Go 模块:有了 Go 模块后,大<span style="color: black;">都数</span>时候你都不需要关心 $GOPATH。<span style="color: black;">况且</span>它们还<span style="color: black;">能够</span>更<span style="color: black;">容易</span>地管理应用程序的依赖项。</span></p>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">缺点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">无</span>泛型:Go 不支持泛型类型,<span style="color: black;">因此呢</span>很难构建可重用的函数,例如filter、sort等。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">无</span>箭头函数:虽然<span style="color: black;">运用</span> Go 编写匿名函数在技术上是可行的,<span style="color: black;">然则</span>我想念箭头函数的形式。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">无</span>三元运算符:这一点似乎不重要,<span style="color: black;">然则</span>这行代码:</span></p><span style="color: black;">myVar := <span style="color: black;">10</span> &gt; <span style="color: black;">5</span> ? <span style="color: black;"><span style="color: black;">"foo"</span></span> : <span style="color: black;"><span style="color: black;">"bar"</span></span></span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">比下面这段代码强太多了吧:</span></p><span style="color: black;"><span style="color: black;"><span style="color: black;">var</span></span> myVar <span style="color: black;">string</span></span><span style="color: black;"><span style="color: black;">if</span> <span style="color: black;"><span style="color: black;">10</span></span> &gt; <span style="color: black;"><span style="color: black;">5</span></span> {</span><span style="color: black;"> <span style="color: black;">myVar</span> = <span style="color: black;"><span style="color: black;">"foo"</span></span></span><span style="color: black;">} <span style="color: black;">else</span> {</span><span style="color: black;"> <span style="color: black;">myVar</span> = <span style="color: black;"><span style="color: black;">"bar"</span></span></span><span style="color: black;">}</span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">错误处理:尽管<span style="color: black;">运用</span> Go 编程有一段时间了,但还是觉得这种错误处理很奇怪:</span></p><span style="color: black;">val, err := someFunc(<span style="color: black;"><span style="color: black;">"foo"</span></span>)</span><span style="color: black;"><span style="color: black;"><span style="color: black;">if</span></span> err != <span style="color: black;"><span style="color: black;">nil</span></span> {</span><span style="color: black;"> handleError(err)</span><span style="color: black;">}</span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SNINFls8LQiGKZ~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=n3fi4LM7UPpTDBk%2BQ76a43MqWK0%3D" style="width: 50%; margin-bottom: 20px;"></p>
            <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">PHP</span></strong></span></h1>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">优点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">易于上手:PHP 是我的<span style="color: black;">第1</span>门编程语言,我利用它构建了<span style="color: black;">非常多</span>东西。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">易于<span style="color: black;">安排</span>:<span style="color: black;">运用</span> Node.js、Ruby、Python、Elixir 时,你必须设置一个应用程序服务器<span style="color: black;">才可</span>将网站公开到互联网。<span style="color: black;">然则</span> PHP 只需要 Apache 或 NGINX。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">丰富的生态系统:与JavaScript <span style="color: black;">同样</span>,,许多<span style="color: black;">研发</span>人员<span style="color: black;">已然</span>用这种语言构建了<span style="color: black;">海量</span>的软件库。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">快速的原型设计:与 Node.js <span style="color: black;">同样</span>,我<span style="color: black;">能够</span>在短短几个小时内构建最小化可行<span style="color: black;">制品</span>或概念验证。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">简单易用:有时我感觉 PHP 就<span style="color: black;">好似</span>是 Node.js 的先驱。你<span style="color: black;">能够</span>利用 PHP 随意编写代码,<span style="color: black;">而后</span>就<span style="color: black;">能够</span>正常工作,并不会遇到太大问题。这一点与 OCaml、Haskell、Elm 以及其他强类型语言有很大的<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>编写代码的时间。</span></p>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">缺点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">.htaccess:我不明白<span style="color: black;">为何</span>应该<span style="color: black;">运用</span>这个文件。<span style="color: black;">因为</span>浏览器的缓存,一旦写错一次,网站就彻底废了。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">模块系统:PHP 本身<span style="color: black;">无</span>合适的模块系统。你需要<span style="color: black;">经过</span> include(),将<span style="color: black;">全部</span>文件<span style="color: black;">包括</span>到另一个 PHP 文件中(相当于复制粘贴)。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">你<span style="color: black;">能够</span><span style="color: black;">运用</span> PHP 的 OOP 特性,但如此一来,你就必须采用 OOP 了。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><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></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">糟糕的设计:PHP 语言本身存在几个设计错误,例如:</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">没法</span><span style="color: black;">运用</span> try/catch 处理 trigger_error。</span></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;"><span style="color: black;">实例<span style="color: black;">办法</span>中的静态变量的范围不是实例。这<span style="color: black;">寓意</span>着一旦设置一个变量,它<span style="color: black;">便是</span>所有实例的全局变量。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">整数字节<span style="color: black;">体积</span>因操作系统而异。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">类似于 JavaScript 的荒唐特性:与 JavaScript 非常相像,PHP <span style="color: black;">亦</span>有<span style="color: black;">有些</span>非常荒唐的特性:</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">"foobar" == 0 为 true,"foobar" == true 为 true,<span style="color: black;">然则</span> 0 == true 为 false</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">以下代码会<span style="color: black;">引起</span>三元运算符出错:</span></p><span style="color: black;"><span style="color: black;"><span style="color: black;"><span style="color: black;">&lt;?php</span></span></span></span><span style="color: black;"><span style="color: black;"> $initial = </span><span style="color: black;"><span style="color: black;"><span style="color: black;">M</span></span></span><span style="color: black;">;</span></span><span style="color: black;"><span style="color: black;"> $name = (</span></span><span style="color: black;"><span style="color: black;"> ($initial == </span><span style="color: black;"><span style="color: black;"><span style="color: black;">M</span></span></span><span style="color: black;">) ? </span><span style="color: black;"><span style="color: black;"><span style="color: black;">Mitch</span></span></span></span><span style="color: black;"><span style="color: black;"> : ($initial == </span><span style="color: black;"><span style="color: black;"><span style="color: black;">K</span></span></span><span style="color: black;">) ? </span><span style="color: black;"><span style="color: black;"><span style="color: black;">Kevin</span></span></span></span><span style="color: black;"><span style="color: black;"> : ($initial == </span><span style="color: black;"><span style="color: black;"><span style="color: black;">J</span></span></span><span style="color: black;">) ? </span><span style="color: black;"><span style="color: black;"><span style="color: black;">John</span></span></span></span><span style="color: black;"><span style="color: black;"> : ($initial == </span><span style="color: black;"><span style="color: black;"><span style="color: black;">A</span></span></span><span style="color: black;">) ? </span><span style="color: black;"><span style="color: black;"><span style="color: black;">Andrew</span></span></span></span><span style="color: black;"><span style="color: black;"> : </span><span style="color: black;"><span style="color: black;"><span style="color: black;">unknown</span></span></span><span style="color: black;">);</span></span><span style="color: black;"><span style="color: black;"><span style="color: black;"><span style="color: black;">echo</span></span></span><span style="color: black;"> $name; </span><span style="color: black;"><span style="color: black;"><span style="color: black;">// Andrew</span></span></span></span><span style="color: black;"><span style="color: black;"><span style="color: black;"><span style="color: black;"><span style="color: black;">?&gt;</span></span></span></span></span>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">不支持 Unicode:PHP 委员会仍在讨论支持 Unicode。PHP 7 引入了 Unicode 转义语法。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">语法:我<span style="color: black;">发掘</span>过程式 PHP 很难阅读。面向对象式的 PHP 更<span style="color: black;">恰当</span>,<span style="color: black;">亦</span>许是<span style="color: black;">由于</span>它更有条理。你尝试过阅读 WordPress 的源代码?</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">糟糕的功能:Rasmus Lerdorf 曾经说过:“与其压根<span style="color: black;">无</span>某个功能,还不如有一个丑陋的功能……”抱歉,我不赞同。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">我的意思是,<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>在<span style="color: black;">创立</span>一门完整的编程语言时采用这种态度。</span></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;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/SLyLiDbAhsVBHs~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=FR%2BJoLyBkFTwNy%2FdJz5G%2BdCUfHY%3D" style="width: 50%; margin-bottom: 20px;"></p>
            <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">Elixir</span></strong></span></h1>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">优点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">OTP:开放电信平台(Open Telecom Platform,OTP)<span style="color: black;">持有</span>创建大规模可扩展实时分布系统所需的一切。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">性能:Elixir 的性能非常出色。尽管与 Java 相比,单个函数的速度可能会慢<span style="color: black;">有些</span>,<span style="color: black;">然则</span>,在尝试并行化和水平扩展后,Elixir 的性能<span style="color: black;">能够</span><span style="color: black;">容易</span>击败 Java。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">元编程:Elixir 元编程功能非常出色。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">语法:Elixir 的语法类似于 Ruby,无论是阅读还是编写代码都是一种乐趣。</span></p>
            <h2 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">缺点</span></strong></span></h2>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">动态类型:Elixir 是一种动态类型语言。这<span style="color: black;">寓意</span>着你不可能<span style="color: black;">持有</span> Haskell 的强类型<span style="color: black;">优良</span>。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">魔法:有时,Elixir 的元编程功能将程序的工作方式<span style="color: black;">隐匿</span>到宏后面。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">括号:括号在 Elixir 中是可选的,但大部分时间都需要。我更<span style="color: black;">爱好</span> Haskell 处理括号的方式。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">原文链接:</p>https://itnext.io/my-thoughts-about-programming-languages-43a8d23ead1f

            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">声明:本文由CSDN翻译,转载请注明<span style="color: black;">源自</span>。</span></p>
            <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/SNINFms5qTXSbB~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728309066&amp;x-signature=FjnJHCdzvMaNjzf9Th7Zmys1eIA%3D" style="width: 50%; margin-bottom: 20px;"></p>生于2001年的《程序员》曾<span style="color: black;">陪同</span>了无数<span style="color: black;">研发</span>者成长,影响了一代又一代的中国技术人。时隔20年,《新程序员》带着<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>立即订阅!
      </div>
    </div>




nykek5i 发表于 2024-11-6 13:38:52

你的见解真是独到,让我受益匪浅。

nqkk58 发表于 昨天 04:10

你说得对,我们一起加油,未来可期。
页: [1]
查看完整版本: JavaScript、PHP、Golang、Haskell、Elixir,哪个才是最佳编程语言?