文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>赞美脚本编程

赞美脚本编程

时间:2009-08-25  来源:niexining

以下链接到 In Praise of Scripting 的英文原文
http://www2.computer.org/portal/web/csdl/abs/html/mags/co/2008/07/mco2008070022.htm
该文章汉译在《中国计算机学会通讯》(2009年5月)上,  题名为 《赞美脚本编程 - 真正的编程实用主义》 但免费的中文电子版在网上找不到。
文章认为:(美国)学校把Java作为让学生接触的第一种语言, 是最大的错误。学生在学会厌恶别人给的编程限制之前, 应该先体验到编程的乐趣和自己的能力。 早期接触脚本语言的学生,会在整个大学阶段受益匪浅。
作者 Ronald P. Loui, 圣路易斯的华盛顿大学的计算机科学与工程副教授,他的研究兴趣包括Web编程,人工智能和软硬件协同设计。 他获得曼彻斯特大学的计算机科学博士学位 [email protected]


In Praise of Scripting: Real Programming Pragmatism
Ronald P. Loui , Washington University in St. Louis JULY 2008 IEEE    《comlputer》
Today, the boldness(大胆预测)  of John K. Ousterhout's 1998 Computer article, "Scripting: Higher Level Programming for the 21st Century(脚本编程,更高级的面向21世纪的编程语言)," is vindicated. 1 Every major observation and benefit appears genuine. Significantly, IEEE Software recently printed a canonical attack on scripting, "Java Makes Scripting Languages Irrelevant?" 2
This attack is interesting because the author seems unconvinced of his own title; the paper concludes with more text devoted to praising scripting languages than it expends in its declaration of Java's progress toward improved usability. Which is a better recommendation for scripting remains unclear: the durability of Ousterhout's text or this recent critic's indecisiveness.
Most shocking, the academic programming language community continues to reject the change in programming practices brought about by scripting(令人气愤的是,直到现在,编程语言学术界依然否认脚本语言给编程实践带来的巨大变化). Enamored of the object-oriented paradigm, especially in the undergraduate curriculum, never quite ready to accept LAMP (Linux-Apache-MySql-Perl/Python/Php), and firmly believing that more programming theory leads to better programming practice(固执地相信更多的编程理论才能产生更好的编程实践), the academics remain deaf to Ousterhout.
That scripting has developed in the shadow of object-oriented programming explains part of the problem. The two are not incompatible, but one philosophy has received the most attention. Scripting has been appearing language by language. Those who might advocate a scripting philosophy will more likely praise their favorite language, including Ousterhout, who spent much of his article praising Tcl. Today, many questions about scripting persist:

     Is there a scripting language appropriate for teaching CS1 (the first programming course for majors in the undergraduate computing curriculum)?

     Is there room for scripting in enterprise or real-time applications?

     Is there a way for scripting practices to scale to larger software engineering projects?

