[Reprint] languages I should use (develop Games)

Source: Internet
Author: User

The following are reprinted and reproduced from:

Http://blog.csdn.net/gaoyunpeng/archive/2008/04/23/2317274.aspx

Directory:
1. C Language
2. c ++
3. c ++ and C
4. Assembly Language
5. Pascal Language
6. Visual Basic
7. Java
8. creation tools
9. Conclusion

--------------------------------------------------------------------------------
Original article: What language do I use
Translated by: sunlxy
Version: the first edition (ver 1.0)
--------------------------------------------------------------------------------

This is a problem in every game programming FAQ. This question is asked several times a week on the game development forum. This is a good question, but no one can give a simple answer. In some applications, some computer languages are better than others. The following describes the main programming languages used to compile games and their advantages and disadvantages. I hope this article will help you make a decision.

1,C Language
If Fortran and COBOL are the first generation of advanced compilation languages, C languages are their grandchildren. C language was created by Dennis Ritchie in 1970s. It is more powerful and maintains more continuous inheritance with ALGOL, while Algol is the structural successor of COBOL and FORTRAN. The C language is designed to be a more sophisticated and simpler version than its predecessors. It is suitable for compiling system-level programs, such as operating systems. Previously, the operating system was compiled in assembly language and cannot be transplanted. C language is the first programming language that makes porting system-level code possible.

The C language supports structured programming, that is, the C program is compiled into a set of separated function calls (CALLS). These calls run from top to bottom, unlike the code of a separate Integrated Block, the GOTO statement is used to control the process. Therefore, the C program is much simpler than the integrated Fortran and COBOL "Hollow powder code" code. In fact, C still has a GOTO statement, but its functions are limited. It is recommended only when the structured solution is very complex.

Because of its system programming roots, it is quite easy to combine C and assembly languages. Function calling interfaces are very simple, and assembly language commands can also be embedded in C code. Therefore, you do not need to connect to an independent assembly module.

Advantage: it is beneficial to write small and fast programs. It is easy to combine with assembly languages. With high standardization, the versions on other platforms are very similar.

Disadvantage: it is not easy to support object-oriented technology. Syntax is sometimes hard to understand and misuse.

Portability: C language and ANSI function calls are both portable, but limited to process control, memory management, and simple file processing. Other things are related to the platform. For example, to develop a portable program for Windows and Mac, the user interface needs to use function calls related to the system. This generally means that you have to write the user interface code twice, but some libraries can reduce the workload.

Games written in C language: very many.
  
Document: the typical C language book is the C programming language. It has been modified several times and has been expanded to three times as large as the first one, but it is still an excellent book introducing C. An excellent tutorial is the Waite group's c primer plus.

2,C ++
C ++ is the successor of C language with object-oriented features. Object-Oriented Programming, or Oop, is the next step in structured programming. OO programs are grouped by objects, where objects are discrete sets of data and functions. There are a lot of available objects in stock, which makes programming as simple as simply putting together some program "Building Materials" (at least theoretically ). For example, there are many GUI and database implementations as a collection of objects.

C ++ is always the subject of debate, especially in game development forums. There are several C ++ functions, such as virtual functions, which add an additional level for decision making of function calls, critics soon pointed out that C ++ programs will become much slower than C programs with the same functionality. C ++ advocates believe that using C to write code equivalent to a virtual function will also increase expenses. This will be a debate that is still in progress and cannot be quickly concluded.

In my opinion, the extra cost of C ++ is only a small cost for using better languages. The same debate occurred in 1960s when advanced programming languages such as COBOL and FORTRAN began to replace assembly as language choices. Critics correctly point out that a program written in advanced languages is inherently slower than a handwritten assembly language, and must be so. High-level language support believes that such a small performance loss is worthwhile, because the COBOL and Fortran programs are easier to write and maintain.

Advantage: it is much better to organize large programs than the C language. It supports the object-oriented mechanism. Common data structures, such as linked lists and databases composed of scalable arrays, reduce the burden of processing low-level details.

Disadvantage: It is very large and complex. Similar to the C language, there is a syntax abuse problem. It is slower than C. Most compilers do not correctly implement the entire language.

Portability: it is much better than C, but it is still not very optimistic. Because it has the same disadvantages as the C language, most portable User Interface libraries are implemented using C ++ objects.

Games written in C ++: very many. Most commercial games are written in C or C ++.

MATERIALS: the latest version of the C ++ programming language is very good. As a tutorial, there are two camps. One is assumed that you know C, and the other is assumed that you do not know. So far, the best C ++ tutorial is "who's afraid of C ++". If you are familiar with C, try "Teach Yourself C ++".

3,I should study c ++ or start from C.
I don't like this, but it is the most frequently asked question after "which language should I use. Unfortunately, there is no standard answer. You can learn C by yourself and use it to write programs, which saves a lot of time. However, using this method has two drawbacks:

You will miss out on the object-oriented knowledge, as it may make data modeling more efficient in your game.
You don't need to start learning OO programming right away, but it may force you to get rid of the bad programming habits that you must forget in the end. Please trust me in this regard.

Many of the largest commercial games, including first-person shooter games, do not use C ++. However, even if the authors of these programs use the old c format, they usually stick to the object-oriented programming technology. If you only want to learn C, you should at least learn Oo (Object-Oriented) programming technology. Oo is the perfect method for simulation (game). If you don't learn Oo, you will have to "Work hard.

4,Assembly Language(Assembly)
Obviously, assembly is the first computer language. Assembly language is actually the command form representation of the commands actually run by your computer processor. This means you will deal with the underlying processor, such as registers and stacks. If you are looking for a language similar to English and relevant self-explanatory language, this is not what you want.

To be exact, compilation can be done for anything you can do in other languages, but it is not that simple-that is, of course, just like you can drive somewhere, you can also walk, but it is difficult. Although it is good, new technologies make things easier to use.

In general, the assembly language will not be used independently in the game. The use of assembly for games is mainly used for its fragmented parts that can improve performance. For example, the destroyer uses C as a whole, and several plotting programs use assembly. These programs are called thousands of times per second, so as concise as possible will help improve the game performance. The calling of compiled functions in C is quite simple. Therefore, using both languages is not a problem.

Note: The Language name is "assembly ". A tool that translates an assembly language into a real machine code is called an assembly program ". The improper use of this language as "assembler" is quite common. Therefore, start with the correct name of this language.

Advantage: The smallest and fastest language. Assembler experts can compile programs that are much faster than any other language. You will be the first to take advantage of the latest processor features, because you can directly use them.

Disadvantages: hard to learn, obscure syntax, and persistent efficiency, resulting in a large amount of additional code-not suitable for weak heart.

