Jump to page: 1 2 3
Thread overview
D: pay for what you use?
Feb 13, 2014
Rel
Feb 13, 2014
Sean Kelly
Feb 13, 2014
Adam D. Ruppe
Feb 13, 2014
Rel
Feb 13, 2014
Gary Willoughby
Feb 13, 2014
Asman01
Feb 13, 2014
Rel
Feb 13, 2014
Martin Nowak
Feb 14, 2014
Rel
Feb 14, 2014
Dicebot
Feb 13, 2014
bearophile
Feb 13, 2014
Paulo Pinto
Feb 14, 2014
Ziad Hatahet
Feb 15, 2014
Meta
Feb 13, 2014
Mike
Feb 13, 2014
tcak
Feb 13, 2014
tcak
Feb 13, 2014
Brad Anderson
Re: pay for what you use?
Feb 14, 2014
Daniel Murphy
Feb 14, 2014
Iain Buclaw
Feb 14, 2014
Mike
Feb 13, 2014
Mike
Feb 14, 2014
Vladimir Panteleev
Feb 14, 2014
Rel
February 13, 2014
Hello! I really enjoy D and some brilliant concepts in the language, like scope(exit) for example. But what I dislike about D is the druntime, where each single function depends on 100 other functions. I'd like to be able to develop system level code in D (like windows drivers or linux kernel modules or do osdev), but I can not do it, as D is very dependent on the druntime. It would be great if D would have the same "pay for what you use" way, as C/C++ do. So I'd like to ask several questions:

1) Is it possible to fully disable exceptions? Generally I tend not to use exceptions in C++ as well, as exception path may take a whole lot of a time. Also returning error codes or using something like Expected<T> is more readable in most cases. Obviously I'm not going to use exceptions in my code, and I won't be linking with code that throws/catches exceptions.

2) Is it possible to fully disable runtime type information? I understand that being able to get different information about object type in the runtime may be very useful, but I've never used it. However D compilers do generate RTTI-tables no matter what with all class names, module names and etc.

3) Is it possible to fully disable garbage collection? Sometimes having GC is a good thing, but I'd rather do manual memory management or use automatic reference counting instead.

4) What compiler is better to use when I want to compile and run D on "bare bones" (running code without operating system)? Is it DMD? Or is it LDC? Or GDC?

5) Does anyone try to make a tiny druntime library? Did it work out well for you? And can I have a look at it?

PS I know that these kind of questions come out in the D community from time to time, but there's a lot of things I'd like to discuss on this subject, so I decided to make a new thread... sorry...
February 13, 2014
You can disable GC, for example by linking to gcstub (backed by malloc and free).  But for the rest, it sounds like what you want is the "betterC" proposed by Walter recently.
February 13, 2014
On Thursday, 13 February 2014 at 17:04:44 UTC, Rel wrote:
> 1) Is it possible to fully disable exceptions?

Don't implement _d_throw in druntime and they won't link. I'm pretty sure the tables are still generated but they won't be used (and are pretty small anyway.

> 2) Is it possible to fully disable runtime type information?

alas, not at this time.

> 3) Is it possible to fully disable garbage collection?

Again, just don't implement it and it won't link if you try to use it.

> 4) What compiler is better to use when I want to compile and run D on "bare bones" (running code without operating system)? Is it DMD? Or is it LDC? Or GDC?

Any should work since it is more of a linker script question than a compiler one; I used dmd for my playing with it but I'm sure the others can do the same things.

> 5) Does anyone try to make a tiny druntime library? Did it work out well for you? And can I have a look at it?

http://arsdnet.net/dcode/minimal.zip

That's one with exception support (you can remove that sort of with a -version switch but i like exceptions), classes, and much the rest of the language but only comes out to ~30 KB executable, zero outside dependencies (see also Makefile.bare that can make a bare metal image bootable with grub).

It might not compile with the newest dmd, I'm not sure since I haven't kept up with the changes over the last several months. Ripping out druntime and doing it all yourself is liable to break without warning.


An independent try at doing the same thing is here:
https://bitbucket.org/timosi/minlibd

