I recently read that C is easy to pick up and extremely difficult to master.
I was like what?
Is it really easy to pick up?
I feel like I would like to get some hands on C to better feel in linux and to be able to optimize python stuff, so that I could if need be do some C code with true multithreading without global interpreter lock
Anyway, is C really easy to pick up?
C is really precise. Memory allocation is done by the programmer, types are static. For string processing this is a nightmare, for heavy computation it's great. For multithreading you've got a few choices.
First one is Pthreads, which is basically the straight up implementation of POSIX threads. You include a library, you've got your standard fork/join and lock/synchronization stuff.
There's also OpenMP, which is fucking awesome: it's a number of compiler directives which you add to your code, which automatically gets converted into the dirty stuff. Let's say we have an array, and we do an independent operation on every element of the array using a for loop: just add "#pragma omp parallel for", compile with -fopenmp and your shit is parallel. Let's say we want to sum it together instead into a variable called result, then we do "#pragma omp parallel for reduction (+:result)", and bam, shit is done. Have multiple tasks to do? Wrap each of them in a block with "#pragma omp section" at the top, wrap that in a block with "#pragma omp parallel sections" and your shit is done. OpenMP makes parallelizing computational code a lot easier, and is especially great when parallellizing existing single-threaded code (because shoving pthreads into existing code is ugly as fuck). Picture related, OpenMP is comfy.
If you want to go big and run it on a cluster of computers, look into MPI. It's a system which allows you to run a program on multiple computers and pass messages and data between them. It has all the synchronization stuff (no shared data though, you need to send that shit over). It's a bitch to work with, it sees every CPU as a seperate computer (although I've seen it being used in combination with OpenMP), but fuck it, doing shit on clusters is fast as fuck.
Boost (which is C++, not C by the way) is nice, it has more nice stuff like thread grouping, and using futures/promises to pass data is a really clever language feature. The basic idea is the same as POSIX threads though: fork threads which each execute a certain function, have some basic stuff for locking/synchronization/data protection (mutexes/locks/barriers), have some work sharing constructs (queues,doing stuff based on thread id).
Tbh I don't use Boost often. I work in IT at my university on the team that helps scientists prepare their programs to run in parallel on our cluster (150-something nodes, each 24 cores) and I usually do the C stuff, not C++.
C and Lisp are very easy to pick up and moderately easy to master because of their non-bloated core languages, but they're both tedious to work with and maintain since every useful pattern is ad-hoc boilerplate.
"bloated" languages internalize more occasionally useful functionality at the cost of taking longer to learn and making abuse of language features (including actual bloat) much easier.
Yes, you can write something as big and complex as the Linux kernel in C, but it takes countless hours to familiarize yourself with all the bullshit naming conventions, preprocessor macros, etc. when trying to read through an existing codebase like that.
>Anyway, is C really easy to pick up?
Because of your Python background this (fully free) book makes it easy http://c.learncodethehardway.org/book/
Think of learning C from a Python background like learning Latin when you know Spanish