天天看點

Beanshell翻譯2

 Introduction 介紹

This document is about BeanShell. BeanShell is a small, free, embeddable Java source interpreter with object

scrīpting language features, written in Java. BeanShell executes standard Java statements and expressions but

also extends Java into the scrīpting domain with common scrīpting language conventions and syntax.

BeanShell is a natural scrīpting language for Java.

這個文檔是關于BeanShell,BeanShell是一種用Java寫成的小的,自由的,可嵌入的擁有對象腳本語言特性的Java語言解釋器。

Beamshell可以支援Java聲明和表達式,同時可以使用通用的腳本語言習慣和文法将Java擴充進腳本領域。Beanshell對于Java來說,

是一種自然腳本語言。

scrīpting vs. Application Languages 腳本對比應用程式

Traditionally, the primary difference between a scrīpting language and a compiled language has been in its

type system: the way in which you define and use data elements. You might be thinking that there is a more

obvious difference here . that of "interpreted" code vs. compiled code. But the compiler in and of itself does

not fundamentally change the way you work with a language. Nor does interpreting a language necessarily

make it more useful for what we think of as "scrīpting". It is the type system of a language that makes it

possible for a compiler to analyze the structure of an application for correctness. Without types, compilation is

reduced to just a grammar check and an optimization for speed. From the developer's perspective, it is also the

type system that characterizes the way in which we interact with the code.

傳統上說,在一個腳本語言和可編譯語言之間的最初不同是在系統類型上:你定義和使用資料的方法。你可以想到解釋代碼和

編譯代碼之間的明顯差別。但是編譯器本身并不會從根本上改變你使用語言的方式。解釋語言也不必使我們認為的腳本更加有用。

它是語言的一種系統類型,使分析程式結構和正确性成為可能。沒有類型,編輯器的工作減少為僅僅文法檢查和速度最優化。

從開發者的角度看,它僅僅是一種我們使用特征定義的方式來編寫程式的系統類型。

Types are good. Without strongly type languages it would be very hard to write large scale systems and make

any assertions about their correctness before they are run. But working with types imposes a burden on the

developer. Types are labels and labeling things can be tedious. It can be especially tedious during certain

kinds of development or special applications where it is flexibility and not program structure that is

paramount. There are times where simplicity and ease of use is a more important criterion.

類型是很好的,沒有嚴格的類型的語言很難寫出大系統和在運作之前的關于代碼正确性的驗證。但是用類型語言工作對開發者來說

是一種負擔。類型是标簽并且所标示的對象是沉悶乏味的,在發展的軟體或者是彈性很高的應用程式中這些會顯得特别沉悶乏味。

有時候簡單使用是一個很重要的标準.

This is not just rationalization to cover some underlying laziness. Productivity affects what people do and

more importantly do *not* do in the real world, much more than you might think. There is a lot of important

software that exists in the world today only because the cost/benefit ratio in some developer's mind reached a

certain threshold.

掩蓋下面的錯誤是不合理的。産品影響了人們應該做什麼和現實世界中認為是重要的,比你想像的要多。有很多重要的軟體今天

還存在這個世界上僅僅是因為在某些開發者頭腦中費用比率要在一個合理範圍之内。

Unit testing . one of the foundations of writing good code . is a prime example. Unit tests for well written

code are, in general, vitally important as a collective but almost insignificant individually. It's a "tragedy of

the commons" that leads individual developers to repeatedly weigh the importance of writing another unit test

with working on "real code". Give developers have a tool that makes it easy to perform a test with a line or

two of code they will probably use it. If, moreover, it is also a tool that they enjoy using during their

development process . that saves the time, they will be even more inclined to use it.

單元測試。寫出好代碼的基礎之一。是一個簡單的例子。想寫出好的代碼,對于集體來說單元測試通常是極其重要的,

對于個人來說是基本上不重要的。這是一個通常的政策,可以使個人開發者重新認識到使用真實的代碼寫單元測試的重要性。

