4 ms·
Should compare with DasBetterC too! https://dlang.org/spec/betterc.html https://dlang.org/spec/betterc.html
by WalterBright 4y ago
Should compare with DasBetterC too!
https://dlang.org/spec/betterc.html https://dlang.org/spec/betterc.html
- asveikau 4y agoThat page specifies a rationale of: code loaded from C will not load the D runtime. Is it also possible to provide a C-callable shared D library that initializes the runtime dynamically? Would you then get some missing features like global constructors? Googling around seems to suggest there is rt_init or Runtime.initialize for that? I've never used D, I'm just curious about the problem described. Ps. Goes without saying that i, like others, appreciate your comments here.
- WalterBright 4y agoThe impetus for DasBetterC is to use a subset of D that does not require the D runtime library. A surprising amount of D users like this and use it. I use it for projects where I want a small runtime executable. DasBetterC executables are as small as C ones can be.
- lwswl 4y agoAre they really? Because most c executables are almost never as small as they can be.
- mhh__ 4y agoIf the D code is aware that it needs to initialize the runtime then yes, either that you or you initialize it yourself before using it. rt_init will fire up the D runtime. As for constructors the runtime should handle those when the module is initialised, so not necessarily on program start up or the DSO being loaded. If, however, you want to register a C runtime constructor you can do do so with pragma(crt_constructor). I actually recently-ish fixed a bug to make the aforementioned type of constructor work on MacOS because Apple decided to deprecate them with no reason.
- lerno 4y agoBetterC is very nice. I'd like to imagine BetterC lifted out of the D compiler with its own spec and separate evolution... That would have been ideal for me. But with BetterC as part of the D compiler it will always feel more like a gateway drug for D rather than a language in its own right :D There are a lot of C compilers out there, people write them for fun. I like the idea that someone would write a C3 compiler "for fun". So limiting implementation complexity is something I have as a goal. What would it take for someone to write a compiler for just the BetterC subset? Would it be doable like implementing C?