re: Java is NOT EASY to learn. But still worth :) VIEW POST

re: 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:

  1. Pointer / array syntax and semantics are difficult to understand.
  2. Lack of variable initialisation to safe values e.g. zeroes.
  3. The ability to write all over memory.
  4. 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.
  5. Dynamic memory allocation - the memory must be allocated and freed. This comes for free in other languages, and increase the complexity of C code.
  6. Null terminator character instead of length / array representation for strings.
  7. C requires more lines of code to do some things than other languages e.g. implement a simple linked list.
  8. Lack of a namespace to organise source code.
  9. 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.

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.

Code of Conduct Report abuse