www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Can D be used for operating system development ?

reply Jakob Jenkov <jjd duniverse.code> writes:
Is it feasible / practical to use D to develop an operating 
system from the ground up? Or does the VM / memory management get 
in the way?
Jun 02 2022
next sibling parent Adam D Ruppe <destructionator gmail.com> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
Sure, I've done a few bare metal applications with D in the past (most recently, my little webassembly toys use the same technique, though webassembly isn't exactly the same on hardware level obviously, it still acts as a bare metal target as far as plain code goes). In my "D Cookbook" I had two examples, one for x86 and one for arm, showing it. It has gotten easier than it was back then, but you still have to do a lot yourself though, but that's true for any kind of OS dev. Not something you'd want to take on without already being pretty familiar with D, and knowledge its druntime internals help a lot if you want to take it to the next level using more language features.
Jun 02 2022
prev sibling next sibling parent matheus <matheus gmail.com> writes:
https://github.com/PowerNex/PowerNex

https://dlang.org/areas-of-d-usage.html

Matheus.
Jun 02 2022
prev sibling next sibling parent Sergey <kornburn yandex.ru> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
I don’t know But there are plenty of authors who could have some useful opinions: https://github.com/dlang-community/awesome-d#os
Jun 02 2022
prev sibling next sibling parent max haughton <maxhaton gmail.com> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
There are some features you might want to avoid but if you look at the instructions the compiler generates you can see that you can do basically anything.
Jun 02 2022
prev sibling next sibling parent Paulo Pinto <pjmlp progtools.org> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
Surely, as the others have pointed out, there are some examples already. A small secret when people talk about C being used to write OSes is that you aren't really using ISO C on the kernel, rather a language subset, and the full language is only available for the userspace stack. D can be used just as well, and don't let the GC put you off, here are some examples of OSes written in safe systems programming languages. https://www.progtools.org/article.php?name=oberon§ion=compilers&type=tutorial https://www.progtools.org/article.php?name=safe_systems§ion=compilers&type=tutorial
Jun 02 2022
prev sibling next sibling parent reply Olivier Pisano <olivier.pisano laposte.net> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
There is no such thing as a VM in D, and yes D can be used for operating system development.
Jun 02 2022
parent JakobJenkov <jj dwonders.exo> writes:
On Friday, 3 June 2022 at 06:33:52 UTC, Olivier Pisano wrote:
 On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
There is no such thing as a VM in D, and yes D can be used for operating system development.
I should have written "GC" .. not "VM" ... sorry !!
Jun 07 2022
prev sibling next sibling parent RazvanN <razvan.nitu1305 gmail.com> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
This is an example of a device driver that has been ported to D and integrated in the linux kernel: https://github.com/alexandrumc/d-virtio/pull/1.
Jun 03 2022
prev sibling next sibling parent reply Siemargl <inqnone gmail.com> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
Just add Serpent OS to list. https://serpentos.com Linux Kernel and userspace in D.
Jun 06 2022
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 6/6/22 06:03, Siemargl wrote:
 On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating system
 from the ground up? Or does the VM / memory management get in the way?
Just add Serpent OS to list. https://serpentos.com
Very interesting. I've just learned that the lead developer is Ikey Doherty, a name I don't recognize. Does he appear on D forums? (To make it more interesting to me, there is some Turkish connection as well, which I had not heard of either.)
 Linux Kernel and userspace in D.
And many other parts but not the kernel, right? As I understand it, the kernel is being developed by a completely different group: https://en.wikipedia.org/wiki/Linux_kernel Ali
Jun 06 2022
prev sibling parent reply IGotD- <nise nise.com> writes:
On Thursday, 2 June 2022 at 20:36:59 UTC, Jakob Jenkov wrote:
 Is it feasible / practical to use D to develop an operating 
 system from the ground up? Or does the VM / memory management 
 get in the way?
Yes you can write operating systems in D. However you cannot use many parts of druntime/phobos because 1. There is no "no OS" target to build druntime/phobos. 2. Many containers in D/Phobos use GC which makes them unsuitable for kernel development. You probably need to write all your container algorithms yourself. It doesn't though because they need to be special anyway. You are bascally using D without standard libraries. This about the same with C/C++.
Jun 07 2022
parent reply Sergey <kornburn yandex.ru> writes:
On Tuesday, 7 June 2022 at 11:27:18 UTC, IGotD- wrote:
 2. Many containers in D/Phobos use GC which makes them 
 unsuitable for kernel development.

 You probably need to write all your container algorithms 
 yourself. It doesn't though because they need to be special 
 anyway.

 You are bascally using D without standard libraries. This about 
 the same with C/C++.
Actually there are LOT of different realisations.. not only containers, but Core libraries. And as a end-user I have no idea how all of them are different from each other. There are Mecca, Tanya, Hunt - core libraries. Emsi, ikod and collection-d containers. And of course there is the whole Mir world, with nogc and betterC paradigm inside.
Jun 07 2022
parent IGotD- <nise nise.com> writes:
On Tuesday, 7 June 2022 at 11:57:58 UTC, Sergey wrote:
 Actually there are LOT of different realisations.. not only 
 containers, but Core libraries. And as a end-user I have no 
 idea how all of them are different from each other.

 There are Mecca, Tanya, Hunt - core libraries.
 Emsi, ikod and collection-d containers.

 And of course there is the whole Mir world, with nogc and 
 betterC paradigm inside.
What would be really interesting is if D had a library specifically targeted for low level/operating system development. That would include things like intrusive container algorithms, lock less data structures and so on. Even better if these also could use the Phobos range algorithms. Something that I think should be done with Phobos is to isolate the non OS dependent stuff such ranges, algorithms (must be GC free) so that it can be compiled separately. Today Phobos is like ball of thread where you cannot isolate the components from each other.
Jun 07 2022