OS in D language

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS in D language

Post by AndrewAPrice »

I would be EXTREMELY grateful if someone could share their experiences with the D language (wiki?). I have thought about converting to D many times cause I love the language, but now I heard that is designed for systems programming :shock:
My OS is Perception.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: OS in D language

Post by quanganht »

Currently I'm working on D cross-compiler and stuffs like linker script and so. Then a D wiki page will appear ! :)
"Programmers are tools for converting caffeine into code."
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: OS in D language

Post by jal »

quanganht wrote:Currently I'm working on D cross-compiler and stuffs like linker script and so. Then a D wiki page will appear ! :)
Cool, I'll be eagerly awaiting.


JAL
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS in D language

Post by AndrewAPrice »

berkus wrote:dmd vs. gdc - messy. different options, different search paths. gdc can't find some runtime libs, dmd seems to find standard libs fine, but chokes on importing local modules. May be it was my setup.
dmd - Is it the compiler/linker the D website provide for system programming or just applications? And I didn't find any info on the executable format the linker outputs (my OS uses ELF).
gdc - Wikipedia states it only supports D1.0. The compiler isn't 100% faithful to the specification (though they list the issues on their website).

D1.0 vs D2.0 - The 2.0 dmd compiler is unstable, though there are several features I like. The 2.0 specification is also likely to evolve a bit.
My OS is Perception.
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: OS in D language

Post by Zenith »

A long time ago, when I tried to port my kernel to D, I ran into those problems as well:

dmd is actively developed and is the official compiler, but is really not intended to be a compiler for the system. It's distributed in binary form (can't seem to find the source), and only for 32-bit Windows and Linux. It only compiles to the native executable of the platform... way to go, system programming!

gdc is an improvement because it's a front-end to gcc, making it more flexible (and support more target formats). However, it's a one-man show, it's been unmaintained for more than a year now, and that state doesn't seem to have changed (It only supports GCC 4.0.* as of this writing, without patches). Apparently, the reason they haven't added support for D in the GCC project (which would really be a blessing, IMHO) is because of licensing conflicts :roll:.

There's also llvmdc, which seems to be the best hope so far (D front-end on the LLVM compiler). It's really early in production, but if I figure out how to make it cross-compile x86-64 ELF binaries, then I might have a chance.

Finally, there's the runtime stubs. Oh, the runtime stubs... From my experience, it was too painful to implement (I gave up), and apparently differs between compiler and/or library versions. Not to mention that there are two competing libraries, two partially-incompatible standards, and three different compilers. Great...

But that was a long time ago. Now (for my kernel at least), I'm sticking with my C++ foo. 8)
"Sufficiently advanced stupidity is indistinguishable from malice."
User avatar
Wilkie
Member
Member
Posts: 44
Joined: Tue Aug 26, 2008 10:02 pm
Location: Land of the Dead
Contact:

Re: OS in D language

Post by Wilkie »

I agree with you Zenith, dmd is terrible. GDC, using the dmd implementation, is also...meh...bad on many levels. The source is around, GDC uses it. And yes, where did that guy go who is maintaining it?! This is why we are GTFO'ing to LLVM. (We see GCC as a sinking ship, also, but that's a different story)

LLVM's LDC is the way to go. We are working actively with LDC developers on porting XOmB (our D exokernel) to use it. Apparently we are a nice test case :) They tell us our kernel compiles fine for x86-64 (although LLVM's variadics for x86-64 are nonexistent as of the present). It doesn't produce a valid binary because it needs to be a naked compiler, and it isn't. But hopefully they will step us through that and we can update the wiki.

LDC is great because it marks the true second compiler implementation of the language (remember: gdc uses the dmd codebase). So LDC should be a viable development tool for OS work. (I've obviously not had a chance to really use it though)
quanganht wrote:Currently I'm working on D cross-compiler and stuffs like linker script and so. Then a D wiki page will appear ! :)
Great! I see you are on our mailing list. Please use it for questions, we would like to help. Mixins are so nice for interrupt handling 8) I've personally built gdc cross-compilers several times targeting 32-bit and 64-bit machines. One of us has patches that are necessary.
MessiahAndrw wrote:gdc - Wikipedia states it only supports D1.0.
Yep, pretty much. As Zenith points out, the SOLE maintainer is sorta missing ATM. Also, dmd would be a terrible choice for systems dev...unfortunately. Doesn't target 64 bit machines.. It doesn't like stripping out runtimes and the like. It is difficult, that is. This is much of the reason behind the two runtimes (Tango/Aries vs Phobos) being so incompatible. But, that's why LDC exists.
Zenith wrote:I'm sticking with my C++ foo. 8)
Awwww... (confession: I like me some C++ sometimes :oops: )

