Why do we need to learn C language?

Source: Internet
Author: User

C is the most commonly used programming language for writing an operating system ). Unix is the first operating system written in C. Later, Microsoft Windows, Mac OS X, and GNU/Linu were all written in C. C is not only the language of the operating system, but also a pioneer and inspiration for almost all of the most popular advanced languages today. In fact, Perl, PHP, Python, and Ruby are all written in C.

By analogy, let's say the Spanish, Italian, French, or Portuguese you 've been learning. Have you ever wondered if it would be useful to point to Latin? Because Latin is the basis of all these languages, you can understand and appreciate the entire programming language family built on traditional C. Knowing C gives you freedom.

Why C, not assembly language?

The assembly language provides speed and maximum programming controllability, and C provides portability.

Different processors must adopt different assembly languages for programming. One of them must be selected and only one can be learned. This is too much. In fact, in the face of many computer architectures, a major advantage of C is its versatility and portability, while leaving most of the control on the hardware layer to the assembly language.

For example, C programs can be compiled and run on the following devices, HP 50g calculator ARM processor), TI-89 calculator 68000 processor), Palm OS Cobalt smartphone ARM processor), the original iMacPowerPC), ArduinoAtmel AVR) and Intel iMacIntel Core 2 Duo ). Each of these devices has its own proprietary assembly language and is completely incompatible with the assembly language of any other device.

Assembly Language, very powerful, but it is difficult to write large applications, it is difficult to read and explain in a logical way. C is a compilation language that can generate fast and effective executable files. C is also a small "WYSIWYG" language: a c statement corresponds to at most several Assembly statements, and other statements are provided in the form of library functions.

So that's why C is so popular?

Just like the dominoes, the next generation of Programs follow the footprints of its predecessors. Operating systems designed with C usually use the system library designed with C. These system libraries, in turn, are used to build advanced libraries such as OpenGL or GTK. The designers of these libraries usually use the language used by the system library. The advanced library is used by application developers to design word processing programs, games, and media players. Most of them will choose the language used by the advanced library for programming. This mode works like this...

Why C, not another advanced language?

C is mainly designed to generate portable code while maintaining performance and minimizing footprint. This is what the "advanced" interface intended to play in the operating system or other programs. As a stable and mature language, its features may not disappear for a long time, but are transplanted to platforms that are mostly, if not all.

For example, C Programs can compile and run on these devices, including HP 50g calculator ARM processor), TI-89 calculator 68000 processor), Palm OS Cobalt smartphone ARM processor), original iMacPowerPC), ArduinoAtmel AVR) and Intel iMacIntel Core 2 Duo ). Almost all popular programming languages can run on at least one of these devices, and C may be the only programming language that can run on more than three of these devices.

One of the most powerful reasons is memory allocation. Unlike most computer languages, C allows programmers to write memory directly. In C, such as struct, pointer, and array, these designs aim to build and operate memory in an efficient and machine-independent way. In particular, C provides the control method on the memory layer of the data structure. In addition, dynamic memory allocation is controlled by programmers, which must mean that memory redistribution has become a burden on program elements. Java, Perl, and other languages are used to free programmers from worries about memory allocation and pointers. This is a good thing in general, because it is easy to handle memory errors when writing advanced programs. However, C provides a unified and clear interface for processing lower-layer code, such as the part of a device controlled by the operating system. Other advanced languages such as Java do not have these performances.

Perl, PHP, Python, and Ruby may be powerful and support many features that are not supported by C by default. Generally, these languages cannot be implemented by themselves. On the contrary, most of these languages are originally written on C or another high-performance programming language, and must be transplanted to the new platform before use.

Like all programming languages, whether or not to prioritize C language depends on technical and business needs

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.