Author Topic: How many people code in C these days, and if so, why?  (Read 40022 times)

0 Members and 1 Guest are viewing this topic.

Online IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #25 on: May 03, 2020, 05:54:15 pm »
And yeah, I have lots of fond memories of Fortran  :D

Are there still compilers available for that?? Hmm.......

Yup. We still maintain Fortran code at work.

There was a time when Fortran compilers could do better optimizations and produce faster code than C compilers. It may still be the case sometimes for all I know. I think there is still an arms race going on between the compiler writers.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: How many people code in C these days, and if so, why?
« Reply #26 on: May 03, 2020, 05:55:57 pm »
By the way, ever tried reprogramming 300Mlocs of C code that is tested and prooven over 25 years, and then start all over in another language?
How many thousands of SW engineers and hundreds of millions of $ would that cost ?
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #27 on: May 03, 2020, 05:57:36 pm »
If you do write in C these days, what is the reason? Is it because there is no C++ compiler for your target hardware, or are there special advantages to C that make you prefer it?
I graduated in the 90s became an EE , since then had 12 SW jobs with 5 companies and I solely have written C and now for the testing some Python.
First companies the target was 64kB upto 1MB with 100-200klocs
Last company is 650+MB code, est. 300+Mlocs and growing, I luckily only work wit 20Mlocs of that, and still everything except the unittests and other tests is in C.

Why? Because the companies use it and want it and it still is the defacto standard for serious industrial machines and real time hardware. If you program GUIs or games or internet stores, websites etc. choose something more appropriate for that.

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.
- The best engineers know enough to realize they don't know nuthin'...
- Those who agree with you can do no wrong. Those who disagree can do no right.
- I'm always amazed at how many people "already knew that" after you explain it to them in detail...
 

Online IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #28 on: May 03, 2020, 05:58:18 pm »
Why? Because the companies use it and want it and it still is the defacto standard for serious industrial machines and real time hardware. If you program GUIs or games or internet stores, websites etc. choose something more appropriate for that.

I think there is a large space for industrial and scientific software between those two extremes. For instance, would you rather write a Spice circuit simulator in C or C++?
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #29 on: May 03, 2020, 06:19:50 pm »
Why? Because the companies use it and want it and it still is the defacto standard for serious industrial machines and real time hardware. If you program GUIs or games or internet stores, websites etc. choose something more appropriate for that.

I think there is a large space for industrial and scientific software between those two extremes. For instance, would you rather write a Spice circuit simulator in C or C++?

I don't think it's an either/or proposition necessarily. I can imagine writing the GUI for a Spice simulator in C# since it's so quick and easy, but for the core simulation stuff you might want to write it in the most optimizable and fast language (maybe on that has ready access to pertinent math libraries) needed for the actual timestep simulation stuff. And if you're writing it for specific hardware to speed up simulations (like a GPU, for example) that adds another consideration, depending on the best API for that hardware.
- The best engineers know enough to realize they don't know nuthin'...
- Those who agree with you can do no wrong. Those who disagree can do no right.
- I'm always amazed at how many people "already knew that" after you explain it to them in detail...
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: How many people code in C these days, and if so, why?
« Reply #30 on: May 03, 2020, 06:33:43 pm »
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.
 

Offline Picuino

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Re: How many people code in C these days, and if so, why?
« Reply #31 on: May 03, 2020, 07:14:43 pm »
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.
 

Online IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #32 on: May 03, 2020, 07:52:38 pm »
They are all religious wars. It is very difficult to make arguments without ending arguing personally.

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.
 
The following users thanked this post: Siwastaja, Ampera, SiliconWizard

Offline Picuino

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: 00
    • Picuino web
Re: How many people code in C these days, and if so, why?
« Reply #33 on: May 03, 2020, 08:25:04 pm »
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.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: How many people code in C these days, and if so, why?
« Reply #34 on: May 03, 2020, 09:08:54 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.
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.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 6460
  • Country: nl
Re: How many people code in C these days, and if so, why?
« Reply #35 on: May 03, 2020, 09:12:31 pm »
I think there is a large space for industrial and scientific software between those two extremes. For instance, would you rather write a Spice circuit simulator in C or C++?
I rather would write that in an OS independent language like Python I guess, more customers. But that is not my field of expertise. And I hate that Python is runtime not compile time.

