General > General Technical Chat

How many people code in C these days, and if so, why?

<< < (41/99) > >>

Cerebus:

--- Quote from: floobydust on May 09, 2020, 11:23:33 pm ---Computing Science has failed to make a decent programming language.
Every language is intellectually orgasmic and the academics circle jerk off to them, but all fizzle out after many years, and then yet another language is born and the cycle repeats.

C is just a high-level assembly language, extremely dangerous because it really checks for nothing. Think of the all PC Trojans, viruses exe'd due to buffer overflows.
My CompSci Uni prof spent two weeks in class pissing around with pointers in C, seeing what would happen with "funky" de-referencing. It's worse than the Wild West.
Unfortunately C has made it to cars, airplances and other safety-critical applications for embedded systems. It's just too dangerous IMHO.

Just the other day I stumbled onto this:


--- Code: ---boolean myFlag;

myFlag = 2;
myFlag = "A";
myFlag = 3.14159;

--- End code ---

All of which of course compiles and runs in C. Absolute GARBAGE

--- End quote ---

Except of course it doesn't compile and, indeed, isn't C.


--- Code: ---void FLoobiesAssertionIsThatThisWillCompileInC ()
{
    boolean myFlag;

    myFlag = 2;
    myFlag = "A";
    myFlag = 3.14159;
}

--- End code ---

Which, if compiled, will yield this:

--- Code: ---cerebus@shu:~/Desktop$ gcc-9 flooby.c
flooby.c: In function 'FLoobiesAssertionIsThatThisWillCompileInC':
flooby.c:3:5: error: unknown type name 'boolean'
    3 |     boolean myFlag;
      |     ^~~~~~~
flooby.c:6:12: warning: assignment to 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
    6 |     myFlag = "A";
      |            ^
cerebus@shu:~/Desktop$

--- End code ---

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. Many languages will silently cast a floating point type to an integer and vice versa, so that's a odd thing to pick on. And the rant against academic languages is a bit odd given that C does not have its origins in academe, but in Bell Labs.

If you're going to rant about a language a prerequisite is to know the language well enough to know whether you're ranting about the language or ranting about what you imagine the language is.

Wolfgang:

--- Quote from: Cerebus on May 10, 2020, 12:38:34 am ---
--- Quote from: floobydust on May 09, 2020, 11:23:33 pm ---Computing Science has failed to make a decent programming language.
Every language is intellectually orgasmic and the academics circle jerk off to them, but all fizzle out after many years, and then yet another language is born and the cycle repeats.

C is just a high-level assembly language, extremely dangerous because it really checks for nothing. Think of the all PC Trojans, viruses exe'd due to buffer overflows.
My CompSci Uni prof spent two weeks in class pissing around with pointers in C, seeing what would happen with "funky" de-referencing. It's worse than the Wild West.
Unfortunately C has made it to cars, airplances and other safety-critical applications for embedded systems. It's just too dangerous IMHO.

Just the other day I stumbled onto this:


--- Code: ---boolean myFlag;

myFlag = 2;
myFlag = "A";
myFlag = 3.14159;

--- End code ---

All of which of course compiles and runs in C. Absolute GARBAGE

--- End quote ---

Except of course it doesn't compile and, indeed, isn't C.


--- Code: ---void FLoobiesAssertionIsThatThisWillCompileInC ()
{
    boolean myFlag;

    myFlag = 2;
    myFlag = "A";
    myFlag = 3.14159;
}

--- End code ---

Which, if compiled, will yield this:

--- Code: ---cerebus@shu:~/Desktop$ gcc-9 flooby.c
flooby.c: In function 'FLoobiesAssertionIsThatThisWillCompileInC':
flooby.c:3:5: error: unknown type name 'boolean'
    3 |     boolean myFlag;
      |     ^~~~~~~
flooby.c:6:12: warning: assignment to 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
    6 |     myFlag = "A";
      |            ^
cerebus@shu:~/Desktop$

--- End code ---

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. Many languages will silently cast a floating point type to an integer and vice versa, so that's a odd thing to pick on. And the rant against academic languages is a bit odd given that C does not have its origins in academe, but in Bell Labs.

If you're going to rant about a language a prerequisite is to know the language well enough to know whether you're ranting about the language or ranting about what you imagine the language is.

--- End quote ---

C is for users who know what they are doing and who can write code in a safe and defensive way.
There is very little "shoot yourself in the foot" protection, agreed. The dirty minds should therefore play with something else ... :)

intmpe:

--- Quote from: engrguy42 on May 09, 2020, 06:07:20 pm ---Huh? Are you new here?  This place is all about broad assumptions and generalizations and unsupported opinion
:-DD

--- End quote ---
+1 thats because we are really talking about programming and as I was taught in school many years ago its as much an Art as it is a Science. It is not engineering, despite the fact that everyone who reads a book at barns and noble for that .net job gets called a software engineer. Its like your local HR getting renamed a Human Factors Engineer. For the majority of programmers it was just as hard in 1985 trying to extract every clock cycle out of a commodore 64 via assembler - probably harder because there was just a lot less access to information - and many of those who did it were kids. I wouldn't be surprised if the best python programmers out there today are kids via things like the PI.

IanB:

--- Quote from: Cerebus on May 10, 2020, 12:38:34 am ---C does not have a boolean type.
--- End quote ---

Why do you say this? Which C standard are you considering?


--- Quote ---A C compiler will definitely complain if you try to assign a string  (char *) to a non-string type.
--- End quote ---

It will?

I just compiled this using my friendly local C compiler, and there were no warnings:


--- Code: ---#include <stdio.h>

int main(void)
{
    _Bool flag;

    flag = 2;
    flag = "A";
    flag = 3.14159;

    printf("flag = %d", flag);

    return 0;
}

--- End code ---

When I run it, it produces the output "flag = 1": the C language defines any non-zero value as true, and true is represented as 1. So the non-zero double is down-cast to a _Bool type and becomes 1.

coppice:

--- Quote from: IanB on May 10, 2020, 01:00:32 am ---
--- Quote from: Cerebus on May 10, 2020, 12:38:34 am ---C does not have a boolean type.
--- End quote ---
Why do you say this? Which C standard are you considering?

--- End quote ---
C has a boolean type, but the keyword for it is not "boolean" like the example code being referred to.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod