TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Top Things Wrong with JavaScript

6 点作者 horrido超过 9 年前

1 comment

ggchappell超过 9 年前
This is a nice little article. But I have a different perspective on a number of these issues. My thoughts:<p>&gt; 1) There is no integer type!<p>Yup, problem. See also Lua. [I suppose in JS one could create a typed array and use the items as integer-typed variables (?). But who wants to do that?]<p>&gt; 2) JavaScript’s loose typing and aggressive coercions exhibit odd behaviour.<p>I call this a non-issue. If a give-me-this-object function has the possibility of failure, then it should return a truthy value on success and a falsy value on failure. But in all other circumstances, just avoid the implicit type conversions.<p>&gt; 3) Automatic semicolon insertion.<p>Yeah, it was tried in JS and in Go. I think it turned out to be a bad idea in both cases. Let&#x27;s not build it into any more PLs, okay?<p>&gt; 4) JavaScript is seriously abused.<p>Not a problem with JavaScript.<p>There are many idiots in the world. Try not to let them ruin your day.<p>&gt; 5) JavaScript is highly dependent on global variables.<p>I think this is a problem with common JavaScript APIs, not JavaScript <i>per se</i>. But, yes, it is a problem.<p>&gt; 6) JavaScript code can fail silently due to syntactical slip-ups.<p>Yes, that&#x27;s annoying.<p>&gt; 7) Prototype objects do not scale well to large applications.<p>Hmmm ... no explanation. I&#x27;m not sure exactly what the issue is. But then I&#x27;ve never written any large-scale JS code based on a hardcore OO design philosophy.<p>And later:<p>&gt; ... [ES6] classes are not as completely fleshed out as you would find in Smalltalk and C++, for example.<p>The &quot;completely fleshed out&quot; classes in C++ are insanely complicated, with whole books covering their details &amp; pitfalls. Let&#x27;s not go there. And the Smalltalk OO model has been largely abandoned for years -- perhaps for good reason?<p>&gt; 8) Asynchronous programming in JavaScript is very messy.<p>Sure, but I think of this as more of a <i>challenge</i>. We&#x27;re really just learning the ins &amp; outs of large-scale asynchronous code. I look forward to seeing how JS and other PLs evolve to handle these issues.<p>&gt; 9) ... Lisp is a wonderful language and by extension, so is JavaScript. But JavaScript is nothing like Lisp!<p>Is this a problem?<p>&gt; 10) The main draw of JavaScript is actually in frameworks like Node.js and AngularJS. If not for them, why would you use JavaScript???<p>Because it&#x27;s the only PL with native support in all major web browsers?
评论 #10998480 未加载