Daniel has created high-performance applications in C++ for large companies such as Dreamworks. He also excels with C & ASM (x86).

Bạn đang xem: C'est la vie là gì

Many of the C projects that exist today were started decades ago.

The UNIX operating system’s development started in 1969, và its code was rewritten in C in 1972. The C language was actually created to move the UNIX kernel code from assembly to lớn a higher màn chơi language, which would vày the same tasks with fewer lines of code.

Oracle database development started in 1977, và its code was rewritten from assembly khổng lồ C in 1983. It became one of the most popular databases in the world.

In 1985 Windows 1.0 was released. Although Windows source code is not publicly available, it’s been stated that its kernel is mostly written in C, with some parts in assembly. Linux kernel development started in 1991, and it is also written in C. The next year, it was released under the GNU license và was used as part of the GNU Operating System. The GNU operating system itself was started using C và Lisp programming languages, so many of its components are written in C.

But C programming isn’t limited to projects that started decades ago, when there weren’t as many programming languages as today. Many C projects are still started today; there are some good reasons for that.

How is the World Powered by C?

Despite the prevalence of higher-level languages, C continues to lớn empower the world. The following are some of the systems that are used by millions and are programmed in the C language.

Microsoft Windows

Microsoft’s Windows kernel is developed mostly in C, with some parts in assembly language. For decades, the world’s most used operating system, with about 90 percent of the market share, has been powered by a kernel written in C.


Linux is also written mostly in C, with some parts in assembly. About 97 percent of the world’s 500 most powerful supercomputers run the Linux kernel. It is also used in many personal computers.


Mac computers are also powered by C, since the OS X kernel is written mostly in C. Every program and driver in a Mac, as in Windows và Linux computers, is running on a C-powered kernel.


iOS, Android & Windows Phone kernels are also written in C. They are just thiết bị di động adaptations of existing Mac OS, Linux và Windows kernels. So smartphones you use every day are running on a C kernel.

Operating System Kernels Written in C


The world’s most popular databases, including Oracle Database, MySquốc lộ, MS Squốc lộ Server, và PostgreSQL, are coded in C (the first three of them actually both in C & C++).

Databases are used in all kind of systems: financial, government, truyền thông, entertainment, telecommunications, health, education, retail, social networks, website, and the like.

Databases Powered by C

3 chiều Movies

3 chiều movies are created with applications that are generally written in C & C++. Those applications need to lớn be very efficient và fast, since they handle a huge amount of data & vày many calculations per second. The more efficient they are, the less time it takes for the artists & animators to generate the movie shots, & the more money the company saves.

Embedded Systems

Imagine that you wake up one day và go shopping. The alarm clock that wakes you up is likely programmed in C. Then you use your microwave or coffee maker khổng lồ make your breakfast. They are also embedded systems & therefore are probably programmed in C. You turn on your TV or radio while you eat your breakfast. Those are also embedded systems, powered by C. When you open your garage door with the remote control you are also using an embedded system that is most likely programmed in C.

Then you get inlớn your car. If it has the following features, also programmed in C:

automatic transmission tire pressure detection systems sensors (oxygen, temperature, oil level, etc.) memory for seats and mirror settings. dashboard display anti-lochồng brakes automatic stability control cruise control climate control child-proof locks keyless entry heated seats airbag control

You get to the store, park your oto and go to a vending machine lớn get a sodomain authority. What language did they use to program this vending machine? Probably C. Then you buy something at the store. The cash register is also programmed in C. And when you pay with your credit card? You guessed it: the credit thẻ reader is, again, likely programmed in C.

All those devices are embedded systems. They are lượt thích small computers that have a microcontroller/microprocessor inside that is running a program, also called firmware, on embedded devices. That program must detect key presses và act accordingly, and also display information khổng lồ the user. For example, the alarm cloông chồng must interact with the user, detecting what button the user is pressing and, sometimes, how long it is being pressed, và program the device accordingly, all while displaying to the user the relevant information. The anti-loông xã brake system of the oto, for example, must be able khổng lồ detect sudden locking of the tires & act to lớn release the pressure on the brakes for a small period of time, unlocking them, and thereby preventing uncontrolled skidding. All those calculations are done by a programmed embedded system.

Although the programming language used on embedded systems can vary from brvà lớn brvà, they are most commonly programmed in the C language, due khổng lồ the language’s features of flexibility, efficiency, performance, and closeness to the hardware.

Embedded Systems are Often Written in C

Why is the C Programming Language Still Used?

There are many programming languages, today, that allow developers to be more productive sầu than with C for different kinds of projects. There are higher màn chơi languages that provide much larger built-in libraries that simplify working with JSON, XML, UI, website pages, client requests, database connections, truyền thông media manipulation, and so on.

But despite that, there are plenty of reasons lớn believe that C programming will remain active for a long time.

In programming languages one kích cỡ does not fit all. Here are some reasons that C is unbeatable, and almost mandatory, for certain applications.

