翻译 Secrets of the JavaScript Ninja 边译边学(12)

Secrets of the JavaScript Ninja 边译边学(12)第3.1节 函数的区别是什么?

3.1 What’s with the functional difference?
3.1 函数的区别是什么?

How many times have you heard someone moan “I hate JavaScript!”?
你听到过多少次有人抱怨“我讨厌JavaScript!”?

  We’re willing to bet that nine times out of ten (or perhaps even greater), this is a direct consequence of someone trying to use JavaScript as if it were another language that the lamenter is more familiar with, and frustrated by the fact that it’s not that other language.
  我敢打赌,以上的抱怨十有八九来自那些将JavaScript当作另外一种语言来使用的人,这些可怜的人将JavaScript当作他熟悉的语言,最终只能为JavaScript不是另一种语言这一事实而感到沮丧。

  This is probably most common with those coming to JavaScript from a language such as Java, a decidedly non-functional language, but one that a lot of developers learn before their exposure to JavaScript.
  这种情况普遍存在于那些由一种明确的非功能性语言比如Java转向JavaScript语言开发者身上,但很多开发人员在接触到JavaScript之前就已经了解到了这一点。

  Making matters even worse for these developers is the unfortunate naming choice of JavaScript. Without belaboring the history behind that lamentable naming decision, perhaps developers would have fewer incorrect preconceived notions about JavaScript if it had retained the name LiveScript or been given some other less confounding name.
  更糟糕的是,该语言命名为JavaScript。现在抛开对这个可悲的命名决策的讨论,如果该语言一开始命名为LiveScript或者其他不会造成这么多歧义的名字,可能开发者们对JavaScript就不会有这么多错误的预设了。

  Because JavaScript, as the old joke depicted in figure 3.1 goes, has as much to do with Java as a hamburger has to do with ham.
  因为JavaScript和Java的关系就像汉堡和火腿的关系一样,正如图片3.1中描绘的一个古老的的玩笑:

  Hamburgers and ham are both foods that are meat products, just as JavaScript and Java are both programming languages with a C-influenced syntax, but other than that, they don’t have much in common, and are fundamentally different right down to their DNA.
  汉堡和火腿都是食物而且都是肉类加工食物,正如JavaScript和Java都是C风格的编程语言,但除了这点,它们没什么共同点,而且从骨子里是完全不同的。

NOTE

Another factor that plays into some developers’ poor initial reaction to JavaScript may be that most developers are introduced to JavaScript in the browser. So rather than reacting to JavaScript, The Language, they may be recoiling from the JavaScript bindings to the DOM API. And the DOM API… well, let’s just say that it isn’t going to win any Friendliest API of the Year awards. But that’s not JavaScript’s fault.

注意

另一个造成一些开发人员对javascript最初反应不佳的因素可能是大多数开发人员都是在浏览器中初次接触JavaScript。 所以人们通常将它当作是一种DOM API,而不是JavaScript-一种编程语言。 dom api……好吧,让我们假设它不会赢得任何*“年度最友好的api”*奖项。 但那确实不是JavaScript的错。

  Before we learn about how functions are such a central and key concept in JavaScript, let’s understand why the functional nature of JavaScript is so important, especially for code written for the browser.
  在我们了解函数是如何成为JavaScript中的核心和关键概念之前,让我们先了解一下为什么JavaScript的功能性质如此重要,特别是对于为浏览器编写的代码。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值