105 points · by the_jesus_villa · 4y ago · 111 comments
It is of course useful for a whole bunch of reasons, including being able to figure out "why does this do X?", but that's not really "deeper knowledge", IMO.
I think C lets you think about low-level details of how systems work, strings being arrays of characters with an explicit terminating NUL character, for example. Although again assembly language gives you _real_ lower-level understanding and insights if you use it.
All the low-level languages aiming to replace C basically abandoned this approach, and opted for slices instead (ptr + size pair, used in Rust, Zig, etc.) This has the benefit of easier and faster string manipulation (strlen can be O(1) instead of O(n)), as well as better memory safety (can do bounds checking with the size information). The primary reason we are still using and teaching null terminators is because we still have to live with POSIX/Win32 and many low-level libraries written on this platform.
I "just" want to do X, but instead I need to write a whole bunch of code to handle it all manually. It's useful that this is possible, but a lot of times you don't need it, and some other languages still keep the "common case" easy while still enabling the high-performance stuff C can do.
I wish we had C+: C + a few niceties (and not C ++ everything). There's a whole bunch of newer languages aiming at the space C is sitting in, but with a few additions C could be much more ergonomic without having to invent an entire new language.
C is a something of a high-level assembly language. Of course we could write literal assembly language in C, pretty much.
r1 = 0
r2 = 1
r3 = r1 + r2
mem[1000] = r3I think you can eck out more performance, but the time investment is much more.
It is always "worth it" to understand the machine you are manipulating, and no matter what you think about the C virtuel machine, the very real machine in front of me has been shaped by its relationship to C.
Do you learn how to fly when you book a flight? Do you learn how to build cars when you get your driving license? Do you learn how water is cleaned when you drink? There is infinite regress.
In the end it is about trust and abstractions. Most algorithms have nothing to do with C. They are implemented in C.
C is a great language, but as someone said here, there is only so much time.
I would argue that assembly language and hence C has been shaped that way it has because of the underlying structures of the processor and the way binary numbers are manipulated and stored. C and for that matter assembly, becomes quite trivial if you know enough to make your own simple CPU with decoder, instruction set, memory, ALU, FPU, etc.
> It is always "worth it" to understand the machine you are manipulating
Why is it always worth it? If I want to be a product/creative developer how does learning C specifically help me?
And it wasn't even proper C, it was RatC at the time.
There are plenty of alternatives to expand our brain in systems programming, and even better they show we don't need to compromise on security to do it.
However, yes one needs to learn C, because it has snuck everywhere and as the COBOL of systems programming languages (ruffly 10 years younger), it isn't going anywhere.
Marriage material! :D
(2) She made him an accessory to a crime.
(3) She stole his gift instead of investing actual effort to save up and purchase it.
I know the world will always have its share of thieves and liars, but I’m still always a little taken aback when people are shameless enough to celebrate it.
The bare minimum for “marriage material” would have been putting thought into his gift before his birthday, buying it, wrapping it, and surprising him with it.
1. She turned out not be marriage material
2. Y'all are way too sensitive about a teenage girl who shoplifted one time.
It’s about how you framed and excused your behavior.
> https://download-mirror.savannah.gnu.org/releases/pgubook/Pr...
There is an updated version of the book from the author: "Programming Under the Hood" or "Learn to Program with Assembly". See[0]
I'm not saying its a bad book/guide, but with sections like these:
>Before we go on, why would I even begin to bother pointing out that a pound sign is called an octothorpe? The answer is simple: I think the word octothorpe is so excellently funny, I have to gratuitously spread its name around whenever I get the opportunity. Octothorpe. Octothorpe, octothorpe, octothorpe.
It claims to be aimed at programmers who are already proficient in high-level languages, but spends a whole paragraph explaining what code comments are.
I'm not sure it qualifies as "to the point"
Imagine you wrote a new 3D model file-format and all other language users have to load the Ruby interpreter to use it.
Code of Dishonor
She just didn't care about B&N or property law. Maybe you do care about those things - I'm not condoning theft here!
Now, if you had said Code of "This Chick Turns Out To Be Completely Insane And This Should Have Been A Red Flag" you'd be closer to the mark, but that's for the next post!
If you think a corporation is evil, you don’t have to shop there.
I don't think charging $80 is evil, but it's a high enough price to merit some light teasing. To clarify: I'm just making fun of B&N for charging a lot for a book I wanted. This isn't meant to argue that charging a lot justifies theft.
>If you think a corporation is evil, you don’t have to shop there.
This is a more interesting argument, that has nothing to do with what I said, but is still fun to think about. Surely, if a corporation is evil, a reasonable response would exceed "don't shop there".
That said, please enjoy the upvotes and I wish you all the best, Jebus.
If I switch to a static blog I'll let you know!
The followup edition I think had the C89 draft ANSI standard, and was the beginning of the way way way more wordy era.
That the idea of "learn enough C to survive" is a concern for anyone seems to mean the concise clarity of the original K&R book is long lost?
Someone that doesn't have a good grasp of UB and knowledge of the compiler/machine would be slightly terrifying to let loose in a C codebase.
Interestingly, the description from K&R for the 1988 version (I had both btw) said they tried to maintain the succinct clarity of the 1st edition. :)
No, it’s actually crystal clear.
I guess some people really dislike like lame jokes, though!
But C is not going to disappear, and the huge reams of important code written in it, like the Linux kernel proper, are not going away, too.
But C is so much simpler than Rust, it comes almost free. It does give you an appreciation what really unsafe code is, and why is it so unsafe. It also gives you a better understanding of how the machine works on the lower level.
My impression too. Very unlikely that Linux and BSD kernels will be re-written in Rust.
C is primitive and painful to program in for the most part. However, it's at the core of plenty of important things, so having enough knowledge to get around it is crucial.
C is essentially a portable assembler and it's great for a number of tasks. Rust is a general-purpose programming language and it has a vastly different domain of application. Surely, they overlap, in some domains Rust is overtaking C (where C was used more out of necessity/lack of alternatives rather than consciousness). The point is, though, is that there is a domain (not necessarily very big, but very important) where C will very likely stay for a very very long time. At the same time, Rust is great, but not much critical software is written in Rust (yet). It's likely that there will be such software in the future, but I think the consensus is that nobody knows for sure.
Yes, I agree with the fact that learning C makes us appreciate Rust (and other safer languages) better. It's just that between C and Rust, I would pick Rust. I'm not a systems programmer, but I have worked with C before and as soon as I saw some of Rust's example codes, I liked how it taught me something and liked the design choices. Rust does seem like a nice language.