I haven't used it myself though.
February 13, 2014
On Thursday, 13 February 2014 at 17:04:44 UTC, Rel wrote:
> Hello! I really enjoy D and some brilliant concepts in the language, like scope(exit) for example. But what I dislike about D is the druntime, where each single function depends on 100 other functions. I'd like to be able to develop system level code in D (like windows drivers or linux kernel modules or do osdev), but I can not do it, as D is very dependent on the druntime. It would be great if D would have the same "pay for what you use" way, as C/C++ do. So I'd like to ask several questions:

It's a good job i don't believe in conspiracies.

http://forum.dlang.org/thread/lddug4$jgv$1@digitalmars.com

February 13, 2014
On Thursday, 13 February 2014 at 17:15:06 UTC, Gary Willoughby wrote:
> On Thursday, 13 February 2014 at 17:04:44 UTC, Rel wrote:
>> Hello! I really enjoy D and some brilliant concepts in the language, like scope(exit) for example. But what I dislike about D is the druntime, where each single function depends on 100 other functions. I'd like to be able to develop system level code in D (like windows drivers or linux kernel modules or do osdev), but I can not do it, as D is very dependent on the druntime. It would be great if D would have the same "pay for what you use" way, as C/C++ do. So I'd like to ask several questions:
>
> It's a good job i don't believe in conspiracies.
>
> http://forum.dlang.org/thread/lddug4$jgv$1@digitalmars.com

I believe it's a God's signal.
February 13, 2014
Rel:

> It would be great if D would have the same "pay for what you use" way, as C/C++ do.

While D is nearly a system language, its design doesn't follow that C++ rule fully. In some cases paying a little is OK for D, if it makes lot of other code safer, shorter, nicer, etc.

Bye,
bearophile
February 13, 2014
On Thursday, 13 February 2014 at 17:14:05 UTC, Adam D. Ruppe wrote:
> Don't implement _d_throw in druntime and they won't link. I'm pretty sure the tables are still generated but they won't be used (and are pretty small anyway.

Maybe I'm too pedantic about my code, but I don't want to have useless tables in data sections. Sadly on practice this stuff isn't cut off by optimizations.

> http://arsdnet.net/dcode/minimal.zip
>
> That's one with exception support (you can remove that sort of with a -version switch but i like exceptions), classes, and much the rest of the language but only comes out to ~30 KB executable, zero outside dependencies (see also Makefile.bare that can make a bare metal image bootable with grub).
>
> It might not compile with the newest dmd, I'm not sure since I haven't kept up with the changes over the last several months. Ripping out druntime and doing it all yourself is liable to break without warning.
>
>
> An independent try at doing the same thing is here:
> https://bitbucket.org/timosi/minlibd
>
> I haven't used it myself though.

Thanks, I will look at it. But I agree that in general it may be hard to keep your own minimal runtime library up to date with the latest compiler version. That is a bad thing about it too...
February 13, 2014
On Thursday, 13 February 2014 at 17:15:06 UTC, Gary Willoughby wrote:
> It's a good job i don't believe in conspiracies.
>
> http://forum.dlang.org/thread/lddug4$jgv$1@digitalmars.com

Oh, that is funny! I didn't notice that topic, as I haven't been much into D community. Thanks for pointing it out! I really hope that these features will be included in D compiler eventually...
February 13, 2014
On 02/13/2014 07:51 PM, Rel wrote:
> Oh, that is funny! I didn't notice that topic, as I haven't been much
> into D community. Thanks for pointing it out! I really hope that these
> features will be included in D compiler eventually...

It already is, though it might not be fully implemented yet.
Try 'dmd -betterC'.
February 13, 2014
Am 13.02.2014 19:06, schrieb bearophile:
> Rel:
>
>> It would be great if D would have the same "pay for what you use" way,
>> as C/C++ do.
>
> While D is nearly a system language, its design doesn't follow that C++
> rule fully. In some cases paying a little is OK for D, if it makes lot
> of other code safer, shorter, nicer, etc.
>
> Bye,
> bearophile

I agree, I rather pay a little more like in Modula-2 and Ada, than have what C++ has become.

It is always a mess to link in third party libraries if they have decided to pay for a different set of things one is willing to pay for.

And to be honest, even when I used to do systems level programming back in MS-DOS days and my early UNIX days, I never felt the need for such approach.

I think it was a design decision to bring to C++, the C developers that use it as a portable macro assembler.

--
Paulo
« First   ‹ Prev
1 2 3