Fortunately, all these questions now have legitimate answers.
Recent History
Back to Top
The years 1996 through 1998 were perhaps the most interesting in the phylogeny of scripting(在脚本的发展史上) . During that time, Perl "held the Web together" and, along with a new Posix Awk and Gnu Gawk, shipped with every new Linux implementation, considerably improving on older shell scripting practices.
Meanwhile, Web developers furiously deployed JavaScript(与此同时,网络开发者喧嚣于布置JavaScript)—itself bearing no important relation to Java, having been renamed from "livescript" for purely corporate purposes, apparently a sign of Netscape's solidarity with Sun (and even renamed "Jscript" under Microsoft, now officially "ecmascript"). Also, a hand-off from Tcl/Tk to Python took place as the language of choice for GUI developers who would not yield to Microsoft's Visual Basic(同时,不愿屈服于微软的Visual Basic的GUI开发者从Tcl/Tk转向Python).
Php appeared about the same time, although it would take another round of development before it would start displacing server-side Perl, ColdFusion, and Asp. All these are now considered classic, even prototypical, scripting languages. scripting language to capture the imagination, Ruby, has actually been around awhile, promising object-oriented cleanliness with Perl-like productivity(引人注目的Ruby也加入进来,宣称自己既拥有面向对象语言的清晰结构,又有Perl一样的开发灵活性). In the Java world, various forms of scripting have been produced in the past three years that are compatible with their virtual machines.
Java and the Web
By the mid-1990s, the shift from Scheme to Java as the dominant CS1 language had already been completed, and the industry had ceased questioning C++'s superiority over C. But Java applets were not well supported in early browsers, so the appeal of "write once, run everywhere" quickly became derided as "write once, debug everywhere(早期的浏览器对Java Applets的支持不是很好,"一次开发,处处运行" 的说法变成了"一次开发,处处调试"的尴尬)." Webpage forms, which used the common gateway interface (CGI), proliferated, and systems programming languages like C became recognized as overkill for server-side programming.
Web developers quickly discovered the main advantage of Perl for CGI forms processing, especially in the dotcom setting: It minimized the programmer's write time. The algorithms were simple, network latency masked small delays, and developers built database performance into the database software—at which point the bottleneck became programming. Maintenance proved less troublesome than feared as well, with developers and management both happy to rewrite code for redesigned services rather than deal with legacy code. (网络开发者很快发现Perl作为CGI表格处理的主要优点:它能最大程度地减少开发者写代码的时间。尤其在垫子商务网页应用中,网络时延掩盖了程序运行产生的小时延,而数据库的性能已经内嵌的改进,这时,编程成为主要瓶颈。事实也证明,维护工作的困难程度比之前担心的要小很多:开发者和管理者更愿意为重新设计的服务编写新代码,而不愿去维护已有的老代码) 。 Scripting, it turned out, was so powerful and programmer-friendly that creating new scripts from scratch was easier than modifying old programs.
GUI surprise
As far back as 1990 most of the programming effort had already shifted to writing the GUI, and the objectoriented paradigm had much of its momentum in the inheritance of interface widget behaviors. Surprisingly, the interface that most programmers needed could be had in a browser(令人惊讶的是,大多数编程人员需要的GUI接口在浏览器里都有).
The HTML/JavaScript/CGI trio became the GUI and, if more was needed, ambitious client-side JavaScript proved more reliable than the browser's Java virtual machine(当需要更多功能时,已证明雄心勃勃的客户端JavaScript比浏览器的Java虚拟机更稳定可靠). Moreover, the server-side program simply offered a better way to distribute automation in a heterogeneous Internet than the downloadable client-side program(而且,要实现异构网络环境下的分布自动化,服务端程序的方法比可下载下来的客户段程序的方法更简单), whether the download was in binary or bytecode.
Programming Power
Back to Top
Although developers disagreed on the exact necessary and sufficient properties that characterized scripting and distinguished it from "more serious" programming, several things had become clear about scripting:

     it permitted rapid development, often regarded as merely "rapid prototyping," but subsequently recognized as a kind of agile programming(它允许更快速的开发,以前,这仅仅被认为是"快速原型方法",而后来,人们把它叫做敏捷编程);

     it provided the kind of high-level programming that had always been envisioned in the ascent from lowlevel assembly language programming to higher levels of abstraction(它是一种高级语言,符合从汇编语言到更高级语言抽象的一贯趋势)—it was concise and shielded programmers from concerning themselves with many performance and memory management details;

     it was well suited to working with data in heterogeneous, mixed-user settings where the majority of a programming task consisted of transforming user data, as opposed to the connecting of components, which Java did well, or the control of a well-designed system, which was C++'s realm(它特别适合于在异构环境和混杂的用户设置的环境下工作--这样的环境下的主要任务是 各种用户数据间的转换;而Java适合于连接不同组件;C++则适合于设计良好的系统下的控制。这样,它们各有优势,形成互补。); and

     it was easier to get things right with short source code, in which code that was not too terse or verbose determined behavior, when all types could be coerced into strings for debugging, when identifiers were short, and when programmers could turn ideas into code quickly without losing focus(程序员可以很快抓住代码中的思想,不易分散注意力).