Overall, I am very impressed at the response of this thread. I will try and contribute what I can to the wiki.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS in D language

Post by AndrewAPrice »

I'm in the process of reading the D language specification (I thought reading how exactly how the language works would beat reading tutorials/samples and leaving a lot of assuming) and I'm just past halfway through. One thing I am unsure of is it says operators :: and -> do not exist.

Now if had a pointer to a struct, which had a member called foo, how would you access it.
myStruct.foo; // compiler detects myStruct is a pointer and all is good
or
(*myStruct).foo;

If the former is true, how you do know if:
myStruct = mySecondStruct;
is calling the copy constructor or making myStruct point to mySecondStruct?

I don't have a D compiler environment set up atm.
My OS is Perception.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: OS in D language

Post by quanganht »

Hey guys. I'm using Cygwin. And what the hell is this:
Image

It turns out that G++ included GDC ???
"Programmers are tools for converting caffeine into code."
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: OS in D language

Post by Love4Boobies »

I'm not sure what you're talking about. You just showed us what version of G++ you're using with Cygwin...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OS in D language

Post by Solar »

Perhaps he's surprised that he's got GDC included when he didn't ask for it. ;-)

GCC actually supports several languages beyond C/C++. (Java - or more exactly, GCJ - and Objective-C spring to mind.)
Every good solution is obvious once you've found it.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS in D language

Post by AndrewAPrice »

I just finished reading the D1.0 language specification (took roughly 8 hours on and off) from back to front completely.

I'm now inspired to write something in D. Since there seems to be a lot of issues regarding system programming in D, I should write an application. I've decided I should port my game framework to D. The C libraries (Win32, CG, etc) I depend on can be easily interfaced with D.

The only thing disappointing is interop'ing with C++ libraries (which I need for DirectX and majority of physics libraries) which is excluded from D1.0, but not from D2.0. I haven't read exactly how so, but I'm going to update myself and read the 2.0 language spec (though after reading the differences between 1.0 and 2.0 so I'm not repeating myself).

EDIT: It seems like the hard work is done for me http://www.dsource.org/projects/nonagon ... on/d3d9d.d :)
Last edited by AndrewAPrice on Wed Jan 28, 2009 6:27 am, edited 1 time in total.
My OS is Perception.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: OS in D language

Post by jal »

Wilkie wrote:Overall, I am very impressed at the response of this thread.
And I am very impressed with someone actually using D for OS deving. I considered it, but since I knew (and know) little D, and wasn't sure of the tools, I decided against it (using C++ now). Still very interested in it though!


JAL
User avatar
Wilkie
Member
Member
Posts: 44
Joined: Tue Aug 26, 2008 10:02 pm
Location: Land of the Dead
Contact:

Re: OS in D language

Post by Wilkie »

MessiahAndrw wrote:One thing I am unsure of is it says operators :: and -> do not exist.

Now if had a pointer to a struct, which had a member called foo, how would you access it.
myStruct.foo; // compiler detects myStruct is a pointer and all is good
or
(*myStruct).foo;
Both would work. All scoping is done via the dot. To do a copy, and both are pointers, you'd do

Code: Select all

(*myStruct) = (*mySecondStruct)
MessiahAndrw wrote:EDIT: It seems like the hard work is done for me http://www.dsource.org/projects/nonagon ... on/d3d9d.d :)
Hey, I know personally the guy who wrote that. I have a class with him Tuesdays and Thursdays. He wrote some of our initial stub code for the OS. The world is very small.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OS in D language

Post by AndrewAPrice »

quanganht wrote:Then a D wiki page will appear ! :)
Though I'd love to work on my OS, I have other stuff to do, so I decided to to start working on it again until I can do a full port to D (hopefully with the help of your wiki page).
My OS is Perception.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: OS in D language

Post by quanganht »

I installed Cygwin again today. And as I'm surfing the list under 'Devel', I saw there was 'gcc-gdd : D compiler' =P~ . Unbelievable. When did Cygwin add that option, and I don't even know about it :lol: . Testing now. I guess gdc will be include in gcc source code soon ~> cross-compiler no longer be the problem !
"Programmers are tools for converting caffeine into code."
Post Reply