If you're a software developer who doesn't know C, then there's a whole class of software that you can't read - network programming, operating systems, language tools all written in C. This puts you at an extreme disadvantage imho.
Not sure if I'd agree with extreme disadvantage, perhaps slight. I'd wager most even super competent C programmers rarely to never look under the hood at such things.
That said, to me, while C the language is super simple and easy to write, I always find reading it a chore. Folks using 'clever' hacks, rarely using built in types, lack of nice standard library, and so on, make it a bit of a pain to follow unless you are prepared to invest a non-insignificant amount of time. I rarely dive into such things for this reason...
> Not sure if I'd agree with extreme disadvantage, perhaps slight
I disagree. Without knowledge of C, you're unlikely to have read low-level networking code, for example, which is pretty fundamental to an in-depth understanding of modern software.
I do agree that C can be a pain to read, mostly because of the crazy macros that a lot of production code tends to use.
Fair point. Personally, I learned far more about network programming from Beej's famous guide[1] than any code I dug into. Then again, it's one of those things where you don't know what you don't know. Even so, I think it should be required reading for every programmer!
While I agree that knowing C is relevant, from culture point of view, to be able to use libraries written in C, and specially to be aware of its flaws and when to use something better instead.
Writing low level networking code does not require C per se, I have done it in several other languages, and given that the causes for the Morris worm remain in the language, ideally one should use something else.
> Writing low level networking code does not require C per se,
Of course it doesn’t. I mentioned using Python to write low-level networking code above (it was painful for someone used to C). I’ve also used Lua for it (better than Python).
And as I recall, you’re a fan of Ada and Rust, both of which I have used to write low-level networking code (packet parsers, network protocols, and whatnot).
That said, those languages are not typically a well-traveled entry-point into low-level network coding. C is. I’d be as happy as the next guy on HN if we all just moved to Rust, but that’s not in the cards at the moment.
What are you thinking of when you say "low-level networking code"? Because if you mean socket-API, I'd disagree, the C version doesn't teach much its bindings in higher-level languages (which often mirror it quite closely anyways) necessarily wouldn't, even if the languages also offer more abstracted APIs on top.
I'm thinking about network protocols and binary packets, specifically. To me, that stuff is pretty important to have a grasp of. It's very awkward to do packet parsing and generation in Python, for example (I've done it).
Even working in front-end dev now, I benefit from understanding what's driving HTTP and WebSocket (High-Performance Browser Networking is also a great book for understanding this stuff).
I feel like C and bash scripting are the last big chunks of fundamental knowledge I want to master. I think I'm more proficient with C only because it's basically Java + pointers - OOP and Java is my main professional language.
Agree, yet C is definitely a bad language to start.
I knew a bunch of people who started with C and used to use inappropriate data structures and algorithms all the way because writing your own Tree-like or recursive data structure in C is damn hard. So they ended up using arrays or something like this all the way instead.
It's better to start with a language which let to create and use any data structures without tensions. SML, OCaml, scheme, even Java is better than C in this regard.
A stupid example is that all other things being equal you likely will be even on your success on Tinder.
Another stupid example. If you're learning to play hockey, then the person learning C would be at a severe disadvantage to the person practicing hockey.
If you're the technical co-founder of a lean but fast moving startup then you'll likely be better off writing code than to learn C unless your product really needs to be written in C. That person might also be better off putting that time into interviewing, helping with sales or anything else which provides immediate feedback.
Sorry for the dumb examples, but I see this as an issue all the time. We have limited hours in the day. Often people get sidetracked on similar distractions. Premature optimization is one often discussed example. There are endless more. We all have that friend who seems to get hopelessly bogged down in details before doing anything and ultimately giving up.
I started the paragraph with "If you're a software developer who doesn't know C", so "This puts you at an extreme disadvantage to software developers who do know C imho"
Responding to the title: Not really, no. Neither is C necessarily a great starting point, nor does knowing C necessarily help you being good at other languages etc.
I'm not saying learning C isn't useful, but it's far from a necessity and learning other things early can be more effective.
The article itself doesn't really contain the claim the title makes, but also doesn't back it up very much, just some fairly generic "C is low-level" points.
I understand what you're trying to say as I am living proof that you can still be a successful programmer without starting with C.
But I should at least mention that learning C and tinkering with system / network programming helped me improve my understanding of higher level languages in a way I didn't think was conceivable.
Learning about and dealing with memory management, system calls, how code is compiled and translated into machine code etc can be boring and repetitive if you do it long enough but is I believe an essential component of becoming a wiser/better programmer (at least in my experience).
C (or something very like it) is effectively the core of my mental VM. It's an extremely useful mental abstraction even though all I write is C++, JS, Python, and GLSL.
Being able to estimate "what does this code compile into" is extremely powerful for understanding code, as well as exploring the possibility space of solutions. ("Is it even possible to express this?")
It's not an exact mapping to hardware, but it's such a useful level of abstraction to have on tap, even if I never want to write it directly.
Agreed. I spent 10 years writing C in the 90s but very little since. Even still, I find my understanding of eg Go is based on what is being allocated where, compared to colleagues from eg Java or JS, who have never dealt with that, and who focus on syntax and features.
One was raving about slices, which are a struct of ptr + length built into the syntax. Obvious with a C background.
I think C is useful and cool, but I strongly disagree with the final sentence of the post. I think it's a terrible language for beginners. I think it's a good language for proficient coders who want to get to the next level.
If you have a niece or nephew who likes computers and comes to you about it and you try to foist The C Programming Language on them, you will have done them a terrible disservice. 90% of people will find using Python and it's friendly packages for everything to be so much more delightful than C.
This is sort of a 'turtles all the way down' sort of issue. You could also say:
> Learn assembly and the rest will come
> Learn binary and the rest will come
> Learn the fundamentals of electricity and the rest will
come
...
I think learning the layers below which you typically operate can be beneficial; however, I think the patterns and ideas ( semaphores, scheduling, etc. ) are probably the most beneficial part of an exercise like this -- not the actual C language.
I think that's a good idea. C is a fantastic second language to learn in order to know what's happening in the background, but for a total beginner it can be needlessly frustrating.
- Some APIs only support C. On other languages, you can use 3rd party bindings, or use a C interoperability library/API, but this may have a performance overhead, and it may not abstract you from C types.
- Some industries mostly use C, or languages similar to C.
- Some software has real-time requirements. A garbage collector can introduce non-deterministic delays.
- Some software needs fine-grained control over memory management and have a predictable memory layout of data.
- Some software needs a low performance overhead, e.g.: when you run your software on low spec hardware/embedded devices, or you need to save power on a battery-powered device, or make the most out of current hardware.
Finally, the choice of C doesn't mean you only have to use C. C can interoperate with other languages when they offer a C API.
Manipulating a string can be a complex operation in terms of memory and CPU instruction.
For systems programming you don't want to hide that complexity.
e.g in Rust you `a+b` two strings, it is a trivial rust line but it won't compile down to trivial assembly.
There's a case to be made for languages that closely map the way processors works, like C.
Though C doesn't closely map to the way processors work. It closely maps to the way the PDP11 worked, but for modern processors it's pretty far. It doesn't expose any of the ideas of caching, for example.
36 comments
[ 4.0 ms ] story [ 72.5 ms ] threadThat said, to me, while C the language is super simple and easy to write, I always find reading it a chore. Folks using 'clever' hacks, rarely using built in types, lack of nice standard library, and so on, make it a bit of a pain to follow unless you are prepared to invest a non-insignificant amount of time. I rarely dive into such things for this reason...
https://stackoverflow.com/questions/652788/what-is-the-worst...
I disagree. Without knowledge of C, you're unlikely to have read low-level networking code, for example, which is pretty fundamental to an in-depth understanding of modern software.
I do agree that C can be a pain to read, mostly because of the crazy macros that a lot of production code tends to use.
[1]: https://beej.us/guide/bgnet/html/
Another classic requiring C is "Unix Programming Environment" by Kernighan and Pike (old C, but still).
Writing low level networking code does not require C per se, I have done it in several other languages, and given that the causes for the Morris worm remain in the language, ideally one should use something else.
Of course it doesn’t. I mentioned using Python to write low-level networking code above (it was painful for someone used to C). I’ve also used Lua for it (better than Python).
And as I recall, you’re a fan of Ada and Rust, both of which I have used to write low-level networking code (packet parsers, network protocols, and whatnot).
That said, those languages are not typically a well-traveled entry-point into low-level network coding. C is. I’d be as happy as the next guy on HN if we all just moved to Rust, but that’s not in the cards at the moment.
Even working in front-end dev now, I benefit from understanding what's driving HTTP and WebSocket (High-Performance Browser Networking is also a great book for understanding this stuff).
I knew a bunch of people who started with C and used to use inappropriate data structures and algorithms all the way because writing your own Tree-like or recursive data structure in C is damn hard. So they ended up using arrays or something like this all the way instead.
It's better to start with a language which let to create and use any data structures without tensions. SML, OCaml, scheme, even Java is better than C in this regard.
A stupid example is that all other things being equal you likely will be even on your success on Tinder.
Another stupid example. If you're learning to play hockey, then the person learning C would be at a severe disadvantage to the person practicing hockey.
If you're the technical co-founder of a lean but fast moving startup then you'll likely be better off writing code than to learn C unless your product really needs to be written in C. That person might also be better off putting that time into interviewing, helping with sales or anything else which provides immediate feedback.
Sorry for the dumb examples, but I see this as an issue all the time. We have limited hours in the day. Often people get sidetracked on similar distractions. Premature optimization is one often discussed example. There are endless more. We all have that friend who seems to get hopelessly bogged down in details before doing anything and ultimately giving up.
I'm not saying learning C isn't useful, but it's far from a necessity and learning other things early can be more effective.
The article itself doesn't really contain the claim the title makes, but also doesn't back it up very much, just some fairly generic "C is low-level" points.
But I should at least mention that learning C and tinkering with system / network programming helped me improve my understanding of higher level languages in a way I didn't think was conceivable.
Learning about and dealing with memory management, system calls, how code is compiled and translated into machine code etc can be boring and repetitive if you do it long enough but is I believe an essential component of becoming a wiser/better programmer (at least in my experience).
I'd say if you are just a hobbyist programmer, learning C is probably not always a necessary. Go/Python/Pascal/Java etc is fine.
Once you are interested in poking Linux internals, obviously this is where your C knowledge is needed.
Being able to estimate "what does this code compile into" is extremely powerful for understanding code, as well as exploring the possibility space of solutions. ("Is it even possible to express this?")
It's not an exact mapping to hardware, but it's such a useful level of abstraction to have on tap, even if I never want to write it directly.
One was raving about slices, which are a struct of ptr + length built into the syntax. Obvious with a C background.
If you have a niece or nephew who likes computers and comes to you about it and you try to foist The C Programming Language on them, you will have done them a terrible disservice. 90% of people will find using Python and it's friendly packages for everything to be so much more delightful than C.
Yeah, I concur:
https://news.ycombinator.com/item?id=22008971
> Learn assembly and the rest will come
> Learn binary and the rest will come
> Learn the fundamentals of electricity and the rest will come
...
I think learning the layers below which you typically operate can be beneficial; however, I think the patterns and ideas ( semaphores, scheduling, etc. ) are probably the most beneficial part of an exercise like this -- not the actual C language.
https://www.google.com/search?client=firefox-b-d&q=rust+ardu...
- Some APIs only support C. On other languages, you can use 3rd party bindings, or use a C interoperability library/API, but this may have a performance overhead, and it may not abstract you from C types.
- Some industries mostly use C, or languages similar to C.
- Some software has real-time requirements. A garbage collector can introduce non-deterministic delays.
- Some software needs fine-grained control over memory management and have a predictable memory layout of data.
- Some software needs a low performance overhead, e.g.: when you run your software on low spec hardware/embedded devices, or you need to save power on a battery-powered device, or make the most out of current hardware.
Finally, the choice of C doesn't mean you only have to use C. C can interoperate with other languages when they offer a C API.
I got stuck at some elementary string manipulations.
So I said, forget this. I pulled out Python, and solved it in a few minutes.
This proved to me, that while C has its place, it just does not meet the programmer productivity of other more modern languages.
Nevertheless, we need a modern replacement for C. But honestly, I just don't think Rust is it.
e.g in Rust you `a+b` two strings, it is a trivial rust line but it won't compile down to trivial assembly.
There's a case to be made for languages that closely map the way processors works, like C.
https://www.youtube.com/watch?v=Ye8mB6VsUHw