I always stayed close to the hardware, HSI stuff, electronic driver software , motion control, that kind of stuff.

I have nothing against C++ or C# by the way , I takeover good habits like the setters and getters you can use that in C also. I don't see the added value of inheritance outside environments like guis like windows where it is the basic way of doing things.

Oh well we all row with what the boss has used in the past.
« Last Edit: May 03, 2020, 09:30:47 pm by Kjelt »
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8637
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #36 on: May 03, 2020, 09:28:18 pm »
For instance, would you rather write a Spice circuit simulator in C or C++?
We know what Spice was written in. Versions 1 and 2 were in Fortran. Version 3 was released in 1989 in C, but its not clear when development began. C++ compilers were getting common by 1989, but might not have been common when development began. So, it not clear if they freely chose C over C++, or they were constrained. Until the mid 90s there were certainly strong reasons one might want to avoid C++, as it kept changing. Many new compiler releases broke existing code. So, for timing reasons Spice might not be the best candidate for looking at whether people choose C or C++.
 

Offline splin

  • Frequent Contributor
  • **
  • Posts: 999
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #37 on: May 03, 2020, 11:54:46 pm »
C++ might be better described as a metamorphic (ok, that might only apply to rocks - perhaps it should be 'subject to regular metamorphosis') than OO language. I might eventually manage to get my C++ code from the late 90's past the syntax checker of the latest revision compiler but semantically who knows what it would actually do?

When the language evolves faster than your ability to learn the changes you know it's time to abandon ship and settle back into your comfort zone with straight C, warts and all.
 

Online IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 11858
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #38 on: May 04, 2020, 12:18:24 am »
We know what Spice was written in. Versions 1 and 2 were in Fortran. Version 3 was released in 1989 in C, but its not clear when development began. C++ compilers were getting common by 1989, but might not have been common when development began. So, it not clear if they freely chose C over C++, or they were constrained. Until the mid 90s there were certainly strong reasons one might want to avoid C++, as it kept changing. Many new compiler releases broke existing code. So, for timing reasons Spice might not be the best candidate for looking at whether people choose C or C++.

I was just trying to pick an example that would resonate with people here. Maybe not Spice specifically, but my domain of expertise is in computer simulation software, and it would be hard to consider C as a candidate programming language in a domain that has complex object models, notwithstanding the need for high performance. One has to trade code performance against human performance. Higher level language constructs make things more efficient for the people writing and maintaining the code.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8637
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #39 on: May 04, 2020, 12:45:37 am »
C++ might be better described as a metamorphic (ok, that might only apply to rocks - perhaps it should be 'subject to regular metamorphosis') than OO language. I might eventually manage to get my C++ code from the late 90's past the syntax checker of the latest revision compiler but semantically who knows what it would actually do?

When the language evolves faster than your ability to learn the changes you know it's time to abandon ship and settle back into your comfort zone with straight C, warts and all.
I think some of us were probably so alienated by C++ endlessly changing in the 90s, that we really can't look at it objectively any more.
 
The following users thanked this post: Karel, ogden, newbrain

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #40 on: May 04, 2020, 09:47:18 am »
Probably a certain truth to that, frigging language would not keep still for long enough for you to actually finish anything....

C++ has some good bits, but it is such a vast sprawling mess these days that every engineer knows a DIFFERENT 20% of the language, for me it suffers from not being high level enough to be really efficient for GUI and suchlike work (Where you really want OO), while being just too big and with far too many footguns to make it attractive for small things.

That and the fact that on most platforms there is ONE C ABI, while C++ seems to have many depending in subtly ways on compiler options... Makes library things harder then they need to be.

C for low level or where speed matters, something MUCH higher level for GUI and suchlike bullshit.
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2217
  • Country: 00
Re: How many people code in C these days, and if so, why?
« Reply #41 on: May 04, 2020, 11:01:20 am »
..., something MUCH higher level for GUI and suchlike bullshit.

Qt for Python:  https://www.qt.io/qt-for-python
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: How many people code in C these days, and if so, why?
« Reply #42 on: May 04, 2020, 11:18:00 am »
I almost only use C. the microcontrollers i use for both work and hobby only have C compilers. Wish they had C++ sometimes.
Maybe i can find some other languages like python or ada but the support is nonexistent (no debug, no USB libraries for example) so there is no point in using those.

