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.
Top comments (87)
Depends on from which direction you are looking.
If you are looking from below (machine code, assembly, etc.), it's high level.
So it's mid level or old high level.
Levels don't have ages.
Unless they are normalised.
-- Olu Adegoke
I agree, Pascal (and probably Fortran) are on the same level as C.
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.
Yeah, that takes me back. That's real programming. Not like the namby-pamby memory managed languages I use these days.
Yeah, where have all the real programmers gone?
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.
And you can always write C modules that you then import into Python.
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.
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.
C has no concept of registers (the register storage class just makes a variable unaddressable).
C has no concept of op codes.
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?
I agree with you for the most part, but that last paragraph is baseless.
Well, I will create another discussion here and ask if this classification "high level" x "low level" languages still does make sense. Maybe when you didn't have another abstraction layers it made sense to classify languages that way, but now i think we should have other classes like "systems language", "scripting language" or something like that. Low level and high level are too widen concepts nowadays
There is no such thing as objectively high-level or low-level. Every language sits uppon a spectrum of abstraction levels. You could even say that CISC assemblies are higher level than RISC assemblies. C is the language that sits just over assemblies and intermediate representations (IRs) and below other compiled languages, like C#, Java, Go, JS, Python, etc. To me, it's supposed to be the language you'd use when another compiled language would create performance issues, but the project is too big to just write it all in assembly.
When you want to work with objects, especially large objects, you often want to avoid moving the objects from one memory location to another as much as possible. This is where C and Cpp dominate, this is on the main reasons why significantly powerful applications can be run on relatively tiny hardware. This is especially true in video and vision applications, where one can, if skilled, map a network input buffer directly to GPU memory, skipping several memory moves altogether that a more abstract approach would require. In addition, highly performant apps often need to explicitly control when memory gets freed in order to avoid getting zapped by a gc getting busy at a random time. In addition, highly performant apps often reuse memory locations repeatedly rather than allocating and deallocating repeatedly. For reasons such as this, C and C++ are for many the highest level of abstraction which apply to the task at hand.
It's relative to what you're comparing to. I'd say it's lower level than some other languages, which is not a bad thing.
Arguably, one can consider most high level languages like Ruby, Python, Java, etc to be not that high level either because you still need to actually write instructions instead of just something more declarative and leaving the implementation up to the language.
You might be interested in 3GL and 4GL definitions. However it's somewhat outdated.
What does an assembly require?
So, what do you mean by "assembly"?
And how does C qualify as one?
I have some thoughts, so here we go:
C is a language to be used in some specific contexts. As we never should be doing a web-Scrapper using C when we have Python, I think we never will see an OS written in JS.
The answer to your question is: C is a high-level language and this will not change for the CS world too soon.
I never said that C has no pointers. I meant C++
Actually, the tweet shared by this article said that, as you can see at this link:
About the STD: the C++ Standard Library is a implementation of common useful objects as abstractions. The existence of such thing in C++ doesn't invalidate that C has its own abstractions as I mentioned. I really suggest you to check how C language is constructed and how to implement some basic things such as a basic server with threads, open/read/write files or a basic calculator in C.
I have no intention to offend you but seems like you have no basic notion of how C language works or what is concepts like abstractions and basic data types.
I get what you mean but people complain that they have to use
char* chrfor this.
There's a big difference between people complaining about something and people being really mindful about knowing the options to it. Compare:
There are more letters to be written in C++ and you are including in your executable the full
string.hheader. Is that valid? Are you really using all of it? For a Desktop application, this makes no sense but for embedded systems, every byte counts.
using namespace std;and...": No. Do not do this in your code. Check this thread at StackOverflow and do some research about it and why is considered a bad practice.
For the 'string' issue, let me suggest another approach:
As an answer to people who say things like: "C is bad because it doesn't have strings!", consider asking about what they are trying to do. In general, they are complaining about scapegoats.
Definitely! I really agree with you. I hope Dev deletes/changes their tweet.
Technically going by the definition, C could be considered high level. I don't really see how it makes a difference, at the end of the day C nowadays is only employed in niche use cases like embedded systems, kernels, drivers, etc. The reason why it is avoided is because it doesn't have many abstractions, i.e. it is considered too low level for general programming.
Everyone should knew this was going to happen as every 5 years we see new languages include in their main features: "ease of use", "garbage collected", "transparent to dev memory allocation".
As a result, C is pushed out from the "high level lang." definition every time a language is born in popularity with those characteristics, and that's because today is so far away from those new "high level languages" we cannot consider it a high level lang anymore.
As a generic syntax and semantic that can express any behavior desired succinctly to be translated into any assembly, be it x86, ARM or you name it, yes. I would consider "high-level language" to be analogous to "can be made to compile into any instruction set".
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?
When you've done that, let me know what you think this does:
And then let's finish up with a more interesting example.
What does calling this do?
I think the term high-level language was only created to contrast them to low-level languages.
Low-level languages are languages that can be used for both low- and high-level programming.
High-level languages can only be used for high-level programming.
Think of writing a driver. You can probably only write it in low-level language. However, it doesn't mean high-level programs can't be written in it. So, C can be used for both, even though it's not a high-level language. That's only my take on this, I'm not an authority on this.