Breaking News

5 Facts About C Language which makes it So Popular


www.technotoken.blogspot.com


So whether you are a newbie in the Programming world or an Medioker one question must have always struck inside your brain and that's that if C Programming Language is Such Old Language and there are Other languages already present today then what is it about the C language that makes it still exist well Today we are going to talk about the 29 Facts which makes the C Programming Language to still exist in today's Programming World.



# Fact 1


Numerous systems that are used by millions and are programmed in the C language Like:

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

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

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 and Linux computers, is running on a C-powered kernel.

Mobile

iOS, Android and Windows Phone kernels are also written in C. They are just mobile adaptations of existing Mac OS, Linux and Windows kernels. So smartphones you use every day are running on a C kernel.

Databases

The world’s most popular databases, including Oracle Database, MySQL, MS SQL Server, and PostgreSQL, are coded in C (the first three of them actually both in C and C++).

Databases are used in all kind of systems: financial, government, media, entertainment, telecommunications, health, education, retail, social networks, web, and the like.

3D Movies

3D movies are created with applications that are generally written in C and C++. Those applications need to be very efficient and fast, since they handle a huge amount of data and do many calculations per second. The more efficient they are, the less time it takes for the artists and animators to generate the movie shots, and the more money the company saves.

Embedded Systems

Imagine that you wake up one day and go shopping. The alarm clock that wakes you up is likely programmed in C. Then you use your microwave or coffee maker to make your breakfast. They are also embedded systems and 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 it's in your car. 

Following features of your Car are 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-lock brakes
  • automatic stability control
  • cruise control
  • climate control
  • child-proof locks
  • keyless entry
  • heated seats
  • airbag control


#Fact 2


Despite of many higher level languages already present there which provide much larger built-in libraries The another reason that C is going to be there for a long Time is due to it's Portability , efficiency, Deterministic Usage of Resources and Code size which are discussed as follows:

Portability and Efficiency

C is more close to the machine as compared to any other Programming language out there also it is available universally for almost every 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 improve on their output with handwritten assembly.

It is so much portable and efficient that “Compilers, Libraries, and Interpreters of other programming languages are also often implemented in C for Maximum efficiency” This means that, instead of generating machine code for every architecture to be supported, compilers for those languages just generate intermediate C code, and the C compiler handles the machine code generation. Many of the Interpreted languages like Python, Ruby, and PHP have their primary implementations written in C. It is even used by compilers for other languages to communicate with the machine.

As Wiki Books puts it:

“Unlike most computer languages, C allows the programmer to write directly to memory. Key constructs in C such as structs, pointers and arrays are designed to structure, and manipulate memory in an efficient, machine-independent fashion."


#Fact 3

Memory Manipulation

There are several functions for memory allocation and management that C programming language provides. These functions can be found in the <stdlib.h> header file.

In simple words if you are aware of the size of an array, then it is easy and you can define it as an array. 

For example:  To store a name of any person, it can go up to a maximum of 150 characters, so you can define something as follows −

char name[150];

 This feature also makes C a perfect fit for system programming (operating systems and embedded systems). System applications must read and write to the custom memory locations in which microcontrollers map their peripherals and I/O pins in order to communicate with the world. So C’s ability to manipulate arbitrary memory addresses is imperative for system programming.


A microcontroller could be architected also which could be understood with an example 

Let us assume 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 set to 1, and that after you set that bit, it will be automatically unset 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 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 to a char, then to dereference (give the value pointed to by) that pointer (with the leftmost * operator) and finally to 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), and save the result back to address 0x40008001. In other words: we set 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 to our code, so the compiler won’t make any assumptions about the value in that address after writing to it. (In this case, this bit is unset by the UART hardware just after we set 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 set, and skip executing the command after the first loop.

#Fact 4

Deterministic Usage of Resources

A common language feature on which system programming cannot rely on is garbage collection, or even just dynamic allocation for some embedded systems. As embedded applications are very limited in time and memory resources they are often used for real-time systems, where a non-deterministic call to the garbage collector cannot be afforded. And if a dynamic allocation cannot be used because of the lack of memory, it is very important to have other mechanisms of memory management, like placing data in custom addresses, as C pointers allow. Languages that depend heavily on dynamic allocation and garbage collection wouldn’t be a fit for resource-limited systems.



#Fact 5

Code Size

Well, you guessed it right the memory footprint for its code is smaller than for most other languages which make its runtime Small. When compared to C++, for example, a C-generated binary that goes to an embedded device is about half the size of a binary generated by a similar C++ code. One of the main causes of that is exception support.

Exceptions are a great tool added by C++ over C, and, if not triggered and smartly implemented, they have practically no execution time overhead (but at the cost of increasing the code size). The Code Size may vary according to the datatypes used however the size of a data type is machine-dependent and vary from compiler to compiler. However, in programming, there exist situations when we need to know the total bytes a type occupies in memory. To find the exact size of a type in C programming we use sizeof() operator.

sizeof() is a special operator used to find exact size of a type in memory. The sizeof() operator returns an integer i.e. total bytes needed in memory to represent the type or value or expression.
The sizeof() is much used operator by programmers. It is very useful for developing portable programs.


Syntax to use sizeof() operator


sizeof() operators can be used in various ways.

sizeof(type)
sizeof(variable-name)
sizeof(expression)

So this is it guys if you want us to write more on this topic or have any particular query regarding this post you can always comment or feel free to mail us at our official mail also follow us on Instagram and Facebook to receive Latest Updates first.

PEACE!!!

No comments

If you have any doubts, please let us Know.