loading...

re: Is C still a high level language? VIEW POST

FULL DISCUSSION
 

Well, when you have a CPU, the lowest programming language that most of us, mere mortals, can write for the CPU is assembler.

What C compiler does is none other than translating C syntax to assembler. It is still so low that In fact you can insert assembler snippets in C source code. There’s quite a lot of assembler code snippets in Linux kernel C source code.

So yeah, I think it’s pretty low level language because with C you can do almost everything that assembler can do and assembler is the lowest language you can write in.

 

This is really not true at all.

A modern C compiler does quite a lot of interesting work to try to make C code competitive.

Things are reordered and elided and optimized in ways that are often surprising.

Consider what this does in C.

while (1);

If you think it requires the program to loop forever, you are mistaken. :)

Beyond that, there is a great deal that C cannot do which assembly can.

  1. C has no concept of registers (the register storage class just makes a variable unaddressable).

  2. C has no concept of op codes.

  3. C has no concept of the CPUs memory model -- C has a segmented memory model.

C programs run in the C Abstract Machine, and understanding this is essential to writing C programs that do not work only by accident.

Consider the following snippet -- what do you expect it to do in C?

{
  int i = 1;
  printf("%d, %d\n", i++, i);
}
 

Yeah, that takes me back. That's real programming. Not like the namby-pamby memory managed languages I use these days.

 

Thanks very much for that link. A copy of same was posted up in the common-room when I was at Uni, and was in my thoughts when I posted my comment, which was, of course, tongue-very-firmly-in-cheek.

 

If this is sarcasm, it's a little too good 😂

 

That it's such a boomer thing to say. Both low and high level programming languages serve their purpose. It's true memory managed languages can be quite slow in execution time and can be resource hungry. On the other hand, you can use C# for example for almost everything and it's suitable for advanced design patterns that are just impossible to implement on C. Unless of course you write your own abstraction level, in which case congrats you just re created C++. Furthermore, C# can be optimized to run almost as fast as C and all executables can be stripped down to run even faster. For Gods sake even python can be optimized to run relatively fast. It all depends on the requirements and the context of the application.

For Gods sake even python can be optimized to run relatively fast.

And you can always write C modules that you then import into Python.

 

I agree with you for the most part, but that last paragraph is baseless.

I can insert assembler to Common Lisp and Rust. Both of those out match Python, Javascript, or C++ in abstraction power, so by definition, they are high languages. That doesn't mean that they can't reach down to lower levels of abstraction when they need to do so.

code of conduct - report abuse