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

0 Members and 7 Guests are viewing this topic.

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #250 on: May 10, 2020, 03:53:19 pm »
And despite how I typed my examples above (which I did for clarity), I actually always type conditionals which contain a fixed value like this:

if (true == boolean)
if (5.3 == fVar)

Why? Because if I accidentally leave out one of the equal signs, the compiler will conveniently report it as an error. Typed the "traditional" way, the compiler will simply (and silently) execute the assignment and then resolve the conditional based on the zero vs. nonzero (false vs. true) numeric value of the assignment. This works in Java and other languages too. It "reads" a bit weird but is perfectly logical and lets the compiler check my work in an extra way for free.

I teach others to type this way and (especially for newbies who haven't internalized the whole "double equal sign" thing) it catches a LOT of mistakes.
 
The following users thanked this post: nctnico

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8739
  • Country: fi
Re: How many people code in C these days, and if so, why?
« Reply #251 on: May 10, 2020, 04:53:38 pm »
The problem is that in C 'if' can be used with any type.

IMHO, you should have a naming convention (explicit, or more subtle) so that you know the types, because the problem isn't limited to the if clause and comparisons.

Once you fix that, you get rid of needing the comparisons to other values just to demonstrate the type!

if(isDog) // any isSomething is bool
   printf("%d", numDogs); // num anything is int

or explicitly,
if(b_dog_exists)
   printf("%d", i32_n_dogs);

whatever your coding style or naming convention is, I don't think writing excess comparisons just to "demonstrate" the type is a good solution. This information should be available in some other way.
 
The following users thanked this post: SiliconWizard

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8739
  • Country: fi
Re: How many people code in C these days, and if so, why?
« Reply #252 on: May 10, 2020, 04:58:05 pm »
But it's not particularly ugly. Some people may find it quirky, but that's largely questionable.

I agree, there's nothing ugly. We don't need to hide all low-level details in near-neurotic way; only abstract things when there is a clear benefit and good reason. Just use a simple comment to document dual-use as a flag and counter (I do that all the time, not only for performance, but because it makes sense.)

Similarly, I accept, and even prefer, to have my plumbing visible. It does not distract me, it has a purpose, it's needed, I use it, and when visible, I can see if it leaks. Some people prefer to hide plumbing inside concrete though because it's "ugly". Then replacing it is a huge project (it's known here as a personal tragedy, called "plumbing renovation", requiring evacuation for half a year and almost doubling the estate price.)
« Last Edit: May 10, 2020, 05:00:55 pm by Siwastaja »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15226
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #253 on: May 10, 2020, 05:00:59 pm »
And despite how I typed my examples above (which I did for clarity), I actually always type conditionals which contain a fixed value like this:

if (true == boolean)
if (5.3 == fVar)

Why? Because if I accidentally leave out one of the equal signs, the compiler will conveniently report it as an error. Typed the "traditional" way, the compiler will simply (and silently) execute the assignment and then resolve the conditional based on the zero vs. nonzero (false vs. true) numeric value of the assignment. This works in Java and other languages too. It "reads" a bit weird but is perfectly logical and lets the compiler check my work in an extra way for free.

I teach others to type this way and (especially for newbies who haven't internalized the whole "double equal sign" thing) it catches a LOT of mistakes.

Yes, I don't like this style, but it's a pretty common one to avoid errors.

Note that many decent/recent compilers will issue a warning if you write 'if (a = 5)' (and you shouldn't ignore warnings!), and otherwise static analyzers will also spot that. But if you don't use any, then yes I agree.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15226
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #254 on: May 10, 2020, 05:03:50 pm »
But it's not particularly ugly. Some people may find it quirky, but that's largely questionable.

I agree, there's nothing ugly. We don't need to hide all low-level details in near-neurotic way; only abstract things when there is a clear benefit and good reason. Just use a simple comment to document dual-use as a flag and counter (I do that all the time, not only for performance, but because it makes sense.)

Agreed, but I don't quite agree with the low-level nature of this particular point.
If anything, I consider the two states of original C "booleans", zero and non-zero, to be a little more abstract than just 0 and 1. Weirdly enough, many people seem to have a problem with that. Guess we're all different.
 

Offline IanBTopic starter

  • Super Contributor
  • ***
  • Posts: 12308
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #255 on: May 10, 2020, 05:08:43 pm »
Yes, I don't disagree with the fact that your if("string") example is valid C (equivalent code is valid in many other languages, as well; and equally not making any sense), as is your modified code in post #204, which nobody has commented about, I was just looking for the point you are trying to make with your messages, but now that you have admitted you have none, and didn't even intend to, it explains many things, and it is unnecessary to discuss any further.

Apparently I failed in my communication somehow. I don't know why everyone found it so objectionable.

I did have a point:

C does not have a boolean type. A C compiler will definitely complain if you try to assign a string  (char *) to a non-string type.

I was just checking this assertion, since later C standards did add a boolean type, and it doesn't in fact complain if you assign a string to it.

Instead of saying "oh, that's interesting" everyone started beating up on me. So OK, it's not important, nobody is bothered and it's not worth arguing about.
 

Offline Tomorokoshi

  • Super Contributor
  • ***
  • Posts: 1212
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #256 on: May 10, 2020, 05:51:30 pm »
For levity's sake this seems appropriate here:
https://xkcd.com/386/

Anyway, sure, C has its +'s, ++'s, -'s, and --'s. For practical reasons there are not a lot of alternatives for embedded work, a lot of code base is available, etc. I can't afford 100 MB to support "Hello World" with Java or other wanna-be bloat.

Regarding the curiosity from the link a few pages pack regarding the apparent rise in popularity of C and Python along with the drop in popularity of Java, it makes perfect sense given the benefits and synergies pointed out by others of using C and Python together.

"Using the right tool for the right job" requires a set of value judgements that don't fall nicely into macroeconomic categories. Many of those are bypassed for non-technical reasons, having to do with the reality and practicality of project cost and scheduling. With a lot of code base and engineering talent invested in C, choosing some other language on technical merits alone will rarely make it through until a lot of off-budget investment is made, such as through independent projects or some game-changing set of tools.
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #257 on: May 10, 2020, 06:11:49 pm »
IanB, between you and me...word to the wise...

Fanboys. This place is crawling with 'em. Meters, scopes, power supplies, you name it. And even software. Go no, right?? Yeah it's true. And who would'a thought there were even C fanboys??  :wtf:

Anyway, it's a bit like going into a bar in Dallas while the Cowboys are playing in the Super Bowl, and shouting "Cowboys SUCK !!". They'll rip you a new one.

So my recommendation: Just apologize, post shit like "C RULES !!!  :-+" and slowly back out and move on.

And watch your back..........

 :-DD
- 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 bd139

  • Super Contributor
  • ***
  • Posts: 23093
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #258 on: May 10, 2020, 06:16:36 pm »
It was quite objective and interesting until a couple of members crawled in...
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #259 on: May 10, 2020, 06:30:45 pm »
It was quite objective and interesting until a couple of members crawled in...

I apologize. C RULES !!!!  :-+
- 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 bd139

  • Super Contributor
  • ***
  • Posts: 23093
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #260 on: May 10, 2020, 06:32:37 pm »
Common Lisp rules  :popcorn:  :-DD
 
The following users thanked this post: knapik

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2258
  • Country: 00
Re: How many people code in C these days, and if so, why?
« Reply #261 on: May 10, 2020, 06:40:08 pm »
What about Borland Delphi?  >:D
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3865
  • Country: de
Re: How many people code in C these days, and if so, why?
« Reply #262 on: May 10, 2020, 06:44:27 pm »
FYI:

C is actually rising in popularity - mostly thanks to embedded development.

https://www.tiobe.com/tiobe-index/

Last month growth of C is almost 3% and it has landed back in the 1st spot, overtaking Java.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15226
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #263 on: May 10, 2020, 06:50:40 pm »
@janoc: yes, I think this link has been posted a number of times already in this thread. As I said, to be taken with a pinch of salt.

Otherwise, and especially for engrguy42: I don't know how surprising that would be that people mostly focus on talking about C in this thread. Overall, the posts looked pretty reasonable to me. And you can't really complain about people being on topic, since this is the very topic. It was not about "what programming language do you guys use these days?" (which is kind of a popular topic and has already been asked numerous times I think.)

As Tomorokoshi posted, some people seem to prefer trying to prove others wrong than staying on topic. Oh well. :popcorn:
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #264 on: May 10, 2020, 07:01:10 pm »
Overall, the posts looked pretty reasonable to me.

Of course they do...  :-DD
- 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 Wolfgang

  • Super Contributor
  • ***
  • Posts: 1820
  • Country: de
  • Its great if it finally works !
    • Electronic Projects for Fun
Re: How many people code in C these days, and if so, why?
« Reply #265 on: May 10, 2020, 07:21:56 pm »
Overall, the posts looked pretty reasonable to me.

Of course they do...  :-DD
IMHO, religious computer language discussions are a complete waste of time -
better spent to solve a real world problem.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27787
  • Country: nl
    • NCT Developments
Re: How many people code in C these days, and if so, why?
« Reply #266 on: May 10, 2020, 07:32:59 pm »
What about Borland Delphi?  >:D
For that we would need a vomit emoticon. I had the misfortune to inherit a larger project once. What a mess. Pascal with C-isms bolted on. I have used Borland Pascal for a while an dabbled in Delphi as well but quickly found out that Pascal is not really suitable for any real programming work where you need to restructure a program half way sometimes. Having 4 or 5 different string types also doesn't help. If you need to resort to C-isms anyway then better use the real deal (C or C++)... If you don't want to use C/C++ then look a C#, Java or Python.
« Last Edit: May 10, 2020, 07:37:10 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 9351
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #267 on: May 10, 2020, 09:56:24 pm »
Common Lisp rules  :popcorn:  :-DD
Rubbish. Snobol rules.
 
The following users thanked this post: bd139

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15226
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #268 on: May 10, 2020, 09:57:15 pm »
PL/M rules.
 

Offline Wolfgang

  • Super Contributor
  • ***
  • Posts: 1820
  • Country: de
  • Its great if it finally works !
    • Electronic Projects for Fun
Re: How many people code in C these days, and if so, why?
« Reply #269 on: May 10, 2020, 10:04:55 pm »
Its endless. With all the time and effort wasted here in this forum you could have coded a graphics package in COBOL. Just as futile, but at least *something* works in the end  >:D >:D :horse:
« Last Edit: May 10, 2020, 10:06:50 pm by Wolfgang »
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 9351
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #270 on: May 10, 2020, 10:14:31 pm »
PL/M rules.
PL/M, MPL, and a few other derivatives of PL/1 were created by microprocessors vendors in the mid to late 1970s, to support bare metal programming for their products. If C had more presence at that time these things would never have existed.
« Last Edit: May 10, 2020, 11:33:18 pm by coppice »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15226
  • Country: fr
Re: How many people code in C these days, and if so, why?
« Reply #271 on: May 10, 2020, 10:15:32 pm »
PL/M rules.
PL/M, MPL, and a few other derivatives fo PL/1 were created by microprocessors vendors in the mid to late 1970s, to support bare metal programming for their products. If C had more presence at that time these things would never have existed.

 ;D
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #272 on: May 10, 2020, 11:00:19 pm »
Its endless. With all the time and effort wasted here in this forum you could have coded a graphics package in COBOL. Just as futile, but at least *something* works in the end  >:D >:D :horse:

Yeah, no kidding...the horse died like 10 pages ago.

Well I spent some time today buttoning up my data acquisition app by making a custom icon.

Oh, and my app has some booleans, and in spite of the incredible complexity surrounding booleans  :wtf: they worked fine. I mean, like, what's to discuss? They're, like, true...or...false.  ;D

"if (plotIt && !plotStop)"

On second thought, I'm sure that will start even more boolean muscle flexing but anyway...
- 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 bd139

  • Super Contributor
  • ***
  • Posts: 23093
  • Country: gb
Re: How many people code in C these days, and if so, why?
« Reply #273 on: May 10, 2020, 11:03:35 pm »
Now write an installer in WIX and sign it with an EV code sign cert  :-DD
 

Offline engrguy42

  • Frequent Contributor
  • **
  • Posts: 656
  • Country: us
Re: How many people code in C these days, and if so, why?
« Reply #274 on: May 10, 2020, 11:08:07 pm »
Now write an installer in WIX and sign it with an EV code sign cert  :-DD

Why?
- 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...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf