Essential C
cslibrary.stanford.edu
cslibrary.stanford.edu
Modern C [1] covers C11 and was mentioned before. However, it weighs in at 300 pages rather than Essential C's 45.
[1] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf
Actually, reading through Essential C, it hasn't really been updated for C99 since it uses C89 declarations:
C takes the middle road -- variables may be declared
within the body of a function, but they must follow a
'{'. More modern languages like Java and C++ allow you
to declare variables on any line, which is handy.Meanwhile, in terms of C11 [update: actually also from C99] I actually wrote a function with a signature like
void func(int arg[static 3]);
but later removed it because (a) the generated code was the same, and (b) rather than increasing clarity and self-documentation, it caused confusion; even when you're familiar with the feature, it never stops looking like a syntax error.They have changed their view regarding C, but the actual work is customer driven.
https://www.reddit.com/r/cpp/comments/75q5wc/visual_studio_2...
I mainly still stick to variable declaration at the beginning of the block out of habit but it would be a pain for me to go back to C89 and forsake all these other nice features.
For essential features, well if one uses C it's usually to have fine-graded control of memory use and allocation patterns. Then C11 _Alignas, and _Alignof are pretty essential. Yes you can do that with platform/compiler specific macros without C11, but it's nice to be able to avoid that.
They now advise to use clang directly, since its Windows support has been improved.
Maybe I'm just a grumpy old programmer, but I feel like kids these days are missing out on something important by learning to program in a language that doesn't require them to truly grok memory management.
I recently ran into someone that was teaching a Python boot camp and they were forcing the students to use VIM instead of PyCharm, and in their words, "using a text editor requires them to memorize apis".
They didn't know about type inference, rename, extract method or navigate to declaration. I view it as the same bias, the attitude doesn't encourage people to use the best tools for the job because we suffered in the past. How about we go back in time and teach young selves how to write code than actually use 2TB of main memory and 128 cores using a dev environment that can scale to millions of lines of code.
And that is what I think beginners should be introduced to - how to write code, how to frame algorithms in your mind and convert them into lucid code. Python does all of this wonderfully. It hides all of the internal details and exposes just the part that is needed for sometime writing a computer program for the first time in their life - simple statements which do simple things.
There is no need for a beginner to understand memory management at all. Trying to understand what is code or how algorithms work is more important to build that mental capacity IMO. Pardon me, but it does seem that just because you had to undergo the pain of trying to understand pointers, memory layout and allocations, you want everyone to go through the same experience as well.
Is there something similar to this for C++? I understand that C++ is a much larger language and I'm definitely not looking for something comprehensive, more of a solid overview of a workable subset of the language. Enough to be productive, produce reasonably modern idiomatic code that can be improved or expanded in the future.
In the end, the graduate course ended up using Python, but I'm still somewhat curious about modern C++.
"Effective C++" by Scott Myers
https://www.amazon.com/Advanced-C-Programming-Styles-Idioms/...
Also, consider looking into MISRA C guidelines. They contain many related tips.
https://www.amazon.com/Expert-Programming-Peter-van-Linden/d...
Every C programmer should have this on their bookshelf!
"the compiler "promotes" the smaller type to be the same size as the larger type before combining the values." Values smaller than int are always promoted to int.
"Promotions do not lose information -- they always convert from a type to compatible, larger type to avoid losing information." This isn't true when a signed type is promoted to unsigned.
It seems that the author didn't read the C language specification.
If you're looking for a challenge, a JSON parser is a more involved project, especially if you implement your own HashTable structure for storing things.
If you want something to be proud of at the end, then you could always try your hand at glitch art. Grab an image file, read it, manipulate it, and output it again.
[0] https://www.edx.org/course/introduction-computer-science-har...
Also C unit testing is often rare. I ended up writing my own framework (which I open sourced, but am neglectful with maintenace) with the idea you can run tests on embedded devices. Meaning it only relies on pretty vanilla C and has no memory allocation.
But, definitely incorporate unit testing in your C coding experience. It will help focus you on not falling for the evils of the language
It is a very good book and it should be easily available.
I'm planning on attempting to read it again after I finish Harvard's CS50. Maybe I just need a lot of hand-holding, but this course seems to do a much better job of explaining concepts.
Yes, to be honest, C is not good as a "first" programming language. If i can give you a suggestion, it would be: Start learning Python, which is a good "first language to learn", and then try this book.
You will find that jumping from Python to C there will be two strong differences:
a) C is a statically typed language, so you will need to declare (specify) the type of each variable you would like to use.
b) In Python, the language manages your usage of the computer's memory. In C, you manage the memory... After some CS courses you'll probably be familiar with concepts like "linked lists", which then you can try implementing in C by using pointers. Thus, you'll realize that in C you are in control of the computer's memory; you will be able to request (allocate, with malloc) blocks of memory and free them afterwards.
c) C syntax can be tricky, compared to Python.
Working your way through it after taking CS50 is actually a fantastic idea.