Portability & Efficiency

C is almost a portable assembly language. It is as cthất bại to the machine as possible while it is almost universally available for existing processor architectures. There is at least one C compiler for almost every existent architecture. And nowadays, because of highly optimized binaries generated by modern compilers, it’s not an easy task to lớn improve sầu on their output with hvà written assembly.

Xem thêm: Chế Độ Ăn Eat Clean Là Gì Bạn Muốn Biết Về Chế Độ Ăn “Thần Thánh” Này

Such is its portability and efficiency that “compilers, libraries, và interpreters of other programming languages are often implemented in C”. Interpreted languages lượt thích Pybé nhỏ, Ruby, và PHP. have their primary implementations written in C. It is even used by compilers for other languages to communicate with the machine. For example, C is the intermediate language underlying Eiffel & Forth. This means that, instead of generating machine code for every architecture lớn be supported, compilers for those languages just generate intermediate C code, & the C compiler handles the machine code generation.

C has also become a lingua franca for communicating between developers. As Alex Allain, Dropbox Engineering Manager & creator of Cprogramming.com, puts it:

C is a great language for expressing comtháng ideas in programming in a way that most people are comfortable with. Moreover, a lot of the principles used in C – for instance, argc và argv for commvà line parameters, as well as loop constructs and variable types – will show up in a lot of other languages you learn so you’ll be able to talk to people even if they don’t know C in a way that’s comtháng khổng lồ both of you.

Memory Manipulation

Arbitrary memory address access & pointer arithmetic is an important feature that makes C a perfect fit for system programming (operating systems và embedded systems).

At the hardware/software boundary, computer systems và microcontrollers bản đồ their peripherals và I/O pins inkhổng lồ memory addresses. System applications must read và write to lớn those custom memory locations khổng lồ communicate with the world. So C’s ability to lớn manipulate arbitrary memory addresses is imperative for system programming.

A microcontroller could be architected, for example, such that the byte in memory address 0x40008000 will be sent by the universal asynchronous receiver/transmitter (or UART, a common hardware component for communicating with peripherals) every time bit number 4 of address 0x40008001 is phối to lớn 1, và that after you mix that bit, it will be automatically unphối by the peripheral.

This would be the code for a C function that sends a byte through that UART:

#define UART_BYTE *(char *)0x40008000 #define UART_SEND *(volatile char *)0x40008001 |= 0x08 void send_uart(char byte) UART_BYTE = byte; // write byte to lớn 0x40008000 address UART_SEND; // set bit number 4 of address 0x40008001 The first line of the function will be expanded to:

*(char *)0x40008000 = byte;This line tells the compiler to interpret the value 0x40008000 as a pointer khổng lồ a char, then to lớn dereference (give the value pointed khổng lồ by) that pointer (with the leftmost * operator) & finally to lớn assign byte value to that dereferenced pointer. In other words: write the value of variable byte to memory address 0x40008000.

The next line will be expanded to:

*(volatile char *)0x40008001 |= 0x08;In this line, we perform a bitwise OR operation on the value at address 0x40008001 and the value 0x08 (00001000 in binary, i.e., a 1 in bit number 4), và save sầu the result back lớn address 0x40008001. In other words: we phối bit 4 of the byte that is at address 0x40008001. We also declare that the value at address 0x40008001 is volatile. This tells the compiler that this value may be modified by processes external khổng lồ our code, so the compiler won’t make any assumptions about the value in that address after writing to lớn it. (In this case, this bit is unmix by the UART hardware just after we mix it by software.) This information is important for the compiler’s optimizer. If we did this inside a for loop, for example, without specifying that the value is volatile, the compiler might assume this value never changes after being mix, & skip executing the comm& after the first loop.

Deterministic Usage of Resources

A comtháng language feature that system programming cannot rely on is garbage collection, or even just dynamic allocation for some embedded systems. Embedded applications are very limited in time & memory resources. They are often used for real-time systems, where a non-deterministic điện thoại tư vấn khổng lồ the garbage collector cannot be afforded. And if dynamic allocation cannot be used because of the laông xã of memory, it is very important khổng lồ have other mechanisms of memory management, lượt thích placing data in custom addresses, as C pointers allow. Languages that depkết thúc heavily on dynamic allocation & garbage collection wouldn’t be a fit for resource-limited systems.

Code Size

C has a very small runtime. And the memory footprint for its code is smaller than for most other languages.

When compared to lớn C++, for example, a C-generated binary that goes lớn an embedded device is about half the kích cỡ of a binary generated by similar C++ code. One of the main causes for that is exceptions tư vấn.

Exceptions are a great tool added by C++ over C, và, if not triggered and smartly implemented, they have sầu practically no execution time overhead (but at the cost of increasing the code size).

Let’s see an example in C++:

