Virtues and Challenges
Become aware of the benefits and limitations of coding in C.
We'll cover the following
Pros and cons of programming in C
Every language has some strong points, but no language is perfect. Let’s see why this is true for C.
Virtues of C language
-
Fast: C is fast. It is a compiled language, close to the machine hardware and doesn’t require any intermediary to interpret each line of code.
-
Portable: Because of its popularity, there exists a compiler for just about any hardware platform out there. This makes it possible to port your code to any platform.
-
Small memory footprint: Its compiled nature, minimal runtime environment, and lack of extensive object-oriented features generally give it a smaller memory footprint compared to languages like C++ and Python.
-
Low-level access: C programmers have direct access to memory and can also access low-level system features as needed. This gives a lot of flexibility and fine-grained control to the programmer.
-
Strong ecosystem: It is one of the older languages. Because of this, it has matured over time. It has a vibrant community, with a strong ecosystem and lots of resources and a combined experience available.
-
Availability of tools: Over time, several tools have been developed to make programming easier. These include various development environments, and compilation, debugging, and optimization tools.
Challenges associated with C
-
Memory management: Memory has to be managed explicitly and a C programmer needs to be mindful of how memory is being used behind the scenes.
-
Minimal runtime checking: As C allows direct access to memory and does not enforce runtime checking, it’s easy to get into trouble when programming in C.
-
Mastering the APIs: The language itself is small but there are many APIs and libraries that must be mastered to become an effective C programmer.
-
The compile-test-debug cycle: There is a compile-test (crash)-debug cycle for each piece of code. Even though the compiled code runs fast, there is a flip side to it as well, since each minor modification requires a time consuming recompilation—unlike interpreted languages like Python.
-
Object-oriented programming: It does not support Object-Oriented Programming.
-
Verbose code: The code is usually much more verbose than in high-level languages like Python.
Now that we have an idea of the strengths and weaknesses of C, it’s time to look at some specific scenarios where it’s preferred over the other languages.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy