DEV Community

Cover image for Is C still a high level language?
Swastik Baranwal
Swastik Baranwal

Posted on

Is C still a high level language?

I keep hearing that C is no longer a High Level Programming Language because it is no abstractions, has pointers, have to handle memory on our own, no string data type, unsafe etc.

Do you think that C is not a high level language anymore? I am against this because it's still readable as any other high level and usable as ever and has many libraries and still been updated.

Latest comments (77)

Collapse
 
pauljlucas profile image
Paul J. Lucas

Who cares whether it's a high or low-level language? What problem does giving it that label solve?

But if you think it's truly low-level, you haven't understood microprocessors since the 1980s.

Collapse
 
sandyydk profile image
Sandeep Harihara Bhat Y

This is a tricky thing if I may say so. Even Go for example has pointers etc and needs some memory management handling. Some people call it a high level language and others mid level. Never ending arguments to follow

Collapse
 
bkahlerventer profile image
Bennie Kahler-Venter • Edited

C was designed as a low-level language with high-level constructs. Brian Kernighan and Dennis Richie needed a language to write Unix in. BCPL, B, and rational fortran - ratfor all contributed to the language now known as C. C is meant to be unsafe and have flexible rules. It was so by design.

It was one of the early universal assembly languages.

 
connellpaxton profile image
connell-paxton

I do get what youre saying, and tbh I didn't realize people were actually get egotistical or at all heated in this.

I don't think assembly is the right word for it, thats all.
It is portable, and does allow for many features that map easily to assembly,
even in some cases allowing for the register keyword etc (although it isnt always guaranteed)

I just think portable and assembly are opposites as assembly programming is very much about familiarity with hardware and programming a specific machine.

Thread Thread
 
pentacular profile image
pentacular

Thomaz,

"Could you show me an example of such nontrivial translation in C? i++, a[i], b.c, for, etc all are trivial (in context of particular CPU)."

Don't you remember asking for those examples? :)

 
connellpaxton profile image
connell-paxton

That is true, but these aren't exactly standardized, and I usually think of them as assembler features as opposed to a "language feature"
I wouldn't really count something as being a part of assembly if it wasn't something directly linked to the actual nmeonics

 
pentacular profile image
pentacular

Every CPU has a memory model, but other than that you've done a good job of demonstrating why C isn't a portable assembly. :)

Beyond that, if you believe that C has a very strong correspondence to every machine code instruction set, then you believe that every machine code instruction set has a strong correspondence with every other machine code instruction set.

This is simply not true -- let's consider a forth machine.

Or if that's not enough, consider one which runs befunge in hardware.

Now let's consider your example operations.
What do you believe this is required to translate to?

void foo() {
  int i = 0;
  int a[3] = { 1, 2, 3 };
  struct foo { int c; } b;
  b.c = a[i++];
}

When you've done that, let me know what you think this does:

void bar() {
  while (1);
}

And then let's finish up with a more interesting example.
What does calling this do?

void quux() {
  int i = 1;
  printf("%d, %d\n", i++, i);
}
Collapse
 
pentacular profile image
pentacular

What does an assembly require?

  1. Access to the CPU registers? C doesn't have this.
  2. Access to the CPU's memory model? C doesn't have this.
  3. Access to the CPU's op codes? C doesn't have this.
  4. A trivial translation to machine code? C doesn't have this.

So, what do you mean by "assembly"?

And how does C qualify as one?

Collapse
 
cubbimew profile image
Sergey Zubkov

It's becoming more of a high level language as time moves on and hardware evolves in ways C programming model doesn't account for (GPUs etc), while compilers evolve to take better advantage of C's abstractions (e.g. compilers remove calls to memset because they are "useless" under C model even if the programmer thought they were wiping out a password from memory)

 
connellpaxton profile image
connell-paxton

You do have abstraction, in that you have types, structs, etc, which no actual assembly would have. Variables of different sizes etc.

Collapse
 
seanthorpe profile image
seanthorpe

Next question, "Did Adam have a belly button?"

To me this is along those lines.
The discussion leads no where.
And reality doesn't change one bit.
Choose the language you need/want to do what you need/want.

Someone below was commenting on how C# could be as/almost as fast as C. So what.

There's defintely one thing C# can do that C can't do...

Be thrown in the trash and no longer supported by Microsoft.

If one day MS decides the .NET Framework is "old news" AND they come out with a TNG Programming Structure using a new SeaStar language... they can end-of-life C#.
(Been there done that!)

C on the other hand will likely endure, due to its place and popularity in the history of programming languages.