The Case for Rust (in the base system)

I think we all are missing the point. What we need is some new hardware which enforces the memory access according to rights for any object itself. Otherwise, there will always be ways to trample on some memory you are not allowed to trample on. We can try to make languages memory safe, make one context memory safe - the system itself will not be memory safe. And we will not change that. We should invest the energy into that. Change my mind.
Unfortunately it seems to me we're going in the opposite direction. I remember reading something extolling the virtues of Web Assembly, and one of them was that it bypasses the MMU and is therefore faster... What is old is new again.

Aand I just ran into this. Part of what you want, no?
 
Secondly, if compiled codes by new compiler language like Rust to be imported cannot link with C codes, it measn ALL CODES INCLUDING WHOLE ECOSYSTEM (not disclosed but using FreeBSD as its base or platform) SHALL BE REWRITTEN ALL AT ONCE.

And that is exactly the point: yes, all codes that are not 100% trustworthy in the ecosystem must be rewritten.

Certain things are trustworthy. For example, a good OS (such as FreeBSD) can be trusted to implement things like POSIX library calls, and be exceedingly reliable and correct. In those cases, we link with the C codes. In some other cases, we can make the C code trustworthy, either by doing a complete rewrite (often to simplify it, moving complex and error-prone functionality into a safe programming environment), or by doing a thorough audit (a line-by-line code inspection by an experienced team). Otherwise, I prefer to reject the code and not link to it, since it will cause problems.

I think we mostly agree though.
 
In my humble opinion, must-kept compatibility is the ability to sanely link with codes written in C.
Well almost any language provides that (or rather the C underneath the languages provides it).

Avoiding bindings and binding generators is a good route to compatibility.

Though based on your suggestion, I think adding a tiny C frontend into the Rust language (Google Go kind of attempts this with the preamble) is a good way to go. Perhaps your specific idea of a Rust frontend on C (i.e going the other way) could work too (though I worry that people will rarely switch into Rust that way).
 
Well almost any language provides that (or rather the C underneath the languages provides it).
My assumption for Rust is --crate-type=cdylib on build commandline or #![crate_type = "cdylib"] in configuration. Am I wrong?

Avoiding bindings and binding generators is a good route to compatibility.
I think so, too.

Though based on your suggestion, I think adding a tiny C frontend into the Rust language (Google Go kind of attempts this with the preamble) is a good way to go. Perhaps your specific idea of a Rust frontend on C (i.e going the other way) could work too (though I worry that people will rarely switch into Rust that way).
If I understand correctly, LLVM generates intermediate code to use for final native code generation. So my assumption is to make LLVM have the frontend for Rust just like for C (clang) by LLVM project is the best thing to introduce for FreeBSD base.
 
So my assumption is to make LLVM have the frontend for Rust just like for C (clang) by LLVM project is the best thing to introduce for FreeBSD base.
It would possibly be a good solution. Though I do feel that it is leveraging a "gimmick" of LLVM (IL) which will make the future creation of compilers (from different vendors / technologies) difficult.

The idea could maybe be duplicated with GCC's GIMPLE but ultimately a language with only a couple of implementations will not replace C or C++.

My assumption for Rust is --crate-type=cdylib on build commandline or #![crate_type = "cdylib"] in configuration. Am I wrong?
I don't think you are wrong, but ultimately this isn't really needed either (Dynamic linking is just a bonus). The .o files can be directly linked by any language that supports native code (provided that name mangling and calling convention have been cleaned up).
 
