5 ms·
> Another is that it's small and fits in your head. I know this is a common view, but I want to highlight some counterexamples: - C programmers need to learn
by oconnor663 5y ago
> Another is that it's small and fits in your head.
I know this is a common view, but I want to highlight some counterexamples:
- C programmers need to learn about many different forms of UB: https://blog.regehr.org/archives/1520 https://blog.regehr.org/archives/1520. Most take years to learn these rules. Many never learn them.
- Most real world C programs use some nonstandard language extensions on some target platforms. C learners trying to read production code have to navigate these.
- The C compilation and linking model is complicated and platform dependent. Compilation is a major stumbling block for students who have to learn Make or CMake at the same time they learn C.
There is some truth to the "C is simple" idea, I'll grant that. It's obviously simpler than C++. But I think there's a big effect where we tend to forget how hard it was to learn, because we learned it so long ago. There's also been substantial progress since the 70's on designing simpler programming languages.
- Zababa 5y agoThat's a good point. I personally don't share this view, and it's also not something I look for in a language. But people using C currently seem to be very attached to this, and knowing how to connect to your audiance is important.
- surajs 5y agoA reduced feature/keyword set does not a simple language make. C is smaller, but definitely not simpler. Also definition of simplicity is context dependent, I would say in many scenarios C++ turns out to be the simpler choice.
- alfiedotwtf 5y agoThanks! This is probably the first time I've heard C called not a small language. Perl was my main language for over a decade, and when I wanted to go lower, I honestly struggled... but not with the language itself, with the peripherals which are exactly what you described!
- SAI_Peregrinus 5y agoC is small, but it's not simple or easy to get right.
- pjmlp 5y agoDepends on how much compiler extensions across multiple compilers one wants to be knowledgeable on.
- alerighi 5y agoC is not a difficult language. I know a lot of electronic engineers that know how to program in C but don't know a thing about informatics, for example what is DNS, or what is JSON, or how to access a FTP server, and things like that. But they know how to program their microcontrollers in C. > C programmers need to learn about many different forms of UB: https://blog.regehr.org/archives/1520 https://blog.regehr.org/archives/1520. Most take years to learn these rules. Many never learn them. UB really don't care that much in real life. When you are targeting a particular platform, that for most C programmer is some sort of 8/32 bit microcontroller, the only thing you care is the datasheet of the microcontroller. Of course you do things that in general are undefined behavior, but in the particular case lead to a perfectly predictable result. In reality you only have to care about UB if your goal is to share code between hardware platform. But let's be realistic, most of the time you don't. Even if you do, some UB are these days standardized, for example integer overflow is UB, in practice you know that on every architecture 2 complement arithmetic is used and thus is well defined. The real problem is that compiler for a misinterpretation for the standard started treating UB as "you are allowed to do whatever stupid thing you want since the condition will never happen", that is the real problem. In reality if you compile without optimization and with flags that avoid this stupid decisions it's not a problem. > Most real world C programs use some nonstandard language extensions on some target platforms. C learners trying to read production code have to navigate these. Again, it's a problem only if you are targeting different hardware platforms. But if you only program on ST microcontrollers (for example) why should you care? And you must use them in some situations, for example in C there is not a way to control how a struct is packed (to decode efficiently data from a serial connection for example you define a packed structure and access individual fields). Or inline assembly is not in the standard (what if you need to use an instruction of the microcontroller that is not exposed by the C library?). > The C compilation and linking model is complicated and platform dependent. Compilation is a major stumbling block for students who have to learn Make or CMake at the same time they learn C. It's. But most of the time you stuck on whatever the development environment for the target hardware platform is setup to. Most C programmers doesn't even know what CMake or Make is, I care about it and do things by hand, most other people use IAR or Keil or whatever proprietary software that integrates compiler, build system and IDE.
- 5y ago