給開發者一個很容易用一兩句代碼就可以建構測試的工具,他們将有可能使用它。如果,更多的,這還是一個在釋出

過程中讓他們很喜歡使用的工具。那樣可以節省時間,他們将更加傾向于使用它。

Customizability through scrīpting also opens the door to applications that are more powerful than the sum of

their parts. When users can extend, enhance, and add to their applications they use them in new and

unexpected ways. scrīpting is powerful.

客戶通過腳本還可以打開一道應用程式的門。當使用者能夠擴充,增強并且将這些都帶入到應用程式中是,他們可以用一些

全新或者是不可預料的方法來使用他們。腳本是強大的。

Tearing Down the Barriers  銷毀屏障。

Traditionally scrīpting languages have traded in the power of types for simplicity. Most scrīpting languages

distill the type system to just one or a handful of types such as strings, numbers, or simple lists. This is

sufficient for many kinds of scrīpting.

Many scrīpting languages operate in a loose, unstructured land . a place dominated by text and

course.grained tools. As such these scrīpting languages have evolved sophisticated mechanisms for working 。

傳統的腳本語言用類型的特征交換簡單特征。許多腳本語言将類型系統提取為一種或者少數幾種類型,比如:字元串,數字,

或簡單的結合。對很多的腳本語言來說這些已經很充分。

許多腳本語言可以執行松散的,沒有結構的程式,一個受控的文本和過程。一些腳本語言已經發展出久經考驗的機制。

Introduction  介紹

with these simple types (regular expressions, pipes, etc.). As a result there has developed a casm between the

scrīpting languages and the application languages created by the collapse of the type system in.between. The

scrīpting languages have remained a separate species, isolated and speaking a different dialect from their

brothers the application languages.

對于這些簡單的類型(通常為表達式)。結果在腳本語言和被類型系統in.between建立失敗的應用程式語言之間制定了casm。

腳本語言還是一個單獨的物種,孤立和說着和它的兄弟語言應用程式語言不同的語調。

BeanShell is a new kind of scrīpting language. BeanShell begins with the standard Java language and bridges

it into the scrīpting domain in a natural way, but allowing the developer to relaxing types where appropriate. It

is possible to write BeanShell scrīpts that look exactly like Java method code. But it's also possible to write

scrīpts that look more like a traditional scrīpting language, while still maintaining the framework of the Java

syntax.

Beanshell是一個全新種類的語言.Beanshell開始于标準的Java語言并且以一個自然的方式将它帶入腳本領域,并且允許開發着

酌情放寬類型。完全像Java方法代碼一樣的書寫Beanshell腳本是可能的。但是更有可能是像傳統腳本語言一樣書寫Beanshell

腳本,同時仍然保持Java文法架構。

BeanShell emulates typed variables and parameters when they are used. This allows you to "seed" your code

with strong types where appropriate. You can "shore up" repeatedly used methods as you work on them,

migrating them closer to Java. Eventually you may find that you want to compile these methods and maintain

them in standard Java. With BeanShell this is easy. BeanShell does not impose a syntactic boundary between

your scrīpts and Java.

當需要的時候Beanshell仿效定義變量和參數。這允許你寫下适當的嚴格類型的代碼。你可以使用函數來重複調用,

将他們遷移到Java中。甚至你會發現你想去編譯這些方法并且在标準Java中調用他們,對于Beanshell來說這是很容易的。

在你的腳本和Java之間Beanshell并沒有硬性的句法邊界。

But the bridge to Java extends much deeper than simple code similarity. BeanShell is one of a new breed of

scrīpting languages made possible by Java's advanced reflection capabilities. Since BeanShell can run in the

same Java virtual machine as your application, you can freely work with real, live, Java objects . passing

them into and out of your scrīpts. Combined with BeanShell's ability to implement Java interfaces, you can

achieve seamless and simple integration of scrīpting into your Java applications. BeanShell does not impose a

type boundary between your scrīpts and Java.

但是和Java聯系的橋擴充的比簡單的代碼更深刻。Beanshell是通過Java的進階映射功能實作的新腳本語言之一。

