| General > General Technical Chat |
| How many people code in C these days, and if so, why? |
| << < (7/99) > >> |
| technix:
I do, and I have three reasons for it: 1. Efficiency. C generates little surprising and/or additional code, even if you aren't exactly extremely familiar with your compiler. This allow you to think in terms of assembly instructions and clock cycles for an embedded software project, but you don't have to really mind the minute details like register allocation, ABI and even actual assembly mnemonics. And in the corner case when it arises, you can inline assembler directly. Also C has a tiny runtime, which means code is small and efficient. 2. Portability. For higher level programs I still prefer C over other languages, as it provides excellent portability between various operating systems. My daily driver machine runs macOS on Intel, and some of my projects target Raspberry Pi. As long as I stick to C + POSIX-compliant libc + a few common dependencies like libcurl, libfastcgi and nginx, I can expect my C code, debugged on my macOS workstation, work as designed on the Pi after just a recompile. I can even switch out the compiler if I want (clang on macOS, gcc-9 on Pi.) Don't get me started on C++ as that thing has such a fragile ABI. (There is a reason why Apple now implements the macOS C++ ABI on top of the Objective-C ABI, as that is just more reliable.) 3. Control. C gives me full control of the program flow - no garbage collection throwing timings out of the window, no unexpected initializer calls, no confusing operator overloads, etc. |
| Picuino:
C vs C++ Vim vs Emacs Spaces vs Tabs They are all religious wars. It is very difficult to make arguments without ending arguing personally. |
| IanB:
--- Quote from: Picuino on May 03, 2020, 07:14:43 pm ---They are all religious wars. It is very difficult to make arguments without ending arguing personally. --- End quote --- I think this thread has done a pretty good job of showing otherwise. People here have been able to present clearly articulated reasons for choosing one thing over another. It doesn't have to be a religious war. |
| Picuino:
In that case I will dare to give my opinion. I use C as an amateur programmer of microcontrollers. For 8 bit PIC microcontrollers there are only C compilers and that is enough. I have also used GCC (C++) for embedded code in the Arduino environment. I think C++ has some advantages when it comes to making separate libraries and separating the developer environment from the user environment. I also appreciate the ability to bring variables and methods together into one class. Namespaces and instantiation are also a good ideas. But you are also at risk of making bad software more easily than in C. And you can't use all the C++ capabilities in embedded environments because of all the overhead involved. |
| Kjelt:
--- Quote from: engrguy42 on May 03, 2020, 05:57:36 pm ---I assume when you're dealing with commercial/industrial products you generally want low cost and efficiency, which I assume pushes companies towards lower level languages with fewer frills and memory and hardware requirements and costs. So I imagine C and ASM and the lower level stuff are the go-to languages in those environments. --- End quote --- For the first few companies you are correct. Those sold millions of products and each $cent of the BOM was carefully weighed. The last company sells a few hundred machines a year, the cheapest machine costs more than $15 million, the most expensive more than a hundred million $, still the code is in C and it runs on industrial boards with VxWorks but also on an industrial Linux server. So it is hard to generalize. |
| Navigation |
| Message Index |
| Next page |
| Previous page |