Though I do feel that it is leveraging a "gimmick" of LLVM (IL) which will make the future creation of compilers (from different vendors / technologies) difficult.
If the (future candidates of) compilers supports all languages that FreeBSD base is using at the moment and every objects it generates (from any of the supported languages) links together sanely, there would be no (or less, if its object format is different from LLVM's ELF and not 100% assured to be linked together) problem.


(provided that name mangling and calling convention have been cleaned up)
I thought cdylib is mandatory for it, reading Linkage part of The Rust Reference. staticlib doesn't seem to be good enough, especially for cases the Rust part is depending on (still not rewritten or impossible to be rewritten mutually-unsafe-as-of-hardware-spec drivers) C codes.
 
It would possibly be a good solution. Though I do feel that it is leveraging a "gimmick" of LLVM (IL) which will make the future creation of compilers (from different vendors / technologies) difficult.
Yes, and LLVM is relatively young. It's unlikely, but not impossible, that some new compiler collection could arise to compete with GCC and LLVM.
 
See how efficient C++ is with memory? What? Sure, I'll get my coat...
?

You are not the first one to make that mistake, I know I did (and will likely do again some time). Every language has such traps, or it is not a true scot... a real language.
Sure, all languages have rough edges, but a read that has a write as a side-effect? That doesn't just violate the POLA, that's world-class BS semantics.
 
Sure, all languages have rough edges, but a read that has a write as a side-effect? That doesn't just violate the POLA, that's world-class BS semantics.
It is the problem with the definition of what to do if a key does not exist. It makes sense to provide the default item for writes (as it will be overwritten) but not for reads. If the language would distinguish between l-value and r-value references, it could be solved. You might throw an exception then, or return a default. But that is not possible (to my knowledge), so we need to manually check if the key is present before reading it. Or only map classes where the default constructor traps to the debugger.

Using well thought out class libraries is fun, but making them is bloody hard.
 
It is the problem with the definition of what to do if a key does not exist. It makes sense to provide the default item for writes (as it will be overwritten) but not for reads. If the language would distinguish between l-value and r-value references, it could be solved. You might throw an exception then, or return a default. But that is not possible (to my knowledge), so we need to manually check if the key is present before reading it. Or only map classes where the default constructor traps to the debugger.

Using well thought out class libraries is fun, but making them is bloody hard.
Yep, you put some effort up front, and it will pay off big time in the long run. ?
 
It is the problem with the definition of what to do if a key does not exist.
Like say, for example, return null? But that's not allowed with C++ references. It's a feature, not a bug. Languages without null struggle with expressing "don't know" which is important, it turns out.

Read the comments for some spicy internal Rust politics. That, more than anything, has confirmed my bias. I'll be skipping that language.
 
The Debian problem shows what happens when your entire OS including applications is in "very stable" mode with only bugfixes backported. We all know that FreeBSD packages run into problems every now and then, but at least the whole shebang is reasonably up-to-date and you could carry forward Rust ports that require a recent Rust.
 
I'm glad we have the Ports Framework. IMO it serves as a sort of mediator for these kinds of language/ecosystem problems. FreeBSD encountered a similar situation when the committers imported perl in base awhile back. We have learned.
 
Looks reasonable for Proof-of-Concept, unless external crates are used directly.
No it doesn't, there are many things wrong with his opinion; for example:

Meaning, all userland components written in Rust will be optional
What the hell is an "optional" component? It goes against one of FreeBSD's key concepts of a deterministic "base" install. There is nothing in FreeBSD that allows that, not even the damage that PkgBase is going to do will handle this.

Besides, Rust can't even wipe its own butt without a couple of hundred crates/dependencies/bindings. External or not, the FreeBSD maintainers cannot maintain that ever moving target.

This is NOT a call to rewrite everything in Rust. This work will only permit NEW, OPTIONAL components to be written.
So his goal is to reach a large number of new components, then whine that FreeBSD is missing out on "all this great stuff" and then push to make them non-optional. This will happen in ~3 years and be premature, pulling in a load of crap. Instead, new components should be written in C, so then every one can benefit and no mess is made.

Broken idea. If he likes non-standard languages, thats fine! He can still make some cool software that belongs in ports. This is exactly what the ports collection is there for.
 
No it doesn't, there are many things wrong with his opinion; for example:

What the hell is an "optional" component? It goes against one of FreeBSD's key concepts of a deterministic "base" install.

Besides, Rust can't even wipe its own butt without a couple of hundred crates/dependencies/bindings. External or not, the FreeBSD maintainers cannot maintain that ever moving target.
Don't forget that this is a Proof-of-Concept, investigating how to define the starting point (or stop starting). Just my guess.
So there still can be an option not to.

Optional could mean something FreeBSD base does NOT yet have, no?
I don't assume trying rewrites of existing component is not an optional thing.

Same functionality with different name would be OK until on "optional" phase. As it can be removed later (because it's optional).
 
Don't forget that this is a Proof-of-Concept, investigating how to define the starting point (or stop starting). Just my guess.
So there still can be an option not to.
The Rust community is a niche minority so don't have the man-power to truely undertake a thorough investigation. Instead they just want to generate lots of noise and reach maximum market penetration with what little resources they have available in the vague hope that they can trap others into their broken ecosystem.

Optional could mean something FreeBSD base does NOT yet have, no?
No I don't think that seems right. FreeBSD's base often gets new additions. None of them are optional; they are either in base or in ports. Perhaps he means filesets you can choose during the installer?
  • kernel.txz
  • base.txz
  • rust_crap.txz
 
As a data point where all this can (hopefully) end, here we will be graced with a new ELF section. What will happen with rust when allowed to roam freely? Resource forks in files for all the dependencies they need per file? We had that already and I am not going from zfs to ntfs...
 
The Rust community is a niche minority so don't have the man-power to truely undertake a thorough investigation. Instead they just want to generate lots of noise and reach maximum market penetration with what little resources they have available in the vague hope that they can trap others into their broken ecosystem.
Much larger ecosystem like python would have the same problem. Too large to manage by themselves. Too rapid growth easily makes such situations.
So I dislike the idea to use crates in Rust ecosystem into FreeBSD base.
In my humble opinion, crates used as non-leaf ports should be managed just like rubygem-, p5-* or py-* and built as libraries to be dynamically linked with their consumers (like graphics/librsvg2-rust can be linked against non-Rust consumers).

No I don't think that seems right. FreeBSD's base often gets new additions. None of them are optional; they are either in base or in ports. Perhaps he means filesets you can choose during the installer?
  • kernel.txz
  • base.txz
  • rust_crap.txz
Not sure at this moment. But possibly, only if merged into base. Anyway, Shawn would be mentored by Warner (and maybe by Alan, too) for this Proof-of-Concept.
 
Much larger ecosystem like python would have the same problem.
Agreed. Python and Rust are not core parts of production operating systems because of this.

Shawn would be mentored by Warner (and maybe by Alan, too) for this Proof-of-Concept.
Based on the mailing lists, I don't feel Alan is a good choice (if I recall, he only pushed for Rust because he didn't understand and was unwilling to learn correct C++ in the FUSE subsystem). Hopefully they don't wear Warner down and exhaust him with nonsense.
 
And that's coming on the heels of "Nontechnical nonsense" !
Dunno, the "nonsense" sounds pretty reasonable and technical to me:
View: https://www.youtube.com/watch?v=WiPp9YEBV0Q&t=1529s


Also, shades of kpedersen. Not only do the "rustaceans" want to inflict oodles of ugly and complicated bindings on C developers, they expect the C developers to maintain them too!
 
I watched this once and it was painful, so this is just my recollection.

The Rust guy was asking for formal interfaces and the C people were yelling about having to do Rust if they wanted to update the interface. What the Rust people were trying to explain is that in that situation, you update the interface definition, then all the adherents have to update, making it incumbent on the C people to update the C and the Rust people to update the Rust.

The C people seem to think "code is law" and that by definition, updating the interface definition means "code in C".
 
Back
Top