This last point was extremely counterintuitive. Strong typing, a naming regimen, and verbosity were supposed to help programmers avoid errors(最后一点似乎违背直觉,通常认为,规范的命名,强制类型声明,冗余说明,会帮助程序员避免错误). But the programmers who had to generate too many keystrokes and consult too many pages, who had to search through many different files to be sure of semantics, who had to follow too many rules, and who had to sustain motivation and concentration over a long period, became distracted and consequently inefficient(但是,程序员必须敲太多键盘,写太多页代码,在不同文件之间查询,长时间保持积极性和注意力,最后变得心烦意乱而导致低效率). The language's promise to discipline the programmer quite simply did not reduce the tendency of humans to err. It exchanged one kind of frequent error for another.
Independent minds(独立的思想)
Scripting languages became the distinctive tools of independent-minded programmers: the hackers, yes, but also the gifted and genius programmers who tended to drive a project's design and development, according to Paul Graham. 3 Scripting became the mark of autodidacts, prodigies, and Third World programmers, the inspired class, the people who had never had to "think outside the box" because they had never been stuck inside it.
Proper and professional software engineering supposedly permits managers to level the playing field and extract considerable productivity from less talented and less motivated programmers. This makes software productivity a commodity, and programmers become disposable and exchangeable. Scripting does not promise this kind of disposability(规范和专业的软件工程学被认为可以提升企业的竞争力,能让缺乏天赋和积极性的程序员产生高的生产率。这让软件生产力变成商品,程序员像机器零件一样随时可更换). Some languages, notably Python, Php, and Ruby, can support large-scale professional software engineering practice, but they are also quite usable by the rugged individual, the eccentric, and the rebel.
A corollary to this difference between the mundane(超然) and the liberating(平凡): Scripting was not enervating but actually renewing. Programmers who viewed code generation in "real languages" as tedious and tiresome viewed scripting in contrast as rewarding self-expression or recreation. (脚本没有被削弱,反而得到复兴。程序员认为那些"真正的编程语言"呆板无聊,而脚本才是自我表现的好机会)
Semantics
The distinct characteristics of scripting languages that produce these effects are usually enumerated as semantic features, starting with low I/O specification costs, the use of implicit coercion and weak typing, automatic variable initialization with optional declaration, predominant use of associative arrays for storage and regular expressions for pattern matching, reduced syntax, and terse control structures.
(脚本语言之所以有这样的效果,是因为它们鲜明的特性 —— 一般被归类为语义特性:I/O规格说明的简洁,弱类型,变量自动初始化,关联数组,正则表达式模式匹配,简练的语法,紧凑的控制结构) 
But the main reason for the productivity gains can be found in the name scripting itself. Scripting powerfully embeds a developer in an environment. In the same way that the dolphin reigns over the open ocean, Lisp provides a powerful language for those who would customize their Emacs, JavaScript is feral among browsers, and many older scripting beasts still rule the Linux jungle(脚本把开发者嵌入到某个环境中。就像海豚统治着开阔的海洋,Lisp给那些想自己定制Emacs的人提供强大的工具;JavaScript在浏览器之间所向无敌,而许多古老的脚本猛兽依然统治着Linux丛林). 
The basic idea of scripting even includes a hint of AI: The scripting language grants high-level control to automate by capturing the intentions and routines normally provided by a user or administrator. If recording and replaying macros simulates a kind of autopilot, then scripting offers a kind of proxy for human decision-making
(脚本的基本思想中甚至包含着人工智能的暗示:脚本语言能通过捕捉用户和管理者自然的意图和例程,提供高层的自动控制。如果说录制和播放宏模拟了一种自动驾驶,那么脚本提供了一种代理来替人类自动决策). Nowhere is this clearer than in one-line embedded Php, or in sysadmin shell scripting, or in the scripting of artificial agents in computer games.

