digitalmars.D.learn - DMD - Druntime - Phobos questions.
- Travis Boucher (84/84) Nov 21 2009 I am trying to learn some of the internal implementations of D2, mostly
- Chad J (27/59) Nov 29 2009 In D2 you should be able to use Phobos and Tango together, with the
I am trying to learn some of the internal implementations of D2, mostly so I can make it work under other platforms. Right now it is making it work under FreeBSD, since most of the stubs for FreeBSD already exist. In the future, this will be extended to other operating systems, and possibly embedded targets or even os development itself. I need some help with the following, to make sure I am correct and to add any missing pieces to puzzle. ------------------- DMD - Digital Mars D Compiler. http://svn.dsource.org/projects/dmd/ - src/ contains the 'front end'. This is the lexical and semantic analysis. - src/backend/ contains the code generation parts of the compiler. - src/root/ contains the application glue, combining the front end and back end into something useful. - src/tk contains helper code. Linking (on gcc-based platforms) is done externally. The compiler just generates objects appropriate for linking with external linkers. Overall, the dependencies are minimal, host porting is trivial. Target OS porting less trivial, but still pretty easy assuming well documented and standardized object formats. Target CPU porting, don't even bother trying with DMD. ------------------- druntime - The runtime http://svn.dsource.org/projects/druntime/ - import/ contains the core interfaces for the D language. These interfaces (at least object.di and parts of core/*) need to be implemented. - src/gc contains the garbage collector implementation. I assume separated from the rest of the runtime to easy swapping out the GC. - src/common/core contains the default implementation of the interfaces in import/. Also serves as a good example of how to implement the runtime in multiple languages (in this case, I see some D, some C and some assembly). - src/compiler - This one I am not too sure about. Not sure how and why it differs from src/common/core. This is where object.d seems to be implemented. ------------------- phobos - The standard library (at least one of them) http://svn.dsource.org/projects/phobos/ I won't go into too much detail of how this is organized. Overall it is the stuff from 'import std.*'. The end-user callable code. std.c contains the (mostly) unsafe direct interface to libc, and the rest is wrappers around it. (of course this description is over simplified). The standard library isn't something that is even really required (in the way that libc for C applications isn't really required). However implementing and using these interfaces (or the tango interfaces) will make other code written in D work. It should even be possible to use both tango and phobos in the same application (correct me if I am wrong here please). ------------------- Some things I am still unclear about. - How does dmd know where the standard libraries (or interfaces) live? Purely via command line? (since dmd.conf just modifies the command line) - How does dmd know what to link in? Same as the include directories? druntime.a is installed somewhere, and a -ldruntime (or similar) command line is used? - What requires what? Phobos isn't required (but without it or something similar, things are pretty useless). - How much of druntime is really required? This is an important question for embedded/os development targets. http://svn.dsource.org/projects/druntime/trunk/src/gc/stub/gc.d a good example of a minimal garbage collector. http://svn.dsource.org/projects/druntime/trunk/import/object.di seems to be the only import that is *required*. http://svn.dsource.org/projects/druntime/trunk/import/core/sys/ seems to be system Dependant, and not required. http://svn.dsource.org/projects/druntime/trunk/import/core/stdc/ seems to be mostly an abstract of libc, so not really needed. These questions obviously show my interest in (future) development on either embedded platforms, or for OS development. ------------------- Other general D questions. - What is the general consensus on the different D compiler implementations? I know this is a very opinionated question, I am looking for answers that related to the D implementation and not the compilers themselves. I am mostly interested in GCC due to it's huge list of targets, complete and mature toolchain, and its something I've always used. - What is the general consensus on the different D standard libraries? Again, I don't want religion here, just overall state related to D2. From what I've seen, phobos is similar (in functionality) to something like libc (plus extras of course), and tango would be more like boost and STL. Thanks, Travis
Nov 21 2009
Travis Boucher wrote:... ------------------- phobos - The standard library (at least one of them) http://svn.dsource.org/projects/phobos/ ... It should even be possible to use both tango and phobos in the same application (correct me if I am wrong here please).In D2 you should be able to use Phobos and Tango together, with the caveat that Tango doesn't have a D2 release yet. From Tango FAQ: " * Q: Does Tango support D 2.0 as represented by the DMD 2.0xx range of releases? * A: No, not officially. A branch exists in Tango's SVN repository with an early attempt, but D 2.0 is still considered too immature and unstable for any full and official commitment to this end. Feel free to contact us if you want to update the branch, though. "... ------------------- Other general D questions. - What is the general consensus on the different D compiler implementations? I know this is a very opinionated question, I am looking for answers that related to the D implementation and not the compilers themselves. I am mostly interested in GCC due to it's huge list of targets, complete and mature toolchain, and its something I've always used.The "D implementation" seems to remain roughly the same across the compilers. They all use the DMD frontend with some differing glue code to turn the AST into something the backend can understand. GDC seems to only support D1 at the moment. For a while it was abandoned, but has been revived recently. LDC also supports D1 only at the moment. It seems exception handling is broken for Windows, thus making it impractical to compile general D programs with LDC+Windows. http://www.dsource.org/projects/ldc/ticket/123 Though this might not matter much for embedded stuff, unless you develop on Windows. I suspect D2 support will improve when D2 gets 'finished'.- What is the general consensus on the different D standard libraries? Again, I don't want religion here, just overall state related to D2. From what I've seen, phobos is similar (in functionality) to something like libc (plus extras of course), and tango would be more like boost and STL.I think Phobos might be more like boost/STL and Tango might be more like Java's myriad out-of-the-box packages.Thanks, TravisYou seem to have a pretty good understanding of this stuff as far as I can tell. More than mine in most cases. Hope this reply isn't too late. - Chad
Nov 29 2009