




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.:.;我该运用何种言语这是每个游戏编程FAQ里都有的问题。这个问题每星期都会在游戏开发论坛上被问上好几次。这是个很好的问题,但是,没人能给出简单的答案。在某些运用程序中,总有一些计算机言语优于其他言语。下面是几种用于编写游戏的主要编程言语的引见及其优缺陷。希望这篇文章能协助 他做出决议。This is a question that belongs in every game programming FAQ. It seems to be asked in a game development forum several times a week. Its a good question,
2、though, and not one with an easy answer. There are computer languages that work better for some applications than others. Here is a list of the major programming languages used to write games along with descriptions, advantages, and disadvantages. Hopefully this list will help you make a decision.1、
3、C言语假设说FORTRAN和COBOL是第一代高级编译言语,那么C言语就是它们的孙子辈。C言语是Dennis Ritchie在七十年代创建的,它功能更强大且与ALGOL坚持更延续的承继性,而ALGOL那么是COBOL和FORTRAN的构造化承继者。C言语被设计成一个比它的长辈更精巧、更简单的版本,它适于编写系统级的程序,比如操作系统。在此之前,操作系统是运用汇编言语编写的,而且不可移植。C言语是第一个使得系统级代码移植成为能够的编程言语。If FORTRAN and COBOL were the first compiled high-level languages, then C is th
4、eir grandchild. It was created in the 70s by Dennis Ritchie as a tighter and more coherent successor to ALGOL, which was a structured successor to COBOL and FORTRAN. It was designed to be a smaller and simpler version of its predecessors, suitable for writing system-level programs, like operating sy
5、stems. Before then, operating systems were hand-coded in assembly and were not portable. C was the first programming language that made portability a reality for system-level code.C言语支持构造化编程,也就是说C的程序被编写成一些分别的函数呼叫调用的集合,这些呼叫是自上而下运转,而不像一个单独的集成块的代码运用GOTO语句控制流程。因此,C程序比起集成性的FORTRAN及COBOL的“空心粉式代码代码要简单得多。现实
6、上,C依然具有GOTO语句,不过它的功能被限制了,仅当构造化方案非常复杂时才建议运用。C is a language that supports structured programming. That is to say that C programs are written as collections of disconnected function calls that run top-down rather than a single monolithic block of code with program control-flow happening via GOTO state
7、ments. Hence, C programs are generally easier to follow than monolithic FORTRAN and COBOL spaghetti-code. Actually, C still has a GOTO statement, but its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated.正由于它的系统编程根源,将C和汇编言语进展结合是相当容
8、易的。函数调用接口非常简单,而且汇编言语指令还能内嵌到C代码中,所以,不需求衔接独立的汇编模块。True to its system-programming roots, it is fairly easy to interface C with assembly languages. The function-calling interface is very simple, and assembly language instructions can be embedded within C code, so linking in separate assembly-language mo
9、dules is not necessary.优点:有益于编写小而快的程序。很容易与汇编言语结合。具有很高的规范化,因此其他平台上的各版本非常类似。Advantages: Good for writing small fast programs. Easy to interface with assembly language. Very standardized, so versions on other platforms are similar.缺陷:不容易支持面向对象技术。语法有时会非常难以了解,并呵斥滥用。Disadvantages: Does not easily support
10、object-oriented techniques. Syntax can be difficult and lends itself to abuse.移植性:C言语的中心以及ANSI函数调用都具有移植性,但仅限于流程控制、内存管理和简单的文件处置。其他的东西都跟平台有关。比如说,为Windows和Mac开发可移植的程序,用户界面部分就需求用到与系统相关的函数调用。这普通意味着他必需写两次用户界面代码,不过还好有一些库可以减轻任务量。Portability: While the core of the language and the ANSI function calls are ver
11、y portable, they are limited to control-flow, memory management, and simple file-handling. Everything else is platform-specific. Making a program thats portable between Windows and the Mac, for instance, requires that the user-interface portions be using system-specific function calls. This generall
12、y means that you need to write the user-interface code twice. There are libraries, though, that make the process a bit easier.用C言语编写的游戏:非常非常多。Games Written in C: Lots and lots.资料:C言语的经典著作是,它经过多次修正,曾经扩展到最初的三倍大,但它依然是引见C的优秀书本。一本极好的教程是。Resources: The classic book about C is The C Programming Language.It
13、s gone through several iterations and has expanded to about three times its original size, but its still a good introduction to the language. An excellent tutorial is The Waite Groups C Primer Plus.2、C+C+言语是具有面向对象特性的C言语的承继者。面向对象编程,或称OOP是构造化编程的下一步。OO程序由对象组成,其中的对象是数据和函数离散集合。有许多可用的对象库存在,这使得编程简单得只需求将一些程
14、序“建筑资料堆在一同至少实际上是这样。比如说,有很多的GUI和数据库的库实现为对象的集合。C+ is the object-oriented successor to C. Object-oriented, or OO, programs are the next step beyond structured programming. OO programs are built out of objects, which are packages of data and functions collected into discrete units. There are many librar
15、ies of objects available that make writing programs as simple as pulling together a collection of program building blocks (at least in theory). For example, there are many GUI and database libraries that are implemented as collections of objects.C+总是争辩的主题,尤其是在游戏开发论坛里。有几项C+的功能,比如虚拟函数,为函数呼叫的决策制定添加了一个额
16、外层次,批判家很快指出C+程序将变得比一样功能的C程序来得大和慢。C+的拥护者那么以为,用C写出与虚拟函数等价的代码同样会添加开支。这将是一个还在进展,而且不能够很快得出结论的争论。C+ is the subject of controversy, especially in the game development community. There are features of C+, like virtual functions, that add an extra layer of decision-making to function calls, and critics are q
17、uick to point out that C+ programs can be larger and slower than C counterparts. C+ advocates point out, however, that coding the equivalent of a virtual function in C requires the same overhead. Its an on-going debate thats not likely to be decided soon.我以为,C+的额外开支只是运用更好的言语的小付出。同样的争论发生在六十年代高级程序文语如C
18、OBOL和FORTRAN开场取代汇编成为言语所选的时候。批判家正确的指出运用高级言语编写的程序天生就比手写的汇编言语来得慢,而且必然如此。而高级言语支持者以为这么点小小的性能损失是值得的,由于COBOL和FORTRAN程序更容易编写和维护。In my opinion, the overhead of C+ is simply the price you pay for a better language. This same debate went on in the 60s when high-level programming languages like COBOL and FORTRA
19、N started to displace hand-coded assembly as the language of choice. Critics correctly pointed out that programs written in high-level languages were inherently slower than hand-tuned assembly and always would be. High-level language advocates pointed out, however, that the slight performance hit wa
20、s worth it because COBOL and FORTRAN programs were much easier to write and maintain.优点:组织大型程序时比C言语好得多。很好的支持面向对象机制。通用数据构造,如链表和可增长的阵列组成的库减轻了由于处置低层细节的负担。Advantages: Much better than C for organizing large programs. Supports the object-oriented paradigm nicely. Libraries of common data structures, like
21、 linked lists and grow-able arrays, can remove much of the burden of having to deal with low-level details. 缺陷:非常大而复杂。与C言语一样存在语法滥用问题。比C慢。大多数编译器没有把整个言语正确的实现。Disadvantages: Extremely large and complicated. Like C, the syntax lends itself to abuse. Can be slower than C. Not many compilers implement the
22、 entire language correctly.移植性:比C言语好多了,但依然不是很乐观。由于它具有与C言语一样的缺陷,大多数可移植性用户界面库都运用C+对象实现。Portability: Better than C, but still not great. While it shares the same disadvantage as C, most of the portable user-interface libraries are implemented as collections of C+ objects.运用C+编写的游戏:非常非常多。大多数的商业游戏是运用C或C+
23、编写的。Games Written in C+: Lots and lots. Almost all commercial games are written in C or C+.资料:最新版的非常好。作为教程,有两个阵营,一个假定他知道C,另外一个假定他不知道。到目前为止,最好的C+教程是,假设他曾经熟知C,那么试一下。Resources: The latest edition of The C+ Programming Language is excellent. As for tutorials, there are two camps, ones that assume you kn
24、ow C, and ones you dont. By far the best ground-up C+ tutorials are Whos Afraid of C+ and Whos Afraid of More C+. If you already know C, try Teach Yourself C+.3、我该学习C+或是该从C开场Should I learn C+, or should I start with C 我不喜欢这种说法,但它是继“我该运用哪门言语之后最经常被问及的问题。很不幸,不存在规范答案。他可以自学C并运用它来写程序,从而节省一大堆的时间,不过运用这种方法有两
25、个弊端:I thought this bore mentioning, as its the second most commonly asked question next to which programming language should I use?Unfortunately, the answer isnt black and white. You could save a lot of time by just teaching yourself C and writing apps, but there are two disadvantages to this approa
26、ch. 他将错过那些面向对象的知识,由于它能够在他的游戏中使得数据建模更有效率的东西。Youre missing out on what will likely be a much more effective way of modeling the data in your game. By not learning OO programming off the bat, you could be enforcing bad programming habits that youll have to un-learn later. Trust me on this one.最大的商业游戏,包
27、括第一人称射击游戏很多并没有运用C+。但是,这些程序的作者即使运用老的C的格式,他们通常坚持运用面向对象编程技术。假设他只想学C,至少要自学OO面向对象编程技术。OO是仿真游戏的完美方法,假设他不学习OO,他将不得不“辛劳的任务。Many of the biggest commercial games, including most first-person shooters, get by without C+. The authors of these programs, however, always insist that theyre using object-oriented pr
28、ogramming techniques even though theyre using plain old C. If you want to just learn C, at least teach yourself OO programming techniques. OO is the perfect methodology for simulations (read: games), and youll really be doing it the hard way if you push off learning OO. 4、汇编言语Assembly显然,汇编是第一个计算机言语。
29、汇编言语实践上是他计算机处置器实践运转的指令的命令方式表示法。这意味着他将与处置器的底层打交道,比如存放器和堆栈。假设他要找的是类英语且有相关的自我阐明的言语,这不是他想要的。By default, assembly was the first computer language. Assembly language is actually a command-based representation of the actual instructions that your computers processor runs. That means you will be dealing wit
30、h the low-level details of your processor, like registers and stacks. If youre looking for a language thats English-like and is relatively self-documenting, this isnt it!确切的说,任何他能在其他言语里做到的事情,汇编都能做,只是不那么简单 这是当然,就像说他既可以开车到某个地方,也可以走路去,只是难易之分。话虽不错,但是新技术让东西变得更易于运用。By definition, anything you can do in an
31、y other language, you can do in assembly, only not as easily -of course, thats like saying that anywhere you can go in a car, you can go on foot, only not as easily. While the statement might be true, the later technologies made things much easier to use.总的来说,汇编言语不会在游戏中单独运用。游戏运用汇编主要是运用它那些能提高性能的零零碎碎的
32、部分。比如说,消灭战士整体运用C来编写,有几段绘图程序运用汇编。这些程序每秒钟要调用数千次,因此,尽能够的简约将有助于提高游戏的性能。而从C里调用汇编写的函数是相当简单的,因此同时运用两种言语不成问题。In general, assembly language is not used on its own for games. Games that use assembly language use it in bits and pieces where it can improve performance. For example, DOOM is written entirely in C
33、 with a couple of drawing routines hand-coded in assembly. They are the routines that are called a few thousand times a second, so making the routine as tight as possible really helped the performance of the game. Its fairly easy to write a function in assembly that is call-able from C, so using bot
34、h languages wasnt a problem.特别留意:言语的名字叫“汇编。把汇编言语翻译成真实的机器码的工具叫“汇编程序。把这门言语叫做“汇编程序这种用词不当相当普遍,因此,请从这门言语的正确称谓作为起点出发。Special Note: The name of the language is assembly. The name of the tool that converts assembly language into true machine code is called an assembler. Its a common misnomer to call the lan
35、guage assembler, so start out on the right foot by calling the language by its proper name.优点:最小、最快的言语。汇编高手能编写出比任何其他言语能实现的快得多的程序。他将是利用途置器最新功能的第一人,由于他能直接运用它们。Advantages: Is, by definition, the smallest and fastest language. A talented assembly programmer can write programs that are faster than anythi
36、ng that can be done in other languages. Youll be the first person to be able to take advantage of the processors latest new features, because you can use them directly.缺陷:难学、语法晦涩、坚持效率,呵斥大量额外代码 不适于心脏虚弱者。Disadvantages: Difficult to learn, cryptic syntax, tough to do efficiently, and it takes much more
37、 code to get something done -not for the faint of heart!移植性:接近零。由于这门言语是为一种单独的处置器设计的,根本没移植性可言。假设运用了某个特殊处置器的扩展功能,他的代码甚至无法移植到其他同类型的处置器上比如,AMD的3DNow指令是无法移植到其它奔腾系列的处置器上的。Portability: Zilch. Since the language is designed for a single processor, it is not portable by definition. If you use extensions spec
38、ific to a particular brand of processor, your code isnt even portable to other processors of the same type (for example, AMD 3DNOW instructions are not portable to other Pentium-class processors).运用汇编编写的游戏:我不知道有什么商业游戏是完全用汇编开发的。不过有些游戏运用汇编完成多数对时间要求苛刻的部分。Games Written in Assembly: I dont know of any co
39、mmercial games that are written entirely in assembly. Some games, however, have the most time-critical portions done in assembly.资料:假设他正在找一门汇编言语的文档,他主要要找芯片的文档。网络上如Intel、AMD、Motorola等有一些关于它们的处置器的资料。对于书籍而言,是很值得学习的。Resources: When youre looking for documentation for an assembly language, youre basicall
40、y looking for the documentation for the chip. There is some online information at Intel, AMDMotorola for their processors. As for books, Assembly Language: Step-By-Step is well-reviewed.5、Pascal言语Pascal言语是由Nicolas Wirth在七十年代早期设计的,由于他对于FORTRAN和COBOL没有强迫训练学生的构造化编程感到很绝望,“空心粉式代码变成了规范,而当时的言语又不反对它。Pascal被
41、设计来强行运用构造化编程。最初的Pascal被严厉设计成教学之用,最终,大量的拥护者促使它闯入了商业编程中。当Borland发布IBM PC上的 Turbo Pascal时,Pascal辉煌一时。集成的编辑器,闪电般的编译器加上低廉的价钱使之变得不可抵抗,Pascal编程了为MS-DOS编写小程序的首选言语。Pascal was designed by Nicolas Wirth in the early 70s, because he was dismayed to see that FORTRAN and COBOL were not enforcing healthy structure
42、d programming disciplines in students. Spaghetti code was becoming the norm, and the languages of the time werent discouraging it. Pascal was designed from the ground up to enforce structured programming practices. While the original Pascal was designed strictly for teaching, it had enough advocates
43、 to eventually make inroads into commercial programming. Pascal finally took the spotlight in a big way when Borland released Turbo Pascal for the IBM PC. The integrated editor, lightning-fast compiler, and low price were an irresistible combination, and Pascal became the preferred language for writ
44、ing small programs for MS-DOS.然而时日不久,C编译器变得更快,并具有优秀的内置编辑器和调试器。Pascal在1990年Windows开场流行时走到了尽头,Borland放弃了Pascal而把目光转向了为Windows 编写程序的C+。Turbo Pascal很快被人遗忘。The momentum, however, did not stay. C compilers became faster and got nice built-in editors and debuggers. The almost-final nail in Pascals coffin h
45、appened in the early 1990s when Windows took over, and Borland ignored Pascal in favor of C+ for writing Windows applications. Turbo Pascal was all but forgotten.最后,在1996年,Borland发布了它的“Visual Basic杀手 Delphi。它是一种快速的带华美用户界面的 Pascal编译器。由于不懈努力,它很快博得了一大群喜好者。Finally, in 1996, Borland released its Visual B
46、asic Killer, Delphi. Delphi was a fast Pascal compiler coupled with a gorgeous user interface. Against all odds (and the Visual Basic juggernaut), it gained a lot of fans.根本上,Pascal比C简单。虽然语法类似,它缺乏很多C有的简约操作符。这既是好事又是坏事。虽然很难写出难以了解的“聪明代码,它同时也使得一些低级操作,如位操作变得困难起来。On the whole, Pascal is simpler than C. Wh
47、ile the syntax is similar, it lacks a lot of the shortcut operations that C has. This is a good thing and a bad thing. Its harder to write inscrutable clever code, but it makes low-level operations like bit-manipulation more difficult.优点:易学、平台相关的运转Dephi非常好。Advantages: Easy to learn. Platform-specifi
48、c implementations (Delphi) are very nice.缺陷:“世界潮流面向对象的Pascal承继者Modula、Oberon尚未胜利。言语规范不被编译器开发者认同。专利权。Disadvantages: World class OO successors to Pascal (Modula, Oberon) have not been successful. Language standards are not adhered to by compiler-makers. Proprietary. 移植性:很差。言语的功能由于平台的转变而转变,没有移植性工具包来处置平
49、台相关的功能。Portability: Dismal. The features of the language changes from platform to platform, and there are no portability toolkits to handle platform-specific features.运用Pascal编写的游戏:几个。DirectX的Delphi组件使得游戏场所变大了。Games Written in Pascal: A couple. The DirectX components for Delphi have made the playing
50、 field more level.资料:查找跟Delphi有关的资料,请访问:Inprise Delphi page。Resources: The find out about Delphi, check out the Inprise Delphi page.6、Visual Basic哈,BASIC。回到八十年代的石器时代,它是程序初学者的第一个言语。最初的BASIC方式,虽然易于学习,却是可怕的无组织化,它义无返顾的运用了GOTO充斥的“空心粉式代码。当回想起BASIC的行号和GOSUB命令,没有几个人能止住眼角的泪水。Ahh, BASIC. Way back in the stone
51、-age of the 80s, it was the first language for budding programmers. The original incarnations of BASIC, while easy to learn, were horribly unstructured, leading to the a rash of GOTO-laden spaghetti-code. Not many people wipe away tears when reminiscing about BASICs line numbers and the GOSUB comman
52、d.快速前进到九十年代早期,虽然不是苹果公司所希望的巨人,HyperCard依然是一个在Windows下无法比较的吸引人的小型编程环境。Windows下的HyperCard克隆品如ToolBook又慢又笨又昂贵。为了与HyperCard一决高下,微软获得了一个小巧的名为Thunder编程环境的答应权,并把它作为Visual Basci 1.0发布,其用户界面在当时非常具有新意。这门言语虽然还叫做Basic不再是全部大写,但更加构造化了,行号也被去除。实践上,这门言语与那些内置于TRS-80、Apple II及Atari里的旧的ROM BASIC相比,更像是带Basic风格动词的Pascal。F
53、ast-forward to the early 1990s. While not the monster that Apple was hoping for, HyperCard was a compelling little programming environment that had no equal under Windows. Windows-based HyperCard clones like ToolBook were slow, clunky, and expensive. To finally compete with HyperCard, Microsoft lice
54、nsed a neat little programming environment named Thunder, releasing it as Visual Basic 1.0. The user-interface was very innovative for the time. The language, while still called Basic (and no longer all-caps), was much more structured. Line numbers were mercy-killed. The language was, in fact, much
55、closer to Pascal with Basic-style verbs than the old ROM BASIC that was built into every TRS-80, Apple , and Atari.经过六个版本,Visual Basic变得非常美丽。用户界面发生了许多变化,但依然保管着“把代码关联到用户界面的主旨。这使得它在与即时编译结合时变成了一个快速原型的优良环境。Six versions later, Visual Basic is pretty deluxe. The user-interface has made some changes, but s
56、till retains its attach bits of code to the user-interface motif. This, in combination with instantaneous compiling, makes it a terrific environment for fast prototyping.优点:整洁的编辑环境。易学、即时编译导致简单、迅速的原型。大量可用的插件。虽然有第三方的DirectX插件,DirectX 7已预备提供Visual Basic的支持。Advantages: Neat IDE. Easy to learn. Instantan
57、eous compiling makes for very fast and easy prototyping. Lots and lots of add-ons available. While there are currently third-party DirectX add-ons for Visual Basic, DirectX version 7 is going to include support for Visual Basic right out of the box.缺陷:程序很大,而且运转时需求几个宏大的运转时动态衔接库。虽然表单型和对话框型的程序很容易完成,要编写
58、好的图形程序却比较难。调用Windows的API程序非常蠢笨,由于VB的数据构造没能很好的映射到C中。有OO功能,但却不是完全的面向对象。专利权。Disadvantages: Apps are large and require several large runtime DLLs to run. While form and dialog-based apps are easy to make, writing good graphical apps is more difficult. Calling Windows API functions is clunky, because VB
59、data structures dont map nicely to C. Has OO features, but is not fully object-oriented. Proprietary.移植性:非常差。由于Visual Basic是微软的产品,他自然就被局限在他们实现它的平台上。也就是说,他能得到的选择是:Windows,Windows或Widnows。当然,有一些工具能将VB程序转变成Java。Portability: Worse than dismal. Since Visual Basic is owned by Microsoft, youre pretty-much
60、limited to whatever platforms theyve ported it too. That means that youve got the choice of Windows, Windows, or Windows. Note that there are, however, a couple of tools that help convert VB apps to Java.运用Visual Basic编写的游戏:一些。有很多运用VB编写的共享游戏,还有一些是商业性的。Games Written in Visual Basic: A few. There are
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 乡镇加强债务管理办法
- 企业员工转正管理办法
- 企业领导考核管理办法
- 乡镇旅游宾馆管理办法
- 企业专利流程管理办法
- 五项福利补贴管理办法
- 乡村水库养殖管理办法
- 二硫化碳防火管理办法
- 临床化验标本管理办法
- 丰田后补充式管理办法
- GB/T 33365-2016钢筋混凝土用钢筋焊接网试验方法
- GB/T 28055-2011钢质管道带压封堵技术规范
- GB/T 23936-2018工业氟硅酸钠
- GB/T 1874-1995磷矿石和磷精矿中酸不溶物含量的测定重量法
- GB 30980-2014海洋倾倒物质评价规范疏浚物
- GA/T 1393-2017信息安全技术主机安全加固系统安全技术要求
- 尼可地尔临床应用优势课件
- 超星尔雅《诗经》导读检测题答案
- 地源热泵埋管冬夏季换热平衡计算
- 湖北省职称评审专业目录表(工程系列)
- 中考《红星照耀中国》各篇章练习题及答案(1-12)
评论
0/150
提交评论