版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、本科畢業(yè)設(shè)計(jì)外文文獻(xiàn)及譯文文獻(xiàn)、資料題目:Evolving Java Without Changingthe Language文獻(xiàn)、資料來源:http:。com/articles/evolving-javalang-change文獻(xiàn)、資料發(fā)表(出版)日期:院 (部):專 業(yè):班 級:姓 名:學(xué) 號:指導(dǎo)教師:翻譯日期:外文文獻(xiàn):Evolving Java Without Changing the LanguageIn ”The Feel of Java” James Gosling stated that: Java is a blue collar language. Its not PhD
2、thesis material but a language for a job. Java feels very familiar to many different programmersbecause I had a very strong tendency to prefer things that had been used a lot over things that justsounded like a good idea。The extraordinary success of Java offers weight to the notion that this was a s
3、ensible, and if it remains an important goal for Java today, then it makes sense that thelanguage should continue to evolve relatively slowly. In addition to this , the fact that Java is amature, widely used language causes its evolution to be fraught with difficulty 。 For one thing,each feature add
4、ed to the language can change the way it feels in subtle and often unpredictableways, risking alienating developers who have already adopted it as their language of choice.For another, a feature that makes perfect sense on its own may interact with other features of thelanguage in awkward or unexpec
5、ted ways. Worse, once a language feature has been added it isall but impossible to remove even if it turns out to be detrimental to the language as a whole 。To justify adding a new feature, a language designer must be highly confident that it will be oflong term benefit to the language rather than a
6、 short term or fashionable solution to a problemthat rapidly becomes redundant。 To mitigate the risk a language designer will typicallyexperiment by creating a separate language or branch, such as the Pizza language used toexperiment with Javas generics, prior to their implementation. The problem wi
7、th this approachis that the audience for such experiments is both small and self-selecting; obviously they will allbe interested in language features, and many may be academics or researchers. An idea whichplays well to such an audience may still play badly when it is incorporated into the main lang
8、uageand general programmers start to work with it.To get a sense of this, consider the closures debate that became so heated for Java 7。Implementations for the main proposals (and some others) have been available for some timebut no consensus has emerged. In consequence Sun decided that JDK 7 will n
9、ot get full closuressupport。 The core argument came down to whether Java had become as complex as it couldafford to be when generics (and in particular the wildcard syntax) were added to Java 5; and- 1 -whether the addition of full support for closures was justified when Java already has a morelimit
10、ed form through anonymous inner classes。Two important use cases for adding full closuressupport were to simplify working with the fork/join API that is being added to JDK 7 to improvemulti-core programming, and to help with resource cleanup。 Josh Blochs ARM blockproposal, which is now expected to be
11、 in JDK 7 via Project Coin, offers an alternative solution tothe latter problem. Dr。 Cliff Clicks research on a scalable, non-blocking programming stylefor Java offers an alternative approach to fork/join that may be more appropriate as the number ofprocessor cores increases。 If this were to happen,
12、 then the uses for closures in Java mayarguably be too limited to justify their inclusion.It remains important though that a programming language continues to develop at somelevel。 This article therefore examines three alternative techniques for adding new languagefeatures to Java that dont require
13、changes to the language itself - using a custom Domain SpecificLanguage, exploiting the Java 6 annotation processor to add optional language features via alibrary, and moving the syntactic sugar from the language to the IDE. Each offers the potential toallow a wide audience of mainstream developers
14、to experiment with the new features over themedium term in a non-invasive manner, and the best ideas can then filter down for inclusion inthe core 。Custom DSLsThe most widely discussed of the three is the DomainSpecific Language or DSL。 There issome disagreement on exactly what the term means, but f
15、or the purp oses of this discussion wellrefer to it simply as a language that has been created with a narrow focus to solve a particularproblem, rather than as a general purpose language designed to solve every computing problem.As such we would expect a DSL to be non Turing complete and for the mos
16、t part this is the。 There are edge cases of course. Postscript, for example, is a Turing complete languagebut also qualifies as a DSL using our definition.As the above example also illustrates , the idea of a DSL is not new. Other familiar DSLsinclude Regular Expressions, XSLT, Ant, and JSP, all of
17、which require some sort of customparser to process them。 Martin Fowler also suggests that fluent interfaces/APIs can beconsidered a second type of DSL, which he refers to as an internal DSL. His definition is that aninternal DSL is developed directly within the host language。 This was a common pract
18、ice- 2 -amongst both Lisp and Smalltalk programmers, and more recently the Ruby community has beenpopularising the technique。Whilst many well-known DSLs are commercially developed and maintained, some enterprisedevelopment teams have used the technique to create a language that allows them to rapidl
19、yexplore aspects of their problem domain. It isnt however as common as it might be, perhapsbecause DSLs have a fairly intimidating barrier to entry. The team has to design the language,build the parser and possibly other tools to support the programming team, and train each newdeveloper that joins t
20、he team on how the DSL works。 Here the emergence of tools tospecifically support DSL development could significantly change the landscape. IntentionalSoftwares Intentional Domain Workbench, which has been in development longer than Java hasbeen around, is the first significant implementation of such
21、 a tool 。 The project started life atMicrosoft Research, and Dr。 Charles Simonyis 1995 paper ”The Death of ComputerLanguages, the Birth of Intentional Programming describes his vision。 In 2002 Simonyifounded Intentional Software to continue working on his ideas and a hugely impressive videodemo of t
22、he system is available。The product itself is at 1.0 status, but access is restricted to verylimited partners.Other software houses are also exploring the concepts, amongst them JetBrains, wellrespected for their IntelliJ IDEA Java IDE, who have recently released the 1.0 version of theirMeta Programm
23、ing System (MPS)。MPS doesnt use a parser, instead working with the AbstractSyntax Tree (AST) directly。 It provides a textlike projectional editor which allows theprogrammer to manipulate the AST, and is used to write languages and programs 。 For eachnode in the tree a textual projection is created -
24、 as the programmer works with the projection, thechange is reflected in the node. This approach allows you to extend and embed languages in anycombination (often referred to as language composing) promoting language re-use。 JetBrainsare using the product internally and have recently released YouTrac
25、k, a bug tracking productdeveloped using the system.The Java 6 Annotation ProcessorWhilst DSLs are less common in more mainstream languages such as Java than they are inRuby, Smalltalk and Lisp, recent developments in the Java language, in particular theannotation processor which was added in Java 6
26、, offer new possibilities for developers looking to- 3 -use them in Java。 The JPA 2。0 criteria API that will ship as part of Java EE 6, itself a DSL,offers an example. Here the annotation processor builds up a metamodel type for each persistentclass in the application. Whilst it would be perfectly p
27、ossible for the developer to hand craft themetamodel in Java, it would be both tedious and error prone。 The use of the annotationprocessor eliminates that pain and, since the annotation processor is built into Java 6, theapproach requires no specific IDE support an IDE delegates to the annotation pr
28、ocessortriggered by the compiler, and the metadata model is generated on the fly.Using the annotation processor it is also possible for a library to add a new language feature.Bruce Chapmans prototype ”no closures proposal,for example,uses the technique to providea mechanism for casting a method to
29、a Single Abstract Method (SAM) type which compiles ontop of Java 6. During our conversation Chapman pointed out that the SAM type also supports freevariables, a key aspect of a closure:The method body can declare additional parameters beyond those required for the SingleAbstract Method using the As.
30、Additional annotation。 These parameters can have valuesbound to them at the point where you obtain an instance of the SAM type, and are then passed tothe method each time it is invoked.Chapman also set up the Rapt project to explore other uses of the technique , and has addedimplementations for two
31、language changes - Multiline Strings and XML literals that wereconsidered for JDK 7 but wont now make it into the final release。 Java could even get a form ofclosures support using this approach. When asked about this, Chapman said:We are just finishing a Swing project which we used it for. We have
32、found a couple of minorbugs around generic types, one recently discovered remains to be fixed but other than that itseems quite nice to use, and nobody has been wanting to rush back to use conventionalanonymous inner classes。Project Lombok, another project exploring the the annotation processor, pus
33、hes thetechnique still further. In effect Lombok uses annotation processing as a hook to run a Java agentthat writes various javac internals based on the annotations。Since it is manipulating internalclasses it is probably not suited to production use (internal classes can change even betweenminor re
34、leases of the JVM) but the project is an eye opening example of just what can be doneusing the annotation processor, including:- 4 - Support for properties using a pair of Getter and/or Setter annotations with varyingaccess levels, e.g. Setter(AccessLevel.PROTECTED) private String name; The EqualsAn
35、dHashCode annotation, which generates hashCode() and equals()implementations from the fields of your object The ToString annotation, which generates an implementation of the toString()method The data method, which is equivalent to combining ToString, EqualsAndHashCode, Getter on all fields, and Sett
36、er on all non final fields along with aconstructor to initialize your final fieldsOther language experimentation, such as removing checked exceptions from Java, can also bedone using this approach.Whilst the annotation processor technique opens up a welcome new route to languageexperimentation,care
37、needs to be taken that the generated code can be easily read by developers,not just by the machine. Chapman made a number of suggestions during our conversation:Generate source code not bytecode, and pay attention to formatting(indenting especially)in thegenerated code. The compiler wont care whethe
38、r it is all on one line or not, but your users will. Ieven sometimes add comments and javadoc in the source code generated by my annotationprocessors where appropriate。Hopefully if the technique becomes more prevalent IDEs will also make it easier to view thecode that is to be generated at compile t
39、ime.Syntactic Sugar in the IDEBruce Chapman also touches on our third technique moving the syntactic sugar from thelanguage to the IDE in his blog and he elaborated on his ideas during our conversation. It isalready routine for Java IDEs to create portions of boilerplate code for you such as the get
40、ters andsetters of a class, but IDE developers are beginning to push the concept further。 JetBrainsIntelliJ 9 offers a terse code block syntax for inner classes similar to a closure, which adeveloper can also type。 Acting like code folds, these can then be expanded into the fullanonymous inner class
41、es which the compiler works with - this allows developers who prefer tostick with the standard anonymous inner class syntax to do so. A similar plugin for Eclipse also- 5 -exists. The key point here is that the alternate syntax is just a view of the actual code which thecompiler and any source manag
42、ement tools continue to work with. Thus the developer should beable to switch views between either form (like expanding or collapsing a code fold), andanyone without access to the definition of the sugar just sees the normal Java code. ChapmanwritesThere are many details to work out in order to make
43、 this easily accessible,but long termI see developers relatively easily defining a two way sugaring/desugaring transformation(jackpot is a good start for how this might be done), trying them out , evolving them andsharing the good ones with colleagues and the community。The advantages of this are alm
44、ost thesame as for a language change, without the disadvantages。 The very best could becomeubiquitous and then form the basis of an actual language change if necessary toget rid of anyremaining ”noise not possible with this approach。Since syntactic sugar has to map to another(more )language feature
45、it cannot offercomplete closure support; there are some features of BGGA closures for example that cannot bemapped to anonymous inner classes, and so they couldnt be implemented through this approach.Nevertheless the idea opens up the possibility of having various new syntaxes for representinganonym
46、ous inner classes, similar to BGGA syntax or FCM syntax, and allowing developers topick the syntax they want to work with. Other language features, such as the null-safe Elvisoperator, could certainly be done this 。 To experiment further with the idea this NetBeansmodule also developed by Chapman, i
47、s what he describes as a ”barely functional” prototype forProperties using this approach.ConclusionIn language development there is always a trade off between stability and progress 。 Theadvantage that all of these techniques bring is that they dont affect the platform or the language.In consequence
48、 they are more tolerant to mistakes and are therefore more conducive to rapid andradical experimentation。With developers freely able to experiment we should begin to see morepeople separately tackling the poor signal to noise ratio of some common boilerplate such as theanonymous inner class syntax,m
49、ixing and evolving these ideas to some optimum form that addsthe most value in the most cases. It will be fascinating to see how developers use these differentapproaches to push the Java platform in new directions.- 6 -中文譯文:不改變語言的前提下推進(jìn) Java 演進(jìn)James Gosling在“The Feel of Java”中說過:Java是一種藍(lán)領(lǐng)語言,它并不是博士的論文
50、材料而是可以完成工作上的語言。很多不同的程序員都非常熟悉Java,因?yàn)槲矣幸环N趨勢去選擇普及的東西,這是一個不錯的選擇.JavaJava么它的語言演進(jìn)將變得很緩慢.Java作為一個成熟,使用廣泛的語言也將導(dǎo)致其演進(jìn)過程充滿了困難。一方面,每個特性添加到語言中都有可能造成不可預(yù)知到后果,這么做會疏遠(yuǎn)那些熟悉Java知的影響.更糟的是,一旦增加了某個語言特性,幾乎就不可能再將它移除,即使這個特性計(jì)者一般會創(chuàng)建單獨(dú)的一種語言或者分支來進(jìn)行試驗(yàn),比如Pizza語言就是在完成前用來測試Java泛型的.這種方式的問題在于試驗(yàn)的參與者是比較少的人群,并且是自愿的。他那些學(xué)者或是研究員認(rèn)為很好的特性可能變得很
51、糟。為了感受一下這種情況,請考慮Java7閉包特性的激烈爭論。很長時間以來有人在提案中給出了閉包的實(shí)現(xiàn),但最終卻還是沒有達(dá)成共識。然后,Sun公司不在JDK7中添加完整的閉包支持。爭論的焦點(diǎn)轉(zhuǎn)向?yàn)樘砑臃盒蜁粫?dǎo)致Java變得越來越復(fù)雜,在Java中的是簡化 fork/join API(添加到了 JDK7 中以改進(jìn)多核編程)的使用以及清理資源。JoshBloch的ARM block提案對第二個問題給出了另一種解決方案。Cliff Click博士在面向Java的可擴(kuò)展,非阻塞變成風(fēng)格的研究中給出了關(guān)于fork/join的另一種方案,這種方案隨著核心處理器的不斷增加看起來也很合理,如果這種成為可能
52、的話,那么Java中使用閉包的地方將會很少了,語言就不需要提供這個特性了。雖然這樣,但是對編程語言來說.不斷的平穩(wěn)發(fā)展還是非常重要的。因此下面講了3種技術(shù),向 Java 中增加新的語言特性而又不改變語言本身 ,他們是客戶化領(lǐng)域特定語言IDE.每個技術(shù)都能讓主流開發(fā)者用非侵入方式體驗(yàn)這些新特性,好的想法可以融合到語言核心- 7 -當(dāng)中??蛻艋疍SL在這3DSL的定義有很多爭議,但是為了方便我們討論,我們把它當(dāng)作一個簡單的語言而不是一個解決計(jì)算機(jī)問題的語言.那樣DSL就不是圖靈完備的了.當(dāng)然也有邊緣情況,例如,Postscript是圖靈完備的語言但是也可以作為DSL來定義。正如上面的例子,一個DS
53、LDSL和 JSP,所有這樣都需要一個定制的分析器排序,來處理他們。 Martin Fowler 也指出interfaces/API可以被認(rèn)為是一個第二種類型的內(nèi)部DSL。他認(rèn)為一個內(nèi)部DSL應(yīng)該被開Lisp和Smalltalk程序員普遍的做法,以及最近Ruby社區(qū)也一直致力推廣這一技術(shù)。雖然很多知名的DSL是為了商業(yè)上的開發(fā)和維護(hù),但是一些企業(yè)已經(jīng)使用這項(xiàng)技術(shù)來創(chuàng)造一種語言,但還是小部分人,可能是DSL門檻較高吧。這個小組必須設(shè)計(jì)語言,建立解析器和其他可能的工具來支持這個程序,以及培養(yǎng)一個新加入者如何用DSL.這是出現(xiàn)來可以支持 DSL 開發(fā)的工具,這大大的改變了局面.Intentional
54、 Software 所開發(fā)的Intentional Domain Workbench比Java還要久,它首先實(shí)現(xiàn)了該工具的功能.該項(xiàng)目開始于微軟研究院,Charles Simonyi博士在1995年所發(fā)表的論文“The Death of ComputerLanguages,theBirthofIntentionalProgramming”中描繪了其愿景。2002年,Simonyi創(chuàng)建了IntentionalSoftware以繼續(xù)實(shí)現(xiàn)他的想法,一個巨大的系統(tǒng)中獲得的令人印象深刻的視頻。該產(chǎn)品現(xiàn)在是1。0版本,但訪問權(quán)僅限于有限合伙人。其他的一些公司也開始研究這項(xiàng)技術(shù),其中包括一IntrelliJ IEDA Java IDE而出名的JetBrains,它最近發(fā)布了Meta Programming System(MPS)1.0版.MPS并沒有使用分析器,而是直接使用 Abstact Syntax Tree(AST).他提供了一個可以允許程序員來操作的 AST以及可以編寫語言和程序的文本編輯器.當(dāng)程序員使用投影時就會為樹上的每個借點(diǎn)創(chuàng)建正在內(nèi)部使用這個產(chǎn)品,最近發(fā)布了bug追蹤產(chǎn)品YouTrack就是使用該系統(tǒng)開發(fā)的。Java6注解處理器在很多主流語言像Java中,DSL遠(yuǎn)不如Ruby Smalltalk和Lisp普遍,最近
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 互聯(lián)網(wǎng)公司實(shí)習(xí)生協(xié)議
- 歐式酒店羅馬柱施工合同
- 照明工程人工費(fèi)施工合同
- 會計(jì)實(shí)習(xí)生聘用合同
- 企業(yè)社會責(zé)任績效
- 糖尿病的健康管理方案設(shè)計(jì)
- 工程項(xiàng)目合同質(zhì)量管理情況記錄
- 電子產(chǎn)品測試顧問協(xié)議
- 工程施工轉(zhuǎn)讓合同協(xié)議
- 2022年大學(xué)工程力學(xué)專業(yè)大學(xué)物理下冊期中考試試題B卷-附解析
- 2024年大學(xué)生就業(yè)創(chuàng)業(yè)知識競賽題庫及答案(共350題)
- 基于SICAS模型的區(qū)域農(nóng)產(chǎn)品品牌直播營銷策略研究
- 《算法設(shè)計(jì)與分析基礎(chǔ)》(Python語言描述) 課件 第6章分支限界法
- 病例討論英文
- 2024秋期國家開放大學(xué)??啤兑簤号c氣壓傳動》一平臺在線形考(形考任務(wù)+實(shí)驗(yàn)報(bào)告)試題及答案
- 個人健康管理平臺使用操作教程
- 【課件】植物體的結(jié)構(gòu)層次課件-2024-2025學(xué)年人教版生物七年級上冊
- 24秋國家開放大學(xué)《0-3歲嬰幼兒的保育與教育》期末大作業(yè)參考答案
- 相對濕度計(jì)算公式
- 新版《鐵道概論》考試復(fù)習(xí)試題庫(含答案)
- 2024版腫瘤患者靜脈血栓防治指南解讀 課件
評論
0/150
提交評論