既然Beanshell可以像你的引用程式一樣運作在Java虛拟機中,你可以自由的調用存在的Java對象,讓它們自由出

入你的腳本。結合Beanshell實作Java接口的能力,你可以将完成腳本和Java應用程式之間的無縫連接配接。在你的

腳本和Java之間Beanshell沒有硬性的類型邊界。

History 曆史

What seems like an eternity ago, back in the summer of 1993, I was working at Southwestern Bell

Technology Resources and I was infatuated with the Tcl/Tk scrīpting language. On the advice of someone at

Sun I also began playing around a bit with the Oak language written by James Gosling. Little did I know that

within just a few years Oak, which would become Java, would not only spark a revolution, but that I would be

writing one of the first books on the new Java language (Exploring Java, O'Reilly & Associates) and creating

Java's first scrīpting language, BeanShell, drawing inspiration from Tcl.

看起來就像很久以前,回到1993年的夏天,我在西南地區的貝爾技術研究所工作并且我對Tcl/Tk語言很着迷。

在Sun公司的一些人的建議上我還是研究James Gosling寫在Oak語言。我不知道過了一些年之後将轉變成Java的語言Oak不僅

發起了一場革命,但是我将要寫一本新Java語言方面的書并且建立Java的第一個腳本語言,Beanshell,我的靈感來自于Tcl.

BeanShell's first public release was not until 1997, but I had been poking at it in one form or another for some

time before that. BeanShell as a language became practical when Sun added reflection to the Java language in

version 1.1. After that, and after having seen its value in helping me create examples and snippets for the

second edition of my book, I decided to try to polish it up and release it.

Beanshell直到1997年才首次公開釋出。但是在這之前我已經了解它了。當sun公司将反射加到Java1.1的時候,Beanshell作為

一zhong語言變得很流行。在這之後,并且在看到它在我的第二版書中幫助我建立執行個體和摘錄的價值之後,我決定嘗試使它更完美

并且釋出它。

BeanShell has slowly, but steadily gained popularity since then. It has grown in fits and spurts as its

contributor's time has allowed. But recently BeanShell has achieved a sort of critical mass. BeanShell is

distributed with Emacs as part of the JDE and with Sun Microsystem's NetBeans / Forte for Java IDEs.

BeanShell is also bundled by BEA with their Weblogic application server. We've had reports of BeanShell

being used everywhere from the high energy physics laboratory CERN, to classrooms teaching programming

to nine year olds. BeanShell is being used in everything from large financial applications all the way down to

embedded systems floating in Buoys in the pacific ocean. I attribute this success to the power of the open

source development model and owe many thanks to everyone who has contributed.

從此之後,Beanshell慢慢的變得流行。當允許捐贈者捐贈的時候它增長的速度很快。但是最近Beanshell已經有了一批

使用者。Beanshell作為IDE的一部分分布在Emacs和Sun公司的NetBeans中。Beanshell也被BEA公司綁定在Weblogic應用

伺服器中。我們已經有報告表示,Beanshell被用在從高能實體實驗室CERN到給9歲孩子上課的教室中的每個地方。Beanshell

被用在從大的金融應用程式到太平洋的浮标的嵌入系統的每件事情上。我将成功歸結于開源架構的力量并且感謝每個曾經

貢獻力量的人。

Conclusion  結束

I believe that BeanShell is the simplest and most natural scrīpting language for Java because it is, foremost,

Java. BeanShell draws on a rich history of scrīpting languages for its scrīpting syntax and uses it to very

conservatively extend the Java language into this new domain. I hope that you have half as much fun using

BeanShell as I have had working on it and I welcome all comments and suggestions.

我相信Beanshell是Java中最簡單和最自然的腳本語言。因為Java.Beanshell采用成熟的腳本語言來定義文法并且将Java語言

适當的擴充進來。我希望當你使用Beanshell的時候,你可以有我工作在上面一半的開心并且我歡迎你的評論和意見。

上一篇: Beanshell翻譯4
下一篇: Beanshell翻譯5