Current Claims (目前的主张)
Back to Top
While it might have been risky for Ousterhout to proclaim scripting on the rise in 1998, it would be folly to dismiss the success of scripting today. Scripting languages are excellent choices for CS1. To me, Java-based CS1 is the single greatest mistake in the history of computing curricula. Students should learn to love their own possibilities before they learn to loathe other people's restrictions(如果说奥斯特霍特1998年就宣称脚本编程正在崛起有些风险,那么今天还否定脚本编程的成功就显得很愚蠢了。脚本语言是第一门编程课程的极佳选择。在我看来,用Java作为第一门授课语言是计算机课程历史上最大 的错误。学生们在学会厌恶来自别人的限制之前,应该学会珍惜他们自己拥有的各种可能性).
There is a lot of the old fascist-versus-anarchist dispute here, but there is also empirical evidence. I reported in 1996 4 that only the scripting programmers could generate code fast enough to keep up with the demands of the artificial intelligence laboratory class. Even though students could choose any language they wanted, and many had to unlearn top-down ways of doing things, few could turn new ideas into code without scripting. In the intervening decade, little has changed(我在1996年报道过只有脚本程序员能够足够快地编写程序,跟上人工智能实验课程的需求。尽管学生可以选择自己想用的任何语言,并且许多人抛弃了自顶向下做事情的方法,如果不用脚本编程很少有学生能将新想法变成代码。在这十年间,这种现象基本没什么变化).
Students who learn to script early are empowered throughout their college years, especially in the crucial Unix and Web environments. Those who learn Java and C++ first are stifled by enterprise-sized correctness. Early programmers must learn to be creative and inventive, and they need programming tools that support exploration rather than production. Software engineering aesthetics should come after programming, not the other way around(早学会脚本编程的学生,在大学学习的整个过程中都会非常受用,特别是在至关重要的Unix和万维网环境下。而首先学习Java和C++语言的学生却被企业规模的正确性所抑制。初级程序员必须学习如何创造和发明。他们需要的编程工具应更多支持探索而不是生产。软件工程的美学应该在变成学习之后,而不是相反).
Scripting CS1 (基于脚本的初级编程课程)
What scripting language could be used for CS1? I personally prefer Gawk, JavaScript, Php, and Asp, mainly because of their gentle learning curves. I don't think Perl would be a disaster; its imperfection would create many teaching moments. But an emerging consensus in the scripting community holds that Python is the right solution for freshman programming. Ruby would also be a defensible choice(什么样的脚本编程语言适合用于第一门编程课?我个人倾向于Gawk,JavaScript, Php 和Aspects,主要是因为它们具有比较平缓的学习曲线。我不觉得Perl一无是处,它的不完美能够创造很多教学点。但是脚本编程界已经出现一个共识,认为Python适合新生编程课程。Ruby也是一个经得起推敲的选择).
Python and Ruby have the enviable properties that almost no one dislikes them, and almost everyone respects them. Both languages support a variety of programming styles and paradigms and satisfy practitioners and theoreticians equally. Both languages are carefully enough designed that developers can demonstrate "correct" programming practices and enforce high standards of code quality. That Google stands by Python provides added motivation for undergraduate majors. Google originally used Python because Scott Hassan, who wrote much of the prototype for Brin and Page, had been mentored by an early Python guru and because I was unable to convince him over many years in St. Louis to switch to Gawk or Perl (Python和Ruby都有很好的性质,受到几乎所有人的欢迎。两种语言都支持各种各样的编程方式和方法,同时满足实践者和理论家的需求。它们都经过了精心的设计,使开发者能展示'正确的'编程实践,保障代码质量的高标准。Google支持Python更有利于它被计算机专业接受。Google最初使用Python是因为斯科特(Scott Hassan)这个人,他为布林和佩奇(Sergey Brin and Larry Page,Google的创始人)写了大部分原型系统,斯科特曾得到一个早期Python权威的指导,而我在圣路易斯作了很多努力都没能说服他使用Gawk或者Perl).
But do scripting solutions scale? What about the performance gap when the algorithm faces large n? What about software engineering on big projects? There has been extensive discussion about scriptings' scalability. In the past, these debates have simply ended with the concession that developers must rewrite large systems in C or C++, once the scripting had served its prototyping duty.
Multiple languages (多种语言)
Indeed, scripting languages are not the answer for long-lasting, CPU-intensive nested loops. Matrix multiplication is simply faster in other languages(确实,对于长时间运行的,CPU使用密集的嵌套循环,脚本是不合适的答案。在其他语言中矩阵乘法当然会更快). Developers can easily identify such bottlenecks and rewrite the code in a more appropriate language. But a harder language or one with blackbox libraries of objects and methods does not always offer the best performance choice.
Often, we see that a team did not implement efficient data organization because it would have required more code—code that they would have attempted and likely successfully written in an easier programming language. We saw this in the AI class with heuristic search and computer vision, where brute force is better in C, but complex heuristics are better than brute force, and scripting is better for complex heuristics(我们在人工智能可中看到这样的现象,这些课中需要启发式搜索和计算机视觉,其中的蛮力搜索更适合在C语言中实现,但复杂的启发式算法比蛮力搜索更好,而写复杂的启发式搜索时用脚本编程就更合适).
When algorithms are exponential, it usually doesn't matter what language developers use because most practical n will incur too great a cost. Again, the solution is to write heuristics, and scripting is the top dog in that house. Processors are so much faster than disks these days that a single extra disk read can erase the CPU advantage of using a compiled language instead of an interpreted one(当算法具有指数复杂性时,开发着用什么样的语言已经无关紧要,因为大部分实际的n都是引起过高的代价。这里的解决方案还是用启发式算法,而脚本编程是为启发式算法编程的最好选择。现在处理器的速度远远快于磁盘操作的速度,以至于一个额外的磁盘读操作,都会把由于使用编译语言而不用解释性语言所得到的处理器优势给淹没的无影无踪).
Programmers also benefit from using multiple paradigms and languages. Projects can and do contain a mix of scripting, high-performance programming, and professional componentware. I weep when I think about the text processing written in C under my managerial watch because the programmer didn't know Perl(当我想到那些在我管理下的工作中,程序员不懂Perl而用C语言编写的文本处理,就不由得扼腕). Considering that there are much better scripting tools for much of what gets programmed in Java and C++, perhaps the question should be whether Java and C++ scale to enterprise projects.
Pragmatics
Back to Top
(待补充)

    References

  • [1] J.K. Ousterhout, "Scripting: Higher Level Programming for the 21st Century," Computer,Mar. 1998, pp. 23 30.
  • [2] D. Spinellis, "Java Makes Scripting Languages Irrelevant?" IEEE Software, vol. 22, no. 3, 2005, pp. 70 71.
  • [3] P. Graham, Hackers and Painters, O'Reilly, 2004.
  • [4] R.P. Loui, "Why Gawk for AI?" SIGPLAN Notices, vol. 31, no. 8, 1996, pp. 8 9.
  • [5] S. Levinson, Pragmatics, Cambridge University Press, 1983.
  • [6] L. Prechelt, "An Empirical Comparison of Seven Programming Languages," Computer, vol. 33, no. 10, 2000, pp. 23 29.
  • [7] M.L. Scott, Programming Language Pragmatics, Morgan Kaufmann, 2000.
Ronald P. Loui is an associate professor of computer science and engineering at Washington University in St. Louis. His research interests include Web programming, artificial intelligence, and hardware-software codesign. Loui received a PhD in computer science from the University of Rochester. Contact him at [email protected].

中文原译者:朱燕民 上海交大讲师 ,主要研究 计算机网络与分布式系统的算法设计,性能分析和优化设计。
本文中的中文译注参考朱老师的译文,有些地方简化和改动。
最后一部分 progmatics(语用)太有深度,我自己还没看懂,等我看懂了,再另外补充进来。
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载