Hacker News new | ask | show | jobs
by skohan 2525 days ago
There seems to be a certain train of thought within the Rust community that unsafe languages are fundamentally invalid. I saw a comment on another forum claiming that C++ was even unsuitable for personal, experimental projects because unsafe code == undefinted behavior, and therefore your program produces "random results" which would not be fit for, say, scientific inquiry.

Apparently the Linux kernel, and all code written before 2010 is just completely random!

1 comments

> Apparently the Linux kernel, and all code written before 2010 is just completely random!

The Linux kernel is well known to be completely random when considered as a C program: building something useful out of it relies on a particular set of flags and ad-hoc implementation details of GCC (e.g. -fno-delete-null-pointer-checks).

> building something useful out of it relies on a particular set of flags and ad-hoc implementation details of GCC (e.g. -fno-delete-null-pointer-checks).

That makes it esoteric, not random. If the Linux kernel really did produce "random output" there is no way it would serve as the backbone of the global computing infrastructure, the financial system etc.

From my observations, there seem to have been considerable efforts to avoid it being just random. Compiler & library "optimisations" have broken Linux before ("randomly") [0] [3]. Linus has ranted about this [1], multiple times [2] [3].

[0] https://lwn.net/SubscriberLink/793253/6ff74ecfb804c410/

[1] https://lkml.org/lkml/2018/6/5/769

[2] https://bugzilla.redhat.com/show_bug.cgi?id=638477#c129

[3] http://lkml.iu.edu//hypermail/linux/kernel/1407.3/00650.html

> That makes it esoteric, not random. If the Linux kernel really did produce "random output" there is no way it would serve as the backbone of the global computing infrastructure, the financial system etc.

To the extent that Linux is useful, it's not written in C. The particular binaries produced by GCC with particular flags have particular behaviour, more or less, but considered solely as a C program in terms of the C standard (i.e. behaviour on the C abstract machine), Linux does produce random output.