// Class A declaration. Methods defined somewhere else; class Apublic: A(); // Constructor ~A(); // Destructor (called when the object goes out of scope or is deleted) void myMethod(); // Just a method;// Class B declaration. Methods defined somewhere else;class Bpublic: B(); // Constructor ~B(); // Destructor void myMethod(); // Just a method;// Class C declaration. Methods defined somewhere else;class Cpublic: C(); // Constructor ~C(); // Destructor void myMethod(); // Just a method;void myFunction() A a; // Constructor a.A() called. (Checkpoint 1) B b; // Constructor b.B() called. (Checkpoint 2) b.myMethod(); // (Checkpoint 3) // b.~B() destructor called. (Checkpoint 4) C c; // Constructor c.C() called. (Checkpoint 5) c.myMethod(); // (Checkpoint 6) // c.~C() destructor called. (Checkpoint 7) a.myMethod(); // (Checkpoint 8) // a.~A() destructor called. (Checkpoint 9)Methods of A, B và C classes are defined somewhere else (for example in other files). Therefore the compiler cannot analyze them & cannot know if they will throw exceptions. So it must prepare khổng lồ handle exceptions thrown from any of their constructors, destructors, or other method calls. Destructors should not throw (very bad practice), but the user could throw anyway, or they could throw indirectly by calling some function or method (explicitly or implicitly) that throws an exception.

If any of the calls in myFunction throw an exception, the stack unwinding mechanism must be able to lớn điện thoại tư vấn all the destructors for the objects that were already constructed. One implementation for the stachồng unwinding mechanism will use the return address of the last call from this function to verify the “checkpoint number” of the Hotline that triggered the exception (this is the simple explanation). It does this by making use of an auxiliary autogenerated function (a kind of look-up table) that will be used for stachồng unwinding in case an exception is thrown from the body toàn thân of that function, which will be similar to this:

// Possible autogenerated functionvoid autogeneratedStackUnwindingFor_myFunction(int checkpoint) switch (checkpoint) // case 1 & 9: bởi vì nothing; case 3: b.~B(); goto destroyA; // jumps khổng lồ location of destroyA label case 6: c.~C(); // also goes lớn destroyA as that is the next line destroyA: // label case 2: case 4: case 5: case 7: case 8: a.~A(); If the exception is thrown from checkpoints 1 and 9, no object needs destruction. For checkpoint 3, b & a must be destructed. For checkpoint 6, c & a must be destructed. In all cases the destruction order must be respected. For checkpoints 2, 4, 5, 7, & 8, only object a needs to be destructed.

This auxiliary function adds kích cỡ khổng lồ the code. This is part of the space overhead that C++ adds to C. Many embedded applications cannot afford this extra space. Therefore, C++ compilers for embedded systems often have a flag lớn disable exceptions. Disabling exceptions in C++ is not không tính tiền, because the Standard Template Library heavily relies on exceptions khổng lồ inform errors. Using this modified scheme, without exceptions, requires more training for C++ developers to detect possible issues or find bugs.

And, we are talking about C++, a language whose principle is: “You don’t pay for what you don’t use.” This increase on binary form size gets worse for other languages that add additional overhead with other features that are very useful but cannot be afforded by embedded systems. While C does not give sầu you the use of these extra features, it allows a much more compact code footprint than the other languages.

Reasons khổng lồ Learn C

C is not a hard language khổng lồ learn, so all the benefits from learning it will come quite cheap. Let’s see some of those benefits.

Lingua Franca

As already mentioned, C is a lingua franca for developers. Many implementations of new algorithms in books or on the internet are first (or only) made available in C by their authors. This gives the maximum possible portability for the implementation. I’ve seen programmers struggling on the mạng internet to lớn rewrite a C algorithm lớn other programming languages because he or she didn’t know very basic concepts of C.

Be aware that C is an old và widespread language, so you can find all kind of algorithms written in C around the website. Therefore you’ll very likely benefit from knowing this language.

Understand the Machine (Think in C)

When we discuss the behavior of certain portions of code, or certain features of other languages, with colleagues, we end up “talking in C:” Is this portion passing a “pointer” khổng lồ the object or copying the entire object? Could any “cast” be happening here? And so on.

We would rarely discuss (or think) about the assembly instructions that a portion of code is executing when analyzing the behavior of a portion of code of a high màn chơi language. Instead, when discussing what the machine is doing, we speak (or think) pretty clearly in C.

Moreover, if you can’t stop and think that way about what you are doing, you may kết thúc up programming with some sort of superstition about how (magically) things are done.

Xem thêm: Nông Nghiệp An Toàn Là Gì - Xây Dựng Nền Nông Nghiệp An Toàn, Hiệu Quả

Think Like the Machine with C

Work on Many Interesting C Projects

Many interesting projects, from big database servers or operating system kernels, khổng lồ small embedded applications you can even vì at trang chính for your personal satisfaction & fun, are done in C. There is no reason khổng lồ stop doing things you may love for the single reason that you don’t know an old and small, but svào & time-proven programming language like C.

Chuyên mục: Blog