4 ms·
I value learning new languages, especially as I have yet to find a very good one. Some are pure and beautiful like Scheme, but if you asked me what single langu
by jll29 4y ago
I value learning new languages, especially as I have yet to find a very good one.
Some are pure and beautiful like Scheme, but if you asked me what single language I would take to a lonely island with me where I was stranded, it would still have to be C.
To those here who would like to have some guidance diving into other languages I can recommend these two books:
Bruce Tate: Seven Languages in Seven Weeks
https://www.amazon.com/Seven-Languages-Weeks-Programming-Programmers/dp/193435659X https://www.amazon.com/Seven-Languages-Weeks-Programming-Pro...
Bruce Tate: Seven More Languages in Seven Weeks
https://www.amazon.com/Seven-More-Languages-Weeks-Shaping/dp/1941222153 https://www.amazon.com/Seven-More-Languages-Weeks-Shaping/dp...
You can work through them in <4 months, and then we can talk again whether you found it useful (I did).
- tonmoy 4y agoOther than the fact that C can be run on basically any device on earth, and the super rich history behind it, does C as a language have any benefits? I personally don’t find C more ergonomic, expressive or beautiful compared to any other language.
- habibur 4y agoPointers. Nearer to the core. In assembly it's all pointers, pointers and pointers. C having better support for pointers makes it nearer to how the processor works, compared to other languages.
- dunefox 4y agoC is very far removed from the CPUs of the last few decades.
- hmfrh 4y ago> C having better support for pointers make it near to how the processor works, compared to other languages. Java is almost entirely pointers to heap allocations, yet I don't think anyone would argue that Java is close to how the processor works. I also don't think that the C virtual machine is all that close to how machines actually work any more.
- anthomtb 4y agoC has a virtual machine? Do tell more.
- hmfrh 4y agoIt appears to also be called the "abstract machine"[1]. C semantics do not work "directly on the hardware" but instead on an abstract machine that is then converted to the actual hardware. It most often comes up when talking about undefined behavior and pointer behavior. Some assorted reading, mostly in the context of Rust and C: https://blog.regehr.org/archives/213 https://blog.regehr.org/archives/213 https://raphlinus.github.io/programming/rust/2018/08/17/undefined-behavior.html https://raphlinus.github.io/programming/rust/2018/08/17/unde... https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html https://www.ralfj.de/blog/2017/06/06/MIR-semantics.html https://www.ralfj.de/blog/2017/06/06/MIR-semantics.html [1]: https://stackoverflow.com/questions/53100198/what-is-the-precise-relationship-between-c-and-its-abstract-machine https://stackoverflow.com/questions/53100198/what-is-the-pre...
- habibur 4y agoTo be fair, Assembly once worked directly on the hardware. On modern machines it doesn't.
- whimsicalism 4y agoI don't think it is fair to conflate the "abstract machine" of C with the virtual machine. There is no software virtualization at work when running C code, it is compiled directly to assembly.
- nlnn 4y agoI found it useful to learn just because there's so much existing code that's been written in it. Means I can at least dig through some old codebases and understand what's going on. Lots of higher level languages also have C bindings, so at least a couple of times in my career I've ended up writing short C modules for speed critical bits of code. The pain of manual memory management also gave me much more of an appreciation of its pitfalls and alternatives.
- optymizer 4y agoC is not meant to be a beautiful language. C is meant to write programs that run as fast as possible on any CPU. The beauty of C comes from being able to tame the hardware and OS complexity to get the most speed, not from taming the complexity of the software architecture or abstract design. If I had to pick one language to code in for the rest of my life, it would be C.
- gradschool 4y agoC gets out of your way and lets you do your job without buying into a lot leaky abstractions and without going to annual C conferences. C doesn't argue with you about whether something is a number or an array of bits. C is blazingly fast compared to most alternatives. C enables you to detect and handle heap overflow errors without panicking or crashing (just in case your memory is finite).
- marcosdumay 4y agoC used to have a close to bare metal semantics, and on some environments¹ still have it. So if you need low level semantics, it normally beats assembly on those environments. The Rust people are working hard to support everything that C does, so in the future C and asm will probably not have a monopoly there. But this is still not our reality. 1 - Of course, not a PC software stack, and not on any ARM available today.
- Stamp01 4y agoThe first book is my all-time favorite programming book. I was disappointed by the second one, though. It didn't hold the same charm and wonder as the original.