4 ms·
C is a very powerful but very primitive language. Too easy to do all sorts of things you didn't intend. But C was all we had (we didn't even have C++), and we
by lordfrito 3y ago
C is a very powerful but very primitive language. Too easy to do all sorts of things you didn't intend.
But C was all we had (we didn't even have C++), and we had to use it, and use it effectively to deliver production firmware that couldn't change after it was shipped. We used it, and we got good at it, and we loved it. And we hated it because we used it and loved it, and that gave us the right to hate it.
Like my above example, when looking at tight (production, performant) C code, you always ask "did the programmer mean to do that?" or "was the programmer aware of the side effect" etc.
Once I groked LINT, I understood that the comments which appeased LINT were also messages to us humans that the programmer had considered the side effects, etc. and that this was intended behavior.
Made it easier to look at other people's code, heck even my old code, because it told me that "yeah, this was considered". Saved a lot of guess work, and allowed me to look at the meat of the code and not be distracted by the simple error stuff.
Also, as much as I love C, my biggest complaint is that it should have been strongly typed from the very start. C# gets this right. You have to be very explicit about mangling things in C#. In straight C it's just too easy to mix types and mess simple stuff up. The compilers attitude is, "sure.. I'll compile that". I prefer it asking questions and complaining.
- pjmlp 3y agoIn what world? I have been coding since 1986 and there were systems were C wasn't even an option, and others were C was an option among many others, excluding UNIX's early days before it got widespread outside AT&T. Even on embedded, besides Assembly, Forth, BASIC and Pascal have been a companion to C since high level languages are able to target those tiny CPUs. Naturally, I guess there were those systems were the specific vendor only provided a C SDK, which by the end of the MS-DOS days was already rare.
- lordfrito 3y agoYou're taking me too literally. Of course we had assembly, etc. The kind of development we were working on was safety-critical real-time systems. So assembly is too low level, too risky, you want something more structured. But nothing academic, or insanely expensive. BASIC just isn't up for the task? How do you even write an ISR in BASIC anyways? We had to read two sensors and process a bunch of math every 500 usec, which was like 500 cycles. Every cycle count. C was for sure the best choice that fit the bill. Plus, everyone knew it. Many times you didn't even get a fully ansi compliant compiler (try writing C on a PIC micro without a software stack). So, for a while, C ruled in places that mattered. Low cost, performant, and people knew the language. Also, the compilers we used were purchased from small software vendors, and delivered by mail on floppy discs (this is before the internet took off). Like $3000 for the compiler, a big investment for a small company in 1995. This was back before semiconductor companies had low cost dev tools with free IDEs. The tools we had were state of the art, expensive, and powerful for their time. We grew to love them, and learned how to work with them better.