Hi, I'm Swastik Baranwal, a software developer from New Delhi, India passionate about open-source contribution, Gopher, Pythoneer, Compiler Design and DevOps.
If you say "C is nightmare" there probably is some mistake.
C is quite simple language originating from 1970. C++ is it's extension from mid-1990s, with OOP, templates and (in recent standards) it have become really difficult to learn just because it has tons of features, many of which are legacy.
C++, Java, C# and Objective-C - they all are decendants of old simple C in some way.
Hi, I'm Swastik Baranwal, a software developer from New Delhi, India passionate about open-source contribution, Gopher, Pythoneer, Compiler Design and DevOps.
C is easy enough to learn, but issues such as the following make it difficult to master:
Pointer / array syntax and semantics are difficult to understand.
Lack of variable initialisation to safe values e.g. zeroes.
The ability to write all over memory.
Doing things that otherwise would cause fast failure in other languages may result in a program that runs and works, or fails in unexpected ways.
Dynamic memory allocation - the memory must be allocated and freed. This comes for free in other languages, and increase the complexity of C code.
Null terminator character instead of length / array representation for strings.
C requires more lines of code to do some things than other languages e.g. implement a simple linked list.
Lack of a namespace to organise source code.
Portability issues - possibility of different results on different hardware even if code works correctly e.g. due to different int sizes.
I say this as somebody who's programmed C for many years, and still do. In my university placement year, I was given a copy of "Kernighan & Ritchie" to learn C in my first week.
Hi, I'm Swastik Baranwal, a software developer from New Delhi, India passionate about open-source contribution, Gopher, Pythoneer, Compiler Design and DevOps.
Differerent classes of languages have their own subtleties so take time to learn. For example, I'd personally really need to think about how to write a prime sieve in a functional programming language.
It's surprising that some developers, even with quite a lot of C programming experience, program without giving sufficient thought to things I've listed above e.g. a new struct is defined, code is written to allocate memory for the structure and fields within it, but with no clean-up strategy in the (admittedly rare) case that memory allocation fails.
I've seen this on projects where a developer is programming in other languages e.g. Java alongside C.
Hi, I'm Swastik Baranwal, a software developer from New Delhi, India passionate about open-source contribution, Gopher, Pythoneer, Compiler Design and DevOps.
What you mean by that?
If you say "C is nightmare" there probably is some mistake.
C is quite simple language originating from 1970. C++ is it's extension from mid-1990s, with OOP, templates and (in recent standards) it have become really difficult to learn just because it has tons of features, many of which are legacy.
C++, Java, C# and Objective-C - they all are decendants of old simple C in some way.
Most people don't find it simple.
I agree C is small and simple.
C is easy enough to learn, but issues such as the following make it difficult to master:
I say this as somebody who's programmed C for many years, and still do. In my university placement year, I was given a copy of "Kernighan & Ritchie" to learn C in my first week.
Agreed but if you understood all these concepts then you will be able to understand any language.
Differerent classes of languages have their own subtleties so take time to learn. For example, I'd personally really need to think about how to write a prime sieve in a functional programming language.
It's surprising that some developers, even with quite a lot of C programming experience, program without giving sufficient thought to things I've listed above e.g. a new struct is defined, code is written to allocate memory for the structure and fields within it, but with no clean-up strategy in the (admittedly rare) case that memory allocation fails.
I've seen this on projects where a developer is programming in other languages e.g. Java alongside C.
It's because they are used to newer languages which cleans up everything for them.
Even with Java care has to be taken so that the garbage collector thinks it can actually release an object when it goes out of scope.