Portability: close to zero. Because this language is designed for a separate processor, there is no portability at all. If you use an extended feature of a special processor, your code cannot even be transplanted to another processor of the same type (for example, AMD's 3dnow command cannot be transplanted to other Pentium series Processors ).

Games written using assembler: I don't know any commercial games are fully developed using assembler. However, some games use assembler to complete most time-demanding parts.

MATERIALS: If you are looking for an assembly language document, you are mainly looking for a chip document. There are some information about their processors on the network, such as Intel, AMD, and Motorola. For books, assembly language: Step-by-step is worth learning.

5,PASCAL Language
Pascal was designed by Nicolas Wirth in the early 1970s s because he was disappointed with the structured programming in which Fortran and COBOL did not force students to be trained, and the "hollow powder-style code" turned into a specification, at that time, the language did not oppose it. Pascal was designed to forcibly use structured programming. The original Pascal was strictly designed for teaching purposes. In the end, a large number of advocates forced it into commercial programming. When Borland released Turbo Pascal on ibm pc, Pascal was brilliant. The integrated Editor, lightning-like compiler, and low prices make it irresistible, Pascal programmed the first language to write applets for the MS-DOS.

However, soon after, the C compiler became faster and had excellent built-in editors and debuggers. Pascal came to an end when Windows became popular in 1990. Borland gave up Pascal and turned to C ++, which programmed windows. Turbo Pascal was quickly forgotten.

Finally, Borland released its "Visual Basic killer"-Delphi in 1996. It is a quick PASCAL Compiler with a gorgeous user interface. Thanks to unremitting efforts, it soon won a large group of fans.

Basically, Pascal is simpler than C. Although the syntax is similar, it lacks many concise operators in C. This is both a good thing and a bad thing. Although it is difficult to write "intelligent" code that is hard to understand, it also makes some low-level operations, such as bit operations, difficult.

Advantages: easy to learn and platform-related operations (dephi) are very good.

Disadvantage: the owner of Pascal (modula and Oberon) for "world trend" is not successful yet. Language standards are not recognized by compiler developers. Patent right.

Portability: poor. The language functions have changed due to the transformation of the platform, and there is no portability toolkit to handle platform-related functions.

Games Written in Pascal: several. The Delphi Component of DirectX makes the game site larger.

MATERIALS: Find information related to Delphi. Please visit: Inprise Delphi page.

6,Visual Basic
Ha, basic. Back to the Stone Age in 1980s, it was the first language for beginners. In the initial basic form, although easy to learn, it is terrible and unorganized. It uses the Goto-filled "Hollow powder-type code" without hesitation ". When I recall the basic line number and the gosub command, few people can stop tears in the corners of their eyes.

Fast forward to the early 1990s s, although not the giant Apple expected, HyperCard is still an attractive small programming environment that is unmatched in windows. HyperCard clones in windows, such as Toolbook, are slow, stupid, and expensive. To compete with HyperCard, Microsoft obtained a small license named Thunder programming environment and published it as visual basci 1.0. Its user interface was very innovative at the time. Although this language is also called Basic (not all uppercase), it is more structured and the row number is also removed. In fact, this language is more like Pascal with basic style verbs than the old Rom basic in TRS-80, Apple II, and Atari.

After six versions, Visual Basic has become very beautiful. The user interface has undergone many changes, but it still retains the subject of "associating code to the User Interface. This makes it an excellent environment for rapid prototyping when combined with real-time compilation.

Advantage: A Clean editing environment. Easy to learn and instant compilation lead to a simple and rapid prototype. A large number of available plug-ins. Although there are third-party DirectX plug-ins, DirectX 7 is ready to provide visual basic support.

Disadvantage: The program is very large, and several huge runtime dynamic connection libraries are required during running. Although form-and dialog-type programs are easy to complete, it is difficult to write good graphics programs. Calling the Windows API program is very clumsy, because the VB data structure cannot be well mapped to C. It has the OO function, but is not completely object-oriented. Patent right.

Portability: very poor. Because Visual Basic is a Microsoft product, you are naturally limited to the platform on which they implement it. In other words, you can choose windows, windows, or Widnows. Of course, there are some tools that can convert the vbprogram into Java.

Games Written in Visual Basic: Some. There are many shared Games Written in VB, and some are commercial.

MATERIALS: Microsoft's VB page has some information.

7,Java
Java was originally designed by Sun for the portability of embedded programs "small C ++ ". The idea of running applets on the Web page attracted a lot of people, so the language rapidly rose. It turns out that Java is not only suitable for embedding animations on webpages-it is an excellent and complete small language for software programming. The "Virtual Machine" mechanism, garbage collection, and no pointers make it easy to implement reliable programs that are not prone to crashes and do not leak resources.

Although it is not a formal continuation of C ++, Java borrowed a lot of syntax from C ++. It discards many complex functions of C ++ to form a compact and easy-to-learn language. Unlike C ++, Java enforces object-oriented programming, writing non-Object-oriented Programs in Java is just as difficult as writing "Hollow powder code" in Pascal.

Advantage: binary code can be transplanted to other platforms. Programs can run on webpages. The class libraries are extremely standard and robust. Automatic splitting and garbage collection prevent program resource leakage. A large number of online code routines.

Disadvantage: using a "Virtual Machine" to run portable bytecode rather than local machine code, the program will be slower than the real compiler. Many technologies (such as the "instant" compiler) greatly improve Java's speed, but the speed is never better than the machine code solution. Early functions, such as AWT, were not carefully considered. Although formally abolished, they had to be retained to maintain backward compatibility. The more advanced the technology is, the more difficult it is to process low-level machine functions. Sun is too slow to add new "blessed" features to the language.

Portability: it is the best, but it still does not reach the level it should have. Low-level code is highly portable, but many UIS and new features are unstable on some platforms.

Games Written in Java: there are a large number of small applets on the web page, but only some of them are commercial. Several commercial games use Java as the internal scripting language.

Info: Sun's official Java page has some good information. IBM also has a very good Java page. Javalobby is the best place for Java news.

8,Creation tools
The programming language mentioned above covers most commercial games. But there is also an exception. This big game has become prominent due to its absence.

"Mysterious Island ". Yes, the best-selling commercial games are not made in any of the above languages. Although some people say that "mydo" 99% is made using 3D modeling tools, its fundamental programming logic is completed in HyperCard.

Most creation tools are a bit like Visual Basic, but they work at a higher level. Most tools use some drag-and-drop flowcharts to simulate process control. Many programming languages with built-in interpretations, but these languages cannot be as robust as the independent languages mentioned above.

Advantage: Quick Prototyping-if your game meets the purpose of tool creation, you may make your game run faster than other languages. In many cases, you can create a simple game without any code. Using plug-in programs, such as shockware and iconauthor players, you can publish programs generated by many creation tools on the web page.

Disadvantage: patent right. As to what features will be added, you will be governed by the tool manufacturer. You must consider whether these tools can meet your game needs, because there are many things that cannot be done by those creative tools. Some tools generate bloated and terrible programs.

Portability: Because creation tools are patented, your portability is closely related to the functions they provide. Some systems, such as director, can be created and run on several platforms. Some tools are created on a certain platform and run on multiple platforms, some can only be created and run on a single platform.

Games written using creative tools: Mysterious Island and other adventure games of the same type. All shockwave games are on the network.

MATERIALS: Director, HyperCard, supercard, iconauthor, and Authorware.

9,Conclusion
You may want to get a more standard conclusion on the question "which language should I use. Unfortunately, there is no best solution for all applications. C is suitable for fast and small programs, but does not support object-oriented programming. C ++ fully supports object-oriented, but very complex. Visual Basic and Delphi are easy to learn, but cannot be transplanted and have patent rights. Java has many simple functions, but it is slow. The creation tool can generate your program as quickly as possible, but it only works for some types of programs. The best way is to decide what kind of game you want to write and select the best language to support your game. It is a good thing to "try for 30 days" to become an industrial standard.

--------------------------------------------------------------------------------
Author Profile
John Hattan is the principal manager of code zone, the largest software company in watauga, Texas. If you have any opinions on his article, please write to him.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.