版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 毕业设计说明书英文文献及中文翻译 班 级: 学号: 软件学院姓 名: 软件工程学 院: 专 业: 指导教师: 2014 年 6 月an introduction to javathe first release of java in 1996 generated an incredible amount of excitement, not just in the computer press, but in mainstream media such as the new york times, the washington post, and business week. java ha
2、s the distinction of being the first and only programming language that had a ten-minute story on national public radio. a $100,000,000 venture capital fund was set up solely for products produced by use of a specific computer language. it is rather amusing to revisit those heady times, and we give
3、you a brief history of java in this chapter. in the first edition of this book, we had this to write about java: “as a computer language, javas hype is overdone: java is certainly a good program-ming language. there is no doubt that it is one of the better languages available to serious programmers.
4、 we think it could potentially have been a great programming language, but it is probably too late for that. once a language is out in the field, the ugly reality of compatibility with existing code sets in.” our editor got a lot of flack for this paragraph from someone very high up at sun micro- sy
5、stems who shall remain unnamed. but, in hindsight, our prognosis seems accurate. java has a lot of nice language featureswe examine them in detail later in this chapter. it has its share of warts, and newer additions to the language are not as elegant as the original ones because of the ugly reality
6、 of compatibility. but, as we already said in the first edition, java was never just a language. there are lots of programming languages out there, and few of them make much of a splash. java is a whole platform, with a huge library, containing lots of reusable code, and an execution environment tha
7、t provides services such as security, portability across operating sys-tems, and automatic garbage collection. as a programmer, you will want a language with a pleasant syntax and comprehensible semantics (i.e., not c+). java fits the bill, as do dozens of other fine languages. some languages give y
8、ou portability, garbage collection, and the like, but they dont have much of a library, forcing you to roll your own if you want fancy graphics or network- ing or database access. well, java has everythinga good language, a high-quality exe- cution environment, and a vast library. that combination i
9、s what makes java an irresistible proposition to so many programmers.simple we wanted to build a system that could be programmed easily without a lot of eso- teric training and which leveraged todays standard practice. so even though we found that c+ was unsuitable, we designed java as closely to c+
10、 as possible in order to make the system more comprehensible. java omits many rarely used, poorly understood, confusing features of c+ that, in our experience, bring more grief than benefit. the syntax for java is, indeed, a cleaned-up version of the syntax for c+. there is no need for header files,
11、 pointer arithmetic (or even a pointer syntax), structures, unions, operator overloading, virtual base classes, and so on. (see the c+ notes interspersed throughout the text for more on the differences between java and c+.) the designers did not, however, attempt to fix all of the clumsy features of
12、 c+. for example, the syn- tax of the switch statement is unchanged in java. if you know c+, you will find the tran- sition to the java syntax easy. if you are used to a visual programming environment (such as visual basic), you will not find java simple. there is much strange syntax (though it does
13、 not take long to get the hang of it). more important, you must do a lot more programming in java. the beauty of visual basic is that its visual design environment almost automatically pro- vides a lot of the infrastructure for an application. the equivalent functionality must be programmed manually
14、, usually with a fair bit of code, in java. there are, however, third-party development environments that provide “drag-and-drop”-style program development. another aspect of being simple is being small. one of the goals of java is to enable the construction of software that can run stand-alone in s
15、mall machines. the size of the basic interpreter and class support is about 40k bytes; adding the basic stan- dard libraries and thread support (essentially a self-contained microkernel) adds an additional 175k. this was a great achievement at the time. of course, the library has since grown to huge
16、 proportions. there is now a separate java micro edition with a smaller library, suitable for embedded devices. object oriented simply stated, object-oriented design is a technique for programming that focuses on the data (= objects) and on the interfaces to that object. to make an analogy with carp
17、entry, an “object-oriented” carpenter would be mostly concerned with the chair he was building, and secondarily with the tools used to make it; a “non-object- oriented” carpenter would think primarily of his tools. the object-oriented facilities of java are essentially those of c+.object orientation
18、 has proven its worth in the last 30 years, and it is inconceivable that a modern programming language would not use it. indeed, the object-oriented features of java are comparable to those of c+. the major difference between java and c+ lies in multiple inheritance, which java has replaced with the
19、 simpler concept of interfaces, and in the java metaclass model (which we discuss in chapter 5). note: if you have no experience with object-oriented programming languages, you will want to carefully read chapters 4 through 6. these chapters explain what object-oriented programming is and why it is
20、more useful for programming sophisticated projects than are traditional, procedure-oriented languages like c or basic. network-savvy java has an extensive library of routines for coping with tcp/ip protocols like http and ftp. java applications can open and access objects across the net via urls wit
21、h the same ease as when accessing a local file system. we have found the networking capabilities of java to be both strong and easy to use. anyone who has tried to do internet programming using another language will revel in how simple java makes onerous tasks like opening a socket connection. (we c
22、over net- working in volume ii of this book.) the remote method invocation mechanism enables communication between distributed objects (also covered in volume ii).robust java is intended for writing programs that must be reliable in a variety of ways. java puts a lot of emphasis on early checking fo
23、r possible problems, later dynamic (runtime) checking, and eliminating situations that are error-prone. the single biggest difference between java and c/c+ is that java has a pointer model that eliminates the possibility of overwriting memory and corrupting data. this feature is also very useful. th
24、e java compiler detects many problems that, in other languages, would show up only at runtime. as for the second point, anyone who has spent hours chasing memory corruption caused by a pointer bug will be very happy with this feature of java. if you are coming from a language like visual basic that
25、doesnt explicitly use pointers, you are probably wondering why this is so important. c programmers are not so lucky. they need pointers to access strings, arrays, objects, and even files. in visual basic, you do not use pointers for any of these entities, nor do you need to worry about memory alloca
26、tion for them. on the other hand, many data structures are difficult to implement in a pointerless language. java gives you the best of both worlds. you do not need point- ers for everyday constructs like strings and arrays. you have the power of pointers if you need it, for example, for linked list
27、s. and you always have complete safety, because you can never access a bad pointer, make memory allocation errors, or have to protect against memory leaking away.architecture neutral the compiler generates an architecture-neutral object file formatthe compiled code is executable on many processors,
28、given the presence of the java runtime sys- tem. the java compiler does this by generating bytecode instructions which have nothing to do with a particular computer architecture. rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on t
29、he fly. this is not a new idea. more than 30 years ago, both niklaus wirths original implemen- tation of pascal and the ucsd pascal system used the same technique. of course, interpreting bytecodes is necessarily slower than running machine instruc- tions at full speed, so it isnt clear that this is
30、 even a good idea. however, virtual machines have the option of translating the most frequently executed bytecode sequences into machine code, a process called just-in-time compilation. this strategy has proven so effective that even microsofts .net platform relies on a virtual machine. the virtual
31、machine has other advantages. it increases security because the virtual machine can check the behavior of instruction sequences. some programs even produce bytecodes on the fly, dynamically enhancing the capabilities of a running program.portable unlike c and c+, there are no “implementation-depende
32、nt” aspects of the specifi- cation. the sizes of the primitive data types are specified, as is the behavior of arith- metic on them. for example, an int in java is always a 32-bit integer. in c/c+, int can mean a 16-bit integer, a 32-bit integer, or any other size that the compiler vendor likes. the
33、 only restriction is that the int type must have at least as many bytes as a short int and cannot have more bytes than a long int. having a fixed size for number types eliminates a major porting headache. binary data is stored and transmitted in a fixed format, eliminating confusion about byte order
34、ing. strings are saved in a standard unicode format. the libraries that are a part of the system define portable interfaces. for example, there is an abstract window class and implementations of it for unix, windows, and the macintosh. as anyone who has ever tried knows, it is an effort of heroic pr
35、oportions to write a pro- gram that looks good on windows, the macintosh, and ten flavors of unix. java 1.0 made the heroic effort, delivering a simple toolkit that mapped common user interface elements to a number of platforms. unfortunately, the result was a library that, with a lot of work, could
36、 give barely acceptable results on different systems. (and there were often different bugs on the different platform graphics implementations.) but it was a start. there are many applications in which portability is more important than user interface slickness, and these applications did benefit fro
37、m early versions of java. by now, the user interface toolkit has been completely rewritten so that it no longer relies on the host user interface. the result is far more consistent and, we think, more attrac- tive than in earlier versions of java. interpreted the java interpreter can execute java by
38、tecodes directly on any machine to which the interpreter has been ported. since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory. incremental linking has advantages, but its benefit for the development process is clearly overstated
39、. early java development tools were, in fact, quite slow. today, the bytecodes are translated into machine code by the just-in-time compiler.multithreaded the benefits of multithreading are better interactive responsiveness and real-time behavior. if you have ever tried to do multithreading in anoth
40、er language, you will be pleasantly surprised at how easy it is in java. threads in java also can take advantage of multi- processor systems if the base operating system does so. on the downside, thread imple- mentations on the major platforms differ widely, and java makes no effort to be platform i
41、ndependent in this regard. only the code for calling multithreading remains the same across machines; java offloads the implementation of multithreading to the underlying operating system or a thread library. nonetheless, the ease of multithread- ing is one of the main reasons why java is such an ap
42、pealing language for server-side development.java程序设计概述1996年java第一次发布就引起了人们的极大兴趣。关注java的人士不仅限于计算机出版界,还有诸如纽约时报、华盛顿邮报、商业周刊这样的主流媒体。java是第一种也是唯一的一种在national public radio上占用了十分钟时间进行介绍的程序设计语言,并且还得到了$100000000的风险投资基金。这些基金全部用来支持用这种特别的计算机语言开发的产品,重温那些令人兴奋的日子是很有意思的。本章将简要的介绍一下java语言的发展历史。本书的第一版是这样描写java的:“作为一种计
43、算机语言,java的广告词确实有点儿夸大其词,然而,java的确是一种优秀的的程序设计语言。作为一个名副其实的程序设计人员,使用java无疑是一个好的选择,有人认为:java有望成为一种最优秀的程序设计语言,但还需要一个相当长的发展时期。一旦一种语言应用于某个领域,与现存代码的相容性问题就摆在了人们的面前。”我们的编辑手中有很多这样的广告词,这是sun公司高层的某位不愿透露姓名提供的。然而,现在看起来,当初的这些预测还是有一定的准确性的。java有许多非常优秀的程序语言特性,本章稍后会详细地讨论这些特性。由于相容性这个严峻的问题确实存在于现实中,所以,或多或少的还是有一些“累赘”被加到语言中,
44、这就导致java并不如想象的中的那么完美无瑕。但是,正像我们在第一版中已经指出的那样,java并不只是一种语言。在此之前出现的那么多种语言也没有能够引起那么大的轰动。java是一个完整的平台,有一个庞大的库,其中包含了很多可重用的代码和一个提供诸如安全性、跨操作系统的可移植性以及自动垃圾收集等服务的执行环境。作为一名程序设计人员,常常希望能够有一种语言,它具有令人赏心悦目的语法和易于理解的语义(c+不是这样的)。与许多其他的优秀语言一样,java恰恰满足了这些要求。有些语言提供了可移植性,垃圾收集器等等,但是,没有提供一个大型的库,如果想要有奇特的绘图功能,网络连接功能和数据库存取功能就必须自
45、己动手编写代码。java这种功能齐全的出色语言,具有高质量的执行环境以及庞大的库。正是因为它集多种优势于一身,所以对广大的程序设计人员有着不可抗拒的吸引力。简单性 人们希望构建一个无需深奥的专业训练就可以进行编程的系统,并且要符合当今的标准惯例。因此,尽管人们发现c+不太适用,但在设计java的时候还是尽可能地接近c+,以便系统更易于理解。java剔除了c+中许多很少使用、难以理解、易混淆的特性。在目前看来,这些特性带来的麻烦远远多于其带来的好处。的确,java语法是c+语法的一个“纯净版本。这里没有头文件、指针运算(甚至指针语法)、结构、联合、操作符重载、虚基类等等(请参阅本书各个章节给出的
46、c+注释,那里比较详细地解释了java与c+之间的区别)然而,设计者并没有试图清除c+中所有不适当的特性。例如,switch语句的语法在java中就没有改变。如果知道c+就会发现可以轻而易举地将其转换成java。 如果已经习惯于使用可视化的编程环境(例如visual basic),你就不会觉得java简单了。java有许多奇怪的语法(尽管掌握其要领并不需要很长时间),更重要的是,使用java需要自己编写大量的程序o visual basic的魅力在于它的可视化设计环境几乎自动地为应用程序提供了大量的基础结构。而使用java实现同样的功能却需要手工地编制代码,通常代码量还相当大。然而,已经有一些
47、支持“拖放”风格程序开发的第三方开发环境。 简单的另一个方面是小。java的目标之一是支持开发能够在小型机器上独立运行 的软件。基本的解释器以及类支持大约仅为40kb;再加上基础的标准类库和对线程的支持(基本上是一个白包含的微内核)大约需要增加175kb。在当时,这是一个了不起的成就。当然,由于不断的扩展,类库已经相当庞大了。现在有一个独立的具有较小类库的java微型版(java micro edition)用于嵌入式设备。面向对象 简单地讲,面向对象设计是一种程序设计技术。它将重点放在数据(即对象)和对象的接口上。用木匠打一个比方,一个“面向对象的”木匠始终关注的是所制作的 椅子,第二位才是
48、所使用的工具;一个非面向对象的”木匠首先考虑的是所用的工 具。在本质上,java的面向对象能力与c+是一样的。 在过去的30年里,面向对象已经证明了自身的价值,一种现代的程序设计语言不使用面向对象技术简直让人难以置信。的确,java的面向对象特性与c+旗鼓相当。 java与c+的主要不同点在于多继承,在java,取而代之的是简单的接口概念,以及java的元类(metaclass)模型(有关这部分内容将在第5章中讨论)。如果没有使用面向对象程序设计语言的经验,你一定要仔细阅读第4章第6章。这些章节解释了什么是面向对象程序设计以及在煽程实现复杂的项目时为什么比传统的像c或basic这样的面向过程的
49、语言更加有效。网络技能 java有一个扩展的例程库,用于处理像http和ftp这类的tcp/ip协议。java应用程序能够通过url打开和访问网络上的对象,其便捷程度就好像访问本地文件一样。 人们已经看到java的网络能力强大且易于使用。任何曾经试图使用其他语言进行网络编程的人都会惊呼java竟然把类似打开socket连接这类繁重的任务都变得如此简单(在本书的卷ii中介绍网络连接)。另外,远程方法调用机制使得分布式对象之间可以进行通信(也将在卷ii中介绍)。健壮性java的设计目标之一在于使得java编写的程序具有多方面的可靠性。java投入了大量的精力进行早期的问题检测、后期动态的(运行时)检测,并消除了有出错倾向的状态。java和c+最大的不同在于java采用的指针模型可以消除重写内存和损坏数据的可能性。这个特性非常有用。java编译器能够检测许多在其他语言中仅在运行时刻才能够检测出来的问题。至于第二点,对于曾经花费几个小时来检查由于指针bug而引起内存冲突的人来说,一定很喜欢java的这一特性。如果曾经只使用过visual basic这类没有显式指针的语言,你就会感觉这么说似乎有
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 白酒与乡村旅游产业的地理空间优势考核试卷
- 光学仪器的稳定性与重复性分析研究考核试卷
- 搪瓷制品的纹理与质感呈现考核试卷
- 广东省深圳市福田区2024-2025学年四年级上学期期中英语试卷
- 刺绣艺术在体育用品中的融合考核试卷
- 发现专业技能的无尽可能考核试卷
- 美术情绪课件教学课件
- 团队介绍课件教学课件
- 淮阴工学院《工程地质学》2022-2023学年第一学期期末试卷
- 三聚氰胺相关项目投资计划书
- 部编版《古诗三首》饮湖上初晴后雨(完美版)课件
- 《中国居民膳食指南》2023收藏版
- 【深信服】大云云计算PT2认证考试(重点)复习题库(含答案)
- 管壳式热交换器的热力计算课件
- 蛇咬伤的护理查房-课件
- 《建筑防火通用规范》学习研讨
- 雅各布森翻译理论的解读与启示-对等
- 绩溪县现代化工有限公司年产1000吨34-二氯二苯醚项目(一期工程)竣工环境保护验收报告
- TMF自智网络白皮书4.0
- 所水力除焦设备介绍
- 鼻腔冲洗护理技术考核试题及答案
评论
0/150
提交评论