If C/C++ are native languages then why do they need runtimes?

Asked

Viewed 209 times

5

Usually the first thing that came to my mind when I heard the term native language, was a program that ran independent of operating system, communicating directly with hardware, I always developed in mode debug, when I released a release for the first time I noticed that compilers even like Mingw needed a Runtime, if it were an application that used Windows API for example it would be totally understandable because it depends on Windows operating system libraries. But if there’s a need Runtime then why call it native language?

I imagine a hobbyist developing a very simple computer (something like a chip-8) so he starts to develop his kernel for the operating system, at some point he will have to set aside the Assembly and use C/C++, so as the program will handle something so low level without a Runtime?

  • 1

    If you use Mingw-W64, for example, (which is a modern Fork) you don’t need Runtime (mingwm10.dll, for example). Not to be confused with the exception library, thread library and stdlib, each has its own function (independent of Runtime) - Your question is mixing many unrelated things.

1 answer

7


Usually the first thing that came to my mind when listening to the term native language, was a program that ran independent of operating system, communicating directly with the hardware

Wrong, a native language depends on the operating system. At least there’s no requirement that you don’t need an operating system, and if you don’t have one, then the Runtime turns out to be fundamental, after all the language alone (the code generated by it) can only give instructions to the processor. Direct access to hardware is possible, but not simple.

I’ve always developed in mode debug, when I released a release for the first time I noticed that compilers even like Mingw needed a Runtime, if it were an application using Windows API for example it would be totally understandable because it depends on Windows operating system libraries.

I think it lacks understanding of what a Runtime. It is code needed to perform certain tasks in an easier and safer way.

You don’t need one Runtime in Assembly, also in C, or almost. In a way in C++. But in practice it will take work, you will have to do everything by hand and you are probably reinventing the wheel in a worse way. You will rarely be getting rid of the code needed to work properly, you are just doing it by hand.

Libraries count as Runtime or not? In practice without them you can’t do anything useful, except rewrite them. What you might be calling Runtime are the libraries. It is not wrong to say this, but it is possible to leave it out. You will have little advantage over Assembly, probably just architecture portability.

The Runtime has mechanisms to make your life easier if you use them. Or to solve an implementation or platform problem, not the language.

But if there’s a need for a Runtime then why call it native language?

Since this is a mistaken premise you should provide a reason why a native language could not have a Runtime.

Native language means that the code runs directly on the processor, only that, it doesn’t have an intermediate process of interpretation.

Actually the term is already wrong. There is no native language, there is native implementation. We can say that every language can be native or not. Some tend to be one or the other, but, except for something in the specification that uniquely requires one of these senses, and neither C, nor C++ has this requirement, you can make a non-native implementation.

I imagine a hobbyist developing a very simple computer (something like a chip-8) so he starts to develop his kernel for the operating system, at some point it will have to set aside the Assembly and use C/C++

No, it can continue using Assembly.

then how will the program deal with something so low level without a Runtime?

I do not know how this question makes sense, much less what doubt here. If I understood correctly this question invalidates the original assumptions of the question.

Completion

I think you’re confusing terms and concepts. There’s no relationship between these things.

  • I think I’m confusing the terms of Runtime even, for example when I released a release of a program that uses Qt, in addition to the Qt dll’s I needed some dlls that I didn’t have in the Qt MSVC kit (I was using the Mingw version): libgcc_s_dw2-1.dll, libstdc++-6.dll and I believe that libwinpthread-1.dll thing I didn’t have in the MSVC version (Why it should be in the redistributable package of Visual C++, this really is a Runtime according to the downloads page)

  • "No, he can continue using Assembly" - When I said that at some point he should resort to C/C++ it is due to the fact that the little experience I had with asm I could see that it is a complex, time-consuming language to create applications for a simple task like showing a "Hello World", and as you said yourself https://answall.com/questions/19073/por-que-choosec-ao-inv%C3%A9s-de-c-ou-ent%C3%A3o-c-no-lugar-c C can be compiled for any architecture, which would speed development.

  • Making a hardware or operating system is much more complex. I find it simpler to do a "hello world" in Assembly than in another language, even without knowing the language well. If it’s for your hardware this portability seems unimportant.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.