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!
neonek
Member
Member
Posts: 38
Joined: Thu Aug 28, 2008 1:53 pm
Location: Białystok - Podlasie, Poland

OS in D language

Post by neonek »

Hi!
What do you think about writing OS in D language ? Please comment what do you think about it, what are advantages and disadvantages.

Regards,
Mark
Please correct my English. If you'll find mistake please tell me about it so I can improve my English.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: OS in D language

Post by AJ »

One obvious disadvantage is that it is unusual.

You need to be very familiar with the language and toolchain and need to be proficient enough to read design documents and examples, and convert those to D. You will also find a smaller base of people able to help you if you get stuck.

Other than that, I'm afraid I don't know enough about D to give you any more advice :)

Cheers,
Adam
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 »

D is a pretty good language for OSDeving as it's both pretty high level and produces native bytecode. It actually was intended for system programming. I don't know much about it either but you will find everything you need on its official webpage (clicky).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
neonek
Member
Member
Posts: 38
Joined: Thu Aug 28, 2008 1:53 pm
Location: Białystok - Podlasie, Poland

Re: OS in D language

Post by neonek »

Hmm... I thought there is very small number people which can help :cry: I don't know D very well too. So I will stay with C++ in osdev. Thanks guys :)

Regards,
Mark
Please correct my English. If you'll find mistake please tell me about it so I can improve my English.
NReed
Posts: 24
Joined: Wed May 28, 2008 10:56 pm

Re: OS in D language

Post by NReed »

I was able to get an operating system in D to boot and display a hello world.

If i remember correctly, I used the dmd compiler (the flags were just general ones to make sure no stdlib) to compile each .d file to a .o and followed the same build process as any old c/c++ operating system.

However, I got stuck once I tried to use any structures. It appeared the dmd depends on a runtime for structures, but I couldn't find the dependencies. ( I got lazy :roll:)

Here is a microkernel in d. The source code can be an useful tool.

EDIT:
BTW, if anyone was able to figure out how to get structures/arrays to work, I'd like to hear how to do it, since D is my language of choice.
Last edited by NReed on Fri Jan 16, 2009 9:44 pm, edited 1 time in total.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: OS in D language

Post by jal »

I have been contemplating using D in the past, but decided against is due to unfamiliarity and the D garbage collection, which can be turned off, but that's a hassle. It does have some nice features 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 »

neonek,

D is a systems language, so it works very well as a language for a kernel. Well, obviously the static subset of the language. I am one of the lead developers of an exokernel written in D. We use Linux as a development environment, and therefore gdc. Have a look at our repository. I think in src/kernel/core/dstubs.d you will find the stubbed out runtime.
  • Pros:
  • It is a modern systems language that your kernel will be able to then support natively
  • Powerful code generation with "mixins" (see /src/kernel/arch/x86_64/idt.d)
  • Strong, yet simple, meta-programming over C++ (It is similar to a functional language) (see /src/kernel/core/util.d)
  • Supports inline assembly and naked keyword (portability is a concern, however)
  • Allows usage of the C ABI for functions through 'extern(C)'
  • The above also means you can link to C functions and assembly routines
  • Guaranteed type lengths for integers. (ubyte = 1 byte .. ulong = 8 bytes)
  • C-like (easy to learn)
  • No *.h files!
  • Cons:
  • Not likely to find much D code available.
  • Not likely to find many people with knowledge of the language.
  • The compiler has a couple of annoying cosmetic bugs.
  • Building a cross compiler has some difficulty (especially for 64-bit builds)
  • Two competing runtimes to port: tango and phobos
  • D 2.0 is not backwards compatible with version 1.0 of the language
If you choose to work with D, our team and myself will be fairly happy to help you.
NReed wrote: BTW, if anyone was able to figure out how to get structures/arrays to work, I'd like to hear how to do it, since D is my language of choice.
Hmm, they work fairly well for us. You are correct, it is probably a runtime thing and how you stubbed. We don't use the dmd compiler, but gdc uses the same codebase (unfortunately). I'm at a loss. Have a look at our repo, specifically the runtime in dstubs.d. Dust off your code and get that OS up and running! No excuses!

--
Wilkie
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 »

Wilkie wrote:No excuses!
What the... :shock: :D
Every good solution is obvious once you've found it.
neonek
Member
Member
Posts: 38
Joined: Thu Aug 28, 2008 1:53 pm
Location: Białystok - Podlasie, Poland

Re: OS in D language

Post by neonek »

Great Wilkie. Thanks for link. I see I must learn more D lang before i'll start os development in this language. And what are that bugs in compiler ? Anyway thanks.

PS What is bad with header files ?

EDIT: Maybe, Wilkie you'll add some info about basic setup in D to wiki ?
Please correct my English. If you'll find mistake please tell me about it so I can improve my English.
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 »

neonek wrote:PS What is bad with header files?
You have to keep them in-sync with your implementation files, and a change in a single header can result in having to recompile basically the whole project. Those are the disadvantages I can think of right away.

I always felt the biggest advantage of them being that they nicely define the "public interface" of your code, without the actual implementation getting in the way. With Java, for example, you need Javadoc or a good IDE to do for you what a C/C++ header can tell you in the same lame text editor you use for coding.
Every good solution is obvious once you've found it.
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 »

Solar wrote:I always felt the biggest advantage of them being that they nicely define the "public interface" of your code, without the actual implementation getting in the way.
Luckily, the language developer agrees, so you can have both if you need it. Here is the description. Basically, you have have these D Interface files that act much like header files would. Yet, they are generated by the compiler from the source, so you don't need to maintain them separately. It is a compiler feature, so it may not be in all compiler implementations.
neonek wrote:And what are that bugs in compiler ?
There are some issues with the templating, but they aren't a big deal. I forget exactly, but it doesn't like to iterate through a list of strings at compile time or something. You can make it a tuple instead, and its just an extra operation. (ran into this in /src/user/syscall.d)

D has an import syntax for including code modules. It breaks when you have circular imports with a depth of 2 or more. There is an annoying workaround. (ran into this EVERYWHERE)

And the errors that it reports are complete nonsense at times. (it's all in good fun)
neonek wrote:Maybe, Wilkie you'll add some info about basic setup in D to wiki ?
Certainly seems possible. I did not have much involvement with that aspect, but I'll ask around. We have been pushing documentation as of lately, and one of the visions of the project is to provide an academic outlet, and thus provide as much information about the particulars of implementation. This is definitely one facet of the development we had forgot to document. I'll throw it on the task queue :)
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 »

Wilkie wrote:Luckily, the language developer agrees, so you can have both if you need it. Here is the description. Basically, you have have these D Interface files that act much like header files would. Yet, they are generated by the compiler from the source, so you don't need to maintain them separately. It is a compiler feature, so it may not be in all compiler implementations.
Is this something akin to Pascal?
"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 »

I've seen something like that (automatic header generation from source) done for C++, too: A nice little Perl script that was actually quite fun to use, because it also took care that your headers didn't include anything they didn't really require. (Many C++ coders never got the idea of forward declarations.) Too bad it was company property...
Every good solution is obvious once you've found it.
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 »

Wilkie, mind if I wikify some of the stuff you said? We don't have anything about the D language on our wiki...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
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 »

The linker script is some kind of troubles too.
"Programmers are tools for converting caffeine into code."
Post Reply