The only things i don't do in C or C++ are apps, which are done in visual basic (basic 4 android / ios is AWESOME. To hell with java)

I believe that if you work with hardware there isn't much you can use besides C. All those reports that C is a fading language are not aimed at people who work with hardware. C will outlast us all
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23018
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #43 on: May 04, 2020, 11:21:12 am »
Yes C will indeed outlast us all. Most of the Internet runs on C too.
 

Offline coppice

  • Super Contributor
  • ***
  • Posts: 8637
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #44 on: May 04, 2020, 11:36:56 am »
Yes C will indeed outlast us all. Most of the Internet runs on C too.
C will certainly outlast C++. C++ usage has decreased a lot in recent years, whether its business server stuff moving to Java, or PC stuff moving to C#.
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2217
  • Country: 00
Re: How many people code in C these days, and if so, why?
« Reply #45 on: May 04, 2020, 12:24:58 pm »
One could say that C is the most import programming language, together with Java.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14445
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #46 on: May 04, 2020, 12:29:17 pm »
Take this for what it is of course, but the TIOBE index is in line with this: https://www.tiobe.com/tiobe-index/
 

Offline BBBbbb

  • Supporter
  • ****
  • Posts: 289
  • Country: nl
Re: How many people code in C these days, and if so, why?
« Reply #47 on: May 04, 2020, 12:51:33 pm »
Few remarks:
- In embedded space C is dominant. In safety critical industries C is absolutely dominant. Only space I know Cpp is dominant is Game Dev.
- Writing C style in Cpp is not C! There are differences between them. The more complex your SW gets, you'll find yourself digging through obscurities and undefined behaviors... and there are differences...
- I used to know Cpp, then I looked at what's done in Cpp17 (and Cpp20), and I have no idea what's going on.
 
The following users thanked this post: JPortici

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14445
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #48 on: May 04, 2020, 01:04:30 pm »
- Writing C style in Cpp is not C! There are differences between them. The more complex your SW gets, you'll find yourself digging through obscurities and undefined behaviors... and there are differences...

Yes. I often warn against this. The standards for the common "subset" between C and C++ are quite different on a number of points.

- I used to know Cpp, then I looked at what's done in Cpp17 (and Cpp20), and I have no idea what's going on.

As I often say, C++ looks like some kind of "all you can eat buffet".
It's a bit as though, to stay afloat for that long, the C++ committee had to add (/borrow from other languages) as many features and paradigms as they possibly could, and it's still going strong.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #49 on: May 04, 2020, 06:34:18 pm »

I have spent about 20 years trying to build up any enthusiasm for C++ and I just can't get there. 


I hear ya...but if you want a lot of fun try writing a ray tracer for 3D graphics.  :-+

It's a ton of fun, and C++ is almost mandatory. Although I think C and C++ are pretty much interchangeable with those graphics API's.

And then tie that into a C# interface and GUI.  :-+

And yeah, I have lots of fond memories of Fortran  :D

Are there still compilers available for that?? Hmm.......

There is gfortran which is fully compliant with Fortran 95 and implements large chunks of Fortran 2003 and Fortran 2008.  It seems to accept the fixed format arrangement of Fortran 77 and earlier.

Or, stepping back 50 years or so, I have an IBM1130 emulation running on an FPGA and I can use IBM Fortran IV (which wasn't fully Fortran IV) that I know and love.  Sure, it doesn't have the .EQ. type operators and it's missing a lot of other stuff but it, and compilers like it, got us to the Moon.  BTW, the 1130 Fortran compiler used 27 passes because the source and the compiler had to fit in machines as small as 4K words.  The company machine I used had 8k and my emulation has 32K, the max.  The original ran at about 400 kHz and mine runs at 50 MHz.

I mess around with Fortran quite a bit.  There are some classic functions that come up in engineering school (particularly in the math courses) that are worth coding up just for giggles.  Something like Euler's Method for solving differential equations comes to mind.  Could I write the code in C or C++, sure!  But it belongs in Fortran.

MATLAB comes into play quite a bit and the scripting language is somewhat similar to Fortran.

Just pick the right tool for the job and move on.

In C, I can get data hiding with static variables and I can limit the scope of functions by declaring them static.  It's nowhere near as sophisticated as the C++ class but it gets much of the benefit.  I use the same 'getters' and 'setters' concepts.


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf