Jump to page: 1 2
Thread overview
Linux Kernel in D?
Nov 01, 2016
Heisenberg
Nov 01, 2016
Edwin van Leeuwen
Nov 01, 2016
cym13
Nov 01, 2016
Daniel Kozak
Nov 01, 2016
Satoshi
Nov 01, 2016
Wild
Nov 01, 2016
bachmeier
Nov 02, 2016
qznc
Nov 02, 2016
Karabuta
Nov 01, 2016
Karabuta
Nov 01, 2016
Wild
November 01, 2016
Just an idea. Do you think it would have any advantage compared to the one that is written in C?
November 01, 2016
On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
> Just an idea. Do you think it would have any advantage compared to the one that is written in C?

There have been a number of projects working on this. For example:
https://github.com/Vild/PowerNex
November 01, 2016
On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
> Just an idea. Do you think it would have any advantage compared to the one that is written in C?

It would have advantages : most kernel vulnerabilities are due to buffer overflows, use-after-frees and such that are directly linked to the use of C. While it is possible to have these bugs in D they require that you go out of your way (using raw pointers instead of slices for example) which makes them less likely to happen.

On the other hand "normal D" cannot be used for the kernel as you need to grow a specific druntime that is able to manage memory allocations and such without depending on an existing kernel, so it's work.
November 01, 2016
Dne 1.11.2016 v 13:12 Heisenberg via Digitalmars-d napsal(a):

> Just an idea. Do you think it would have any advantage compared to the one that is written in C?
Same as any other software written in C. C is unsafe so in D it should be more safe and easier to mantain
November 01, 2016
On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
> Just an idea. Do you think it would have any advantage compared to the one that is written in C?

Look at https://github.com/Rikarin/Trinix for example
November 01, 2016
On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
> Just an idea. Do you think it would have any advantage compared to the one that is written in C?

I think it wouldn't really be worth it. You have to make a custom runtime and
a custom standard library. Because most of the awesome D features are for the
standard library and not directly from the language itself.
Porting the Linux kernel to D language to fix a few bugs isn't really worth it,
if you have to implement all the stuff I mentioned.

It is better to instead design a new kernel from scratch, and structure everything
in a way that seems more logical for D code. This is what I target with my kernel
PowerNex (The current code structure is horrible, I'm currently planning to fix
it so it matches the D style).

Conclusion: Yes D features could probably fix bugs in the Linux kernel and make it
more safe, but you need to implement a lot of extra code just to be able to use
basic D features. So it wouldn't be worth it.

- Dan
November 01, 2016
On 11/01/2016 09:41 AM, Wild wrote:
> On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
>> Just an idea. Do you think it would have any advantage compared to the
>> one that is written in C?
>
> I think it wouldn't really be worth it.

I tend to think the same but for different reasons. Currently the Linux kernel is a large mature product that has its own evolution. It would be very difficult to reimplement it from first principles in any other language and get a competitive, timely product.

As an intellectual exercise, D's safety would help but at this point impart little advantage; the kernel has reached good stability and safety bugs are few and far across. This trend is likely for the foreseeable future.

One thing where D would be able to help quite a bit more is code size. D has better abstraction abilities than C (or C++) and using those would allow eliminating a lot of subtle duplication in kernel code. Consequently we'd be looking at a lower bug rate, better maintainability etc. I estimate that a 25% reduction in LOC is easily attainable. However, the dynamics of large projects makes even this relatively high reduction of little value. You'd not be looking at enjoying 25% savings, but instead at rebuilding 75% of the project. Because of that, you'd need a reduction of one order of magnitude to make the alternative appealing.


Andrei

November 01, 2016
On Tuesday, 1 November 2016 at 16:22:58 UTC, Andrei Alexandrescu wrote:

> As an intellectual exercise, D's safety would help but at this point impart little advantage; the kernel has reached good stability and safety bugs are few and far across. This trend is likely for the foreseeable future.

It would not be unreasonable to write new code in D. It's not as though safety is the only advantage that D brings to the table. This would have to be a fork, and wouldn't likely be of much interest to most Linux users/developers, but maybe there is room to optimize the kernel for a specific application that is also written in D. Using D rather than C would greatly reduce the cost of getting into kernel development.
November 01, 2016
On Tuesday, 1 November 2016 at 13:41:04 UTC, Wild wrote:
> On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
>> Just an idea. Do you think it would have any advantage compared to the one that is written in C?
>
> It is better to instead design a new kernel from scratch, and structure everything
> in a way that seems more logical for D code. This is what I target with my kernel
> PowerNex (The current code structure is horrible, I'm currently planning to fix
> it so it matches the D style).

Really excited to see that you plan to improve the code style to fit D's. I glanced through your code and that was the only killer issue (IMO).


November 01, 2016
On Tuesday, 1 November 2016 at 20:11:13 UTC, Karabuta wrote:
> On Tuesday, 1 November 2016 at 13:41:04 UTC, Wild wrote:
>> On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
>>> Just an idea. Do you think it would have any advantage compared to the one that is written in C?
>>
>> It is better to instead design a new kernel from scratch, and structure everything
>> in a way that seems more logical for D code. This is what I target with my kernel
>> PowerNex (The current code structure is horrible, I'm currently planning to fix
>> it so it matches the D style).
>
> Really excited to see that you plan to improve the code style to fit D's. I glanced through your code and that was the only killer issue (IMO).

I realized that it was too different from the code style that most
D people use and I don't really know if I liked that style.

Hopefully the new code style will fit the project better.
https://github.com/Vild/PowerNex/blob/master/Codestyle.org
« First   ‹ Prev
1 2