Is D language completely dependent on D runtime?

Recently, I studied in D. Iv was always embarrassed during work. From the information that I can collect about it (which is not much), I understand that its time sorting, which helps with some functions of D. As garbage collection, it starts along with your own programs. But since D is compiled into machine code, are functions like garbage collection really necessary if our program does not need it? What really bothers me is like "You can write an operating system in D." I know that you cannot do this because theres more for the operating system than any compiled language can give without using any assembly. But if you had a kernel that called D code, would it prevent D D from running in such a blue environment? Or is this D runtime easier than that. Maybe this can be considered just an β€œautomatic” inclusion of source files / libraries, which when compiling with your application does not make any difference than writing this code yourself? Maybe im just looking at all this wrong. But I am sure that some information on this issue can make many people good.
+8
d
source share
2 answers

Yes, indeed, you can implement the DRuntime functions that the compiler expects directly in your main module (or elsewhere), compile without runtime, and it will just work (tm).

If you simply create your code without runtime, the compiler will emit errors when it lacks the character that it expects to implement at runtime. You can then see how DRuntime implements it, to see what it does, and then implement it in any way. This is what XOmB, a kernel written in D (language version 1, though the same thing) does the following: http://xomb.net/index.php?title=Main_Page

Many DRuntimes are not actually used by many applications, but this is the most convenient way to include D runtime components in applications, so that this is done as a static library (I hope that a shared library will be used in the future).

+13
source share

This is almost the same as C and C ++. The language itself is compiled into its own code and just starts. But there is some code that is always needed to configure everything in order to run your program, for example, to process command line parameters.

And some more sophisticated language tools are better implemented by calling some standard code, rather than generating code wherever it is used. For example, to exclude an exception, you need to find the function of the ulocal processor. Sure, the compiler could have inserted the code to make it wherever it was used, but it’s much wiser to write the code in the library and call it. In addition, the standard library has many pre-written library functions.

All this taken together is lead time.

If you write C, you can use it to write the operating system, because you yourself can write the startup code, you can write all the code to allocate memory yourself, you can write all the code for standard functions such as strcat using the provided fulfillment. But you do not want to do this for any application.

+6
source share

All Articles