Introduction and advantages and disadvantages of the main programming language used to write games

Source: Internet
Author: User
Tags data structures goto

This is a problem in every game Programming FAQ. The question is asked several times a week at the Game Development Forum. This is a good question, but no one can give a simple answer. In some applications, there are always some computer languages that are superior to other languages. Here are a few of the main programming languages that are used to write games and their pros and cons. I hope this article will help you make a decision.

1, C language

If Fortran and COBOL are the first generation of advanced compiler languages, then C language is their grandchildren. The C language was created by the Dennis Ritchie in the 70 's, it is more powerful and has a more continuous inheritance with ALGOL, while Algol is a structured successor to COBOL and FORTRAN. The C language is designed to be a more sophisticated and simpler version than its predecessors, and it is suitable for writing system-level programs, such as operating systems. Prior to this, the operating system was written in assembly language and was not portable. The C language is the first programming language to make system-level code porting possible.

The C language supports structured programming, which means that the C program is written as a collection of discrete function calls (calls) that run from top to bottom rather than using the Goto statement to control the process like a single integrated block of code. 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 functionality is limited and is recommended only when a structured solution is very complex.

Because of its system programming root, it is quite easy to combine C with assembly language. Function call interface is very simple, and assembly language instructions can be embedded into the C code, so, do not need to connect the independent assembly module.

Advantages: Useful for writing small and fast programs. It's easy to combine with assembly language. are highly standardized, so the versions on other platforms are very similar.

Disadvantage: Object-oriented technology is not easy to support. Grammar can sometimes be very difficult to understand and cause abuse.

Portability: The core of C language and ANSI function calls are portable, but are limited to process control, memory management, and simple file processing. Everything else is related to the platform. For example, to develop portable programs for Windows and Macs, the user interface section needs to use system-related function calls. This generally means that you have to write two user interface code, but fortunately there are some libraries to reduce the workload.

A game written in C: very, very much.

Material: C Language Classics is "The C programming Language", it has been modified several times, has expanded to the initial three times times large, but it is still introduced the excellent book of C. An excellent tutorial is "The Waite Group ' s C Primer Plus."

2, C + +

The C + + language is the successor of the C language with object-oriented features. Object-oriented programming, or OOP, is the next step in structured programming. OO programs consist of objects in which objects are discrete collections of data and functions. There are a number of object libraries available, which makes programming simple enough to heap some program "building materials" together (at least in theory). For example, there are many libraries of GUIs and databases implemented as collections of objects.

C + + is always the subject of debate, especially in the Game Development Forum. There are several C + + features, such as virtual functions, which add an extra level to the decision making of function calls, and critics quickly point out that C + + programs will become much slower than C programs with the same functionality. Proponents of C + + argue that writing code equivalent to a virtual function in C also increases spending. This will be a debate that is still going on and is unlikely to come to a conclusion soon.

I think that the extra cost of C + + is just using a little pay for better language. The same controversy took place in the 60 's when advanced programming languages such as COBOL and Fortran began to replace the Assembly as the language of choice. Critics rightly point out that programs written in high-level languages are inherently slower than handwritten assembly language, and necessarily so. High-level language advocates say such a small loss of performance is worthwhile because COBOL and FORTRAN programs are easier to write and maintain.

Advantage: Organizing large programs is much better than C language. Very good support for object-oriented mechanism. Common data structures, such as lists of linked lists and scalable arrays, reduce the burden of handling low-level details.

Disadvantages: Very large and complex. As with C language, there is a problem of grammatical abuse. Slower than C. Most compilers do not implement the entire language correctly.

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

Games written using C + +: very, very much. Most business games are written using C or C + +.

Material: The latest edition of the "the C + + programming Language" is very good. As a tutorial, there are two camps, one assumes you know C, and another assumes you don't know. So far, the best C + + tutorial is The Who's afraid of C + +, and if you're already familiar with C, try teach yourself C + +.

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.