mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
已翻译 by小眼儿
Signed-off-by: tinyeyeser <tinyeyeser@gmail.com>
This commit is contained in:
parent
da53abee67
commit
e98e2b839d
@ -1,88 +0,0 @@
|
|||||||
翻译中 by小眼儿
|
|
||||||
|
|
||||||
How Many Languages Do Developers Need To Know?
|
|
||||||
================================================================================
|
|
||||||
![](http://readwrite.com/files/styles/1400_0/public/fields/code%20example%20Flickr%20Ruiwen%20Chua.jpg)
|
|
||||||
|
|
||||||
> Big companies like Apple, Facebook and Google are developing their own programming languages, forcing developers to adapt.
|
|
||||||
|
|
||||||
At its Worldwide Developer Conference last week, Apple announced its new programming language [Swift][1]. It’s the latest in a rash of new languages developed by big tech companies, in some cases for specific use with their own platforms.
|
|
||||||
|
|
||||||
Apple has Swift for iOS developers; [Facebook has Hack][2], a language for back-end development. Google, meanwhile, has its own entries—the would-be Javascript replacement Dart and a new general programming language called Go.
|
|
||||||
|
|
||||||
This rash of new languages raises a number of issues for developers. Perhaps the most significant is one my colleague [Adriana Lee][3] raised after Apple's Swift announcement:
|
|
||||||
|
|
||||||
> (How many languages are devs supposed to learn?)
|
|
||||||
> — Adriana Lee (@adra_la) [June 2, 2014][4]
|
|
||||||
|
|
||||||
### A Computer-Language Babel ###
|
|
||||||
|
|
||||||
There are already [hundreds of programming languages][5] in existence, and more are popping into existence all the time. Many are designed for use in a relatively narrow range of applications, and large numbers never catch on beyond small groups of coders.
|
|
||||||
|
|
||||||
Similarly, big tech companies have been developing new languages for about as long as there have been big tech companies. The [seminal general-purpose language C][6] originated at AT&T Bell Labs in the early 1970s. Java, now the primary language for development of Android apps, was [born at Sun Microsystems][7] in the 1990s.
|
|
||||||
|
|
||||||
What's different these days is the extent to which companies embrace new languages to further their specific business objectives—a process that also has the effect of creating a dedicated base of developers who are effectively "locked in" to a company's particular platform. That sort of dual strategy dates back at least to Sun's introduction of Java, which the company promoted as a way to challenge Microsoft's dominance on the PC desktop. (Things didn't work out the way Sun planned, although Java eventually found a home in enterprise middleware systems before Google adopted it for Android.)
|
|
||||||
|
|
||||||
It's also clearly Apple's goal with Swift. Should it live up to the company's early hype, Swift seems likely to simplify iOS app development by filing the rough edges off Objective-C, the current lingua franca of iOS and Mac OS X developers. But it will also require those same developers to learn the ins and outs of a new language that they're unlikely to use anywhere else.
|
|
||||||
|
|
||||||
### Why Companies Roll Their Own ###
|
|
||||||
|
|
||||||
Which cuts against the ingrained "don’t reinvent the wheel” philosophy that animates most developers. So why don't more companies just adopt already existing languages to new uses?
|
|
||||||
|
|
||||||
One answer is simply that companies build their own languages because they can. Designing a new language can be complex, but it's not particularly resource-intensive. What's hard is building support for it, both in terms of providing software resources (shared code libraries, APIs, compilers, documentation and so forth) and winning the hearts and minds of developers. Companies are uniquely positioned to do both.
|
|
||||||
|
|
||||||
There's also the fact that existing languages are often difficult to shoehorn into today's complex code frameworks. Take, for instance, [Facebook's decision to create Hack][8], a superset of the [scripting language PHP][9] that's commonly used in Web development.
|
|
||||||
|
|
||||||
Facebook's main goal with Hack—a common one these days—was to improve code reliability, in this case by enforcing data-type checking before a program is executed. Such checks ensure that a program won't, say, try to interpret an integer as a string of characters, an error that could yield unpredictable results if not caught. In Hack, those checks take place in advance so that programmers can identify such errors long before their code goes live.
|
|
||||||
|
|
||||||
According to Julien Verlaguet, a core developer on Facebook’s Hack team, the company first looked for an an existing language that might allow for more efficient programming. But much of Facebook was already built on PHP, and the company has built up a substantial software infrastructure to support PHP and its offshoots. While it's possible to make PHP work with code written in a different language, it's not easy—nor is it fast.
|
|
||||||
|
|
||||||
“Let’s say I try to rewrite our PHP codebase in Scala,” Verlaguet said. “It’s a well designed, beautiful language, but it’s not at all compatible with PHP. Everytime I need to call to PHP from the Scala part of the code base, I’ll lose performance speed. We would have liked to use an existing language but for us, it just wasn’t an option.”
|
|
||||||
|
|
||||||
Instead, Facebook invented Hack, which has enough in common with PHP that it can share the company's existing infrastructure. The vast majority of the Facebook codebase has been migrated from PHP to Hack, said Verlaguet, but the company has open sourced the language in hopes that independent developers will find uses for it outside of Facebook.
|
|
||||||
|
|
||||||
“You can still use PHP,” he said. “But we’re hoping you’ll want to use Hack.”
|
|
||||||
|
|
||||||
### Who Holds The Power ###
|
|
||||||
|
|
||||||
Therein lies the balance of power between companies and developers. Companies can make their languages as specific as they like. But if developers don’t want to use them, nobody is going to—outside, that is, of anyone who might harbor hopes of one day working at the company that invented the language.
|
|
||||||
|
|
||||||
It’s not unusual for companies to make it easiest to develop in one language over another. For example, you would use Objective-C to develop iOS apps, but Java to develop Android apps. This has never been a major sticking point with developers because both Objective-C and Java are general purpose object-oriented languages. They’re useful for a number of purposes.
|
|
||||||
|
|
||||||
Hack, Dart, Go, and Swift, however, so far have only proven useful for particular company-designated programming solutions, usually in tandem with that company’s programming environment of choice. Granted, it may be too soon to judge. Hack, for example, can be used in several back-end implementations; it’s just so new that Facebook doesn’t yet have any data that people want to use it that way.
|
|
||||||
|
|
||||||
It’s not that developers aren’t capable of learning multiple languages. Most already do. Think of them like the Romance languages—if you know Spanish, it’ll be easier to learn French and so on than if you didn’t already know one. Likewise, if you already know Java, it’ll be easier to learn Ruby or Perl. And if you know PHP, you basically already know Hack.
|
|
||||||
|
|
||||||
On the contrary, it’s more of a question of habit. If Java already solves your specific problems, you don’t have any incentive to learn Ruby. And if you are happy coding iOS apps in Objective-C, you’re not going to feel very tempted to pick up Swift.
|
|
||||||
|
|
||||||
To some developers, though, ecosystem-specific languages just make life harder for everybody. Freelance designer Jack Watson-Hamblin, for instance, told me that initiatives like Apple's Swift risk overburdening programmers and fragmenting the developer community:
|
|
||||||
|
|
||||||
> It's important for programmers to know multiple languages, but forcing them to keep up with new languages all the time doesn't make sense. If I'm making a simple cross-platform app, I don't want to have to know four languages to do it. I only want to use the single-purpose language if I really need to.
|
|
||||||
|
|
||||||
Watson-Hamblin argues that when companies each build their own language for their own needs, it slows down overall progress both by dividing the attention of coders and by enforcing a monolithic perspective on development within that language. "When companies are in charge of a language vs. an open-source community, it's like the difference between a corporation and a start-up," he said. Communities are more flexible and adaptive by definition.
|
|
||||||
|
|
||||||
Of course, Apple had [a lot of very good reasons to start from scratch][10] with Swift, just as Facebook did when it invented Hack. That doesn't mean it's not going to force change on developers—some of it doubtless unwelcome.
|
|
||||||
|
|
||||||
“As new languages are invented, it gets more hegemonic,” said Verlaguet. “It can be frustrating to have to keep up. But on the other hand, you’re more likely to have a new language to fit your exact problem. Imagine the reverse—a world where programmers used the same language for everything. It’d be a language that could do everything poorly but nothing well.”
|
|
||||||
|
|
||||||
Lead image by [Flickr user Ruiwen Chua][11], CC 2.0
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://readwrite.com/2014/06/17/apple-swift-facebook-hack-google-dart
|
|
||||||
|
|
||||||
译者:[Mr小眼儿](https://github.com/tinyeyeser) 校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[1]:https://developer.apple.com/swift/
|
|
||||||
[2]:http://readwrite.com/2014/03/20/facebook-new-programming-language-hack
|
|
||||||
[3]:http://readwrite.com/author/adriana-lee#awesm=~oGfPbJlSrFBamJ
|
|
||||||
[4]:https://twitter.com/adra_la/statuses/473537386266112000
|
|
||||||
[5]:http://en.wikipedia.org/wiki/List_of_programming_languages
|
|
||||||
[6]:http://en.wikipedia.org/wiki/C_(programming_language)
|
|
||||||
[7]:http://en.wikipedia.org/wiki/Java_(programming_language)
|
|
||||||
[8]:http://readwrite.com/2014/03/20/facebook-new-programming-language-hack
|
|
||||||
[9]:http://en.wikipedia.org/wiki/PHP
|
|
||||||
[10]:http://blog.erratasec.com/2014/06/why-it-had-to-be-swift.html#.U58BJI1dXtA
|
|
||||||
[11]:https://www.flickr.com/photos/ruiwen/3260095534
|
|
@ -0,0 +1,86 @@
|
|||||||
|
到底开发者需要掌握多少门语言?
|
||||||
|
================================================================================
|
||||||
|
![](http://readwrite.com/files/styles/1400_0/public/fields/code%20example%20Flickr%20Ruiwen%20Chua.jpg)
|
||||||
|
|
||||||
|
> 诸如Apple、Facebook及Google这样的大公司正在开发他们自己的编程语言,开发者们被迫只有适应。
|
||||||
|
|
||||||
|
前不久的世界开发者大会上,Apple公布了它的新开发语言[Swift][1]。这是最近大型技术公司们开发的一大波新语言中的最新成员,这些新语言某种程度上都是专门应用于他们自己的平台。
|
||||||
|
|
||||||
|
对iOS开发者,Apple有Swift;而[Facebook 有 Hack][2] —— 一门用于后端开发的语言。与此同时,Google已经拥有了它自己的Javascript替代者 Dart,以及一门新的通用编程语言Go。
|
||||||
|
|
||||||
|
这一波又一波的新语言,给开发者们带来了许多问题。也许其中最严重的问题正如我一位同事[Adriana Lee][3]在Apple发布Swift后所说:
|
||||||
|
|
||||||
|
> (开发者们到底还得学习多少门语言?)
|
||||||
|
> ——Adriana Lee (@adra_la) [June 2, 2014][4]
|
||||||
|
|
||||||
|
### 计算机语言的通天塔 ###
|
||||||
|
|
||||||
|
目前已经存在的[编程语言有数百种][5],同时还有更多的语言正在涌现。其中许多都是被设计用在相对较窄的应用程序范围内,大多数甚至从未走出过项目小组的范围。
|
||||||
|
|
||||||
|
与此类似,大技术公司开发的新语言其实也是伴随着公司一起成长的。[通用语言的鼻祖,C语言][6],就源于上世纪70年代初的AT&T贝尔实验室。Java,目前作为Android app开发的主要语言,诞生于上世纪90年代[Sun公司的Microsystems系统][7]。
|
||||||
|
|
||||||
|
发展到现在,不同之处在于,公司们拥抱新语言、从而想要延伸的特定商业目标的范围不一样了 —— 这一过程同时建立了一个忠心耿耿的开发者基础,他们被牢牢锁定在了某个公司的特定平台上。这类一石二鸟的战略,最早可以追溯到Sun对Java的采用,当时公司就将其作为了挑战微软PC桌面统治地位的一种手段。(事情虽然没有像Sun计划的那样发展下去,但在Google转向Android之前,Java大体上也算是在企业中间件系统中找到了自己的一席之地。)
|
||||||
|
|
||||||
|
这么看来,Apple的Swift其目标也就很明确了。Swift应该不会辜负公司前期的大肆宣传,通过磨平Objective-C那粗糙的毛边,看起来它能够成功简化iOS app开发者的开发过程。但是同样还是这些开发者,他们却需要学习一门新语言的输入和输出,而这些功能很可能在其他地方都不会用到。
|
||||||
|
|
||||||
|
### 大公司们为什么要重复造轮子 ###
|
||||||
|
|
||||||
|
“不要重复造轮子”这一哲学在绝大多数开发者心中根深蒂固,大公司们对此却并不买账。那他们为何不只是修改下现有语言用于新的用途呢?
|
||||||
|
|
||||||
|
答案很简单,公司们发明他们自己的语言,是因为他们有这个能力。设计一门新语言可能很复杂,但对资源要求却并不很高。困难之处也就在对其提供支持,包括提供软件资源(共享代码库、API、编译器、文档等)以及赢得开发者的心意。大公司们在这两方面尤其擅长。
|
||||||
|
|
||||||
|
还有一个事实,现有语言通常很难硬塞进如今的复杂代码框架中。举个栗子,[Facebook决定发明的Hack][8],就是一个普遍适用于Web开发的[脚本语言PHP][9]的超集合(superset)。
|
||||||
|
|
||||||
|
Facebook的Hack最近已经比较普遍,其主要目标就是改进代码的稳定性,针对这一目的,它强制在程序运行之前对数据类型进行检测。这样的检测确保了一个程序,比方说,不会将一个整数解析为一个字符串,这样的错误如果捕获不到很可能会导致不可预知的后果。在Hack中,这些检测会预先执行,以便程序员能够在程序上线前早早发现这样的错误。
|
||||||
|
|
||||||
|
据Facebook的Hack项目组核心成员Julien Verlaguet透露,公司之前尝试过用一门现有语言实现更高效的编程。但是Facebook的大部分代码都是由PHP编写的,公司实际上已经建立了一个支持PHP及其分支的软件架构。即使能够让PHP同其他语言编写的代码协同工作,实现的难易程度和运行速度都无法满足要求。
|
||||||
|
|
||||||
|
“比如说我们尝试用Scala重写PHP代码库,”Verlaguet说。“Scala是一门设计优秀的漂亮语言,但是它与PHP完全不兼容。每次我需要从Scala的代码库部分调用PHP的时候,都会损失性能。我们很愿意使用一门现有语言,但是对于我们来说,这条路行不通。”
|
||||||
|
|
||||||
|
于是,Facebook发明了Hack,它与PHP一样能够共用公司现有的架构。Verlaguet介绍说,Facebook的代码库主体已经从PHP迁移到了Hack,同时公司将Hack开源,希望独立开发者们能够帮公司找到Facebook以外的用途。
|
||||||
|
|
||||||
|
“你仍然可以使用PHP,”他说,“但是我们希望你有使用Hack的欲望。”
|
||||||
|
|
||||||
|
### 谁说了算 ###
|
||||||
|
|
||||||
|
公司和开发者之间有一种微妙的平衡。公司可以按照自己的喜好发明语言。但是如果开发者都不愿使用这门语言,那就没人用了,公司以外的人也就没人愿意将自己的职业生涯托付给这家公司。
|
||||||
|
|
||||||
|
公司在开发过程中同时使用不同的语言,这并不少见。例如,你可能用Objective-C开发iOS app,但却用Java开发Android app。对开发者来说,这从来都不是症结所在,因为Objective-C和Java都是通用面向对象语言。它们用途广泛适用于很多场合。
|
||||||
|
|
||||||
|
然而,Hack、Dart、Go和Swift,到目前为止,仍然只适用于严格特定公司的编程解决方案,往往和公司选择的编程环境相对应。诚然,现在下结论可能还太早。比方说Hack,就可以用在一些后端的实现中;它只是太新了,以至于Facebook还没有任何数据供人们如此使用。
|
||||||
|
|
||||||
|
不是开发者不能学习多门语言。事实上,大多数人已经掌握了多门语言。这好比罗曼斯语(由拉丁语演变而成的语言),如果你会说西班牙语,再去学法语就比那些不会西班牙语的人简单许多。与此类似,如果你已经会Java,再学Ruby或Perl就简单得多。如果你会PHP,基本上就已经学会了Hack。
|
||||||
|
|
||||||
|
与此相反,学习多门语言更多的是一个习惯问题。如果Java已经解决了你的问题,你就不再有动机去学Ruby。如果你用Objective-C编写iOS app感觉很爽,你就不会有强烈的意愿去学Swift。
|
||||||
|
|
||||||
|
另外,对于一些开发者来说,封闭生态系统的语言只会使每个人的生活变得更糟。例如,自由设计师Jack Watson-Hamblin就告诉我说,像Apple这样强势推出Swift,其实是在冒险增加程序员的负担,同时将开发者社区割裂开来:
|
||||||
|
|
||||||
|
> 程序员掌握多门语言固然重要,但是不断强迫他们紧跟新语言,却是行不通的。如果我正在开发一个简单的跨平台app,我可不想被迫掌握四门语言再来完成它。如果真的需要,我也只想使用一门语言。
|
||||||
|
|
||||||
|
Watson-Hamblin就主张说,当每家公司都为了自家需要发明自己的语言时,程序员的注意力被分散,开发的视野也局限于一种,这只会拖慢整个开发进程。他说,“如果拿公司负责一门语言与负责一个开源社区相比较,这两者的区别就好比一家大企业与一个初创小公司的区别”。社区生来就更加灵活,适应能力更强。
|
||||||
|
|
||||||
|
当然,Apple有[许多非常好的理由推出Swift从零开始][10],就像当初Facebook发明Hack的时候一样。我并不是说,大公司不会强迫开发者接受这种改变,在这方面,有些公司一直都很让人讨厌。
|
||||||
|
|
||||||
|
“新语言的发明,伴随着霸权的支配,”Verlaguet说,“被迫不停追赶,确实令人沮丧,但另一方面,你又多了一种解决问题的新语言。反过来想想,要是全世界的程序员都用同样一门语言做所有事情,即使啥都凑合着能干,这门语言也一定干得不怎么样”。
|
||||||
|
|
||||||
|
题图来自于[Flickr user Ruiwen Chua][11],CC 2.0
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://readwrite.com/2014/06/17/apple-swift-facebook-hack-google-dart
|
||||||
|
|
||||||
|
译者:[Mr小眼儿](http://blog.csdn.net/tinyeyeser) 校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[1]:https://developer.apple.com/swift/
|
||||||
|
[2]:http://readwrite.com/2014/03/20/facebook-new-programming-language-hack
|
||||||
|
[3]:http://readwrite.com/author/adriana-lee#awesm=~oGfPbJlSrFBamJ
|
||||||
|
[4]:https://twitter.com/adra_la/statuses/473537386266112000
|
||||||
|
[5]:http://en.wikipedia.org/wiki/List_of_programming_languages
|
||||||
|
[6]:http://en.wikipedia.org/wiki/C_(programming_language)
|
||||||
|
[7]:http://en.wikipedia.org/wiki/Java_(programming_language)
|
||||||
|
[8]:http://readwrite.com/2014/03/20/facebook-new-programming-language-hack
|
||||||
|
[9]:http://en.wikipedia.org/wiki/PHP
|
||||||
|
[10]:http://blog.erratasec.com/2014/06/why-it-had-to-be-swift.html#.U58BJI1dXtA
|
||||||
|
[11]:https://www.flickr.com/photos/ruiwen/3260095534
|
Loading…
Reference in New Issue
Block a user