Discussion:
Some rather stupid questions about Rust and FreeBSD
(too old to reply)
Aryeh Friedman
2024-09-11 21:26:34 UTC
Permalink
Let's start with the only thing I know about Rust is it is some
language that is all the rage among in some corners and not in others.
I have built it in ports before when just setting a normal old XFCE4
desktop and looked at some sample code in it from that I will say:

1. It takes FOREVER to compile
2. The code looks no better than portable assembly and if that is the
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?

So to help me understand all this fuss can people tell the
journalistic (who, what, when, how and why) for the following:

1. What exactly is Rust?
2. What's all the fuss about it over (both here and the larger
computing community)?
3. What is the entire debate about ports vs. base and why should a
normal user care?
--
Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Alan Somers
2024-09-11 23:02:10 UTC
Permalink
Post by Aryeh Friedman
Let's start with the only thing I know about Rust is it is some
language that is all the rage among in some corners and not in others.
I have built it in ports before when just setting a normal old XFCE4
1. It takes FOREVER to compile
I assume you mean lang/rust. It does take FOREVER to compile, because
it builds its own version of LLVM. That's why I suggest adding it to
ALLOW_MAKE_JOBS_PACKAGES , if you're using Poudriere. Ordinary Rust
programs generally compile at a similar speed as C programs. Slower
than Go, but faster than C++.
Post by Aryeh Friedman
2. The code looks no better than portable assembly and if that is the
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?
I don't know if you're being serious or trolling. I ought to assume
the former, but if you genuinely can't tell the difference between
Rust and assembly source code then you obviously haven't looked at one
or the other for more than a few seconds. So I think you must be
exaggerating, and you really mean "Rust looks no more or less readable
than C". For a good example of why Rust (and other modern languages)
can be more readable than C, compare these examples, which sort an
array:

in C
====
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}

int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
qsort(arr, n, sizeof(int), compare);

in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();

The most visible difference is that C needed a comparison function to
be provided, and that function must be defined far away from where the
sort happens. With Rust, the comparison operator is a property of the
data type (technically, it's defined by the data type's PartialOrd
implementation, which can be derived automatically for most structs
but can also be manually implemented). But readability isn't the
important part. Notice that in C, the programmer must tell qsort
* The size of the array
* The size of each element
* The name of the comparison function

Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
Post by Aryeh Friedman
So to help me understand all this fuss can people tell the
1. What exactly is Rust?
It's a compiled, strongly and statically typed, memory-safe, systems
programming language. It first appeared 9 years ago, sponsored mostly
by Mozilla. Mozilla was interested because web browsers are too
complicated to reliably program in C/C++, but too performance-critical
for other memory-safe contemporary languages like Java or Go.
Post by Aryeh Friedman
2. What's all the fuss about it over (both here and the larger
computing community)?
The computing community in general is excited because Rust really hits
a programming language design sweet spot. Modern features like
modules and procedural macro make Rust highly productive. Its safety
features make Rust code more reliable than C/C++ code. And yet most
of that safety is achieved at compile-time, incurring 0 runtime
overhead. So Rust is faster than other memory-safe languages like
Java and Go. Crucially, it isn't memory-managed like those two, so
it's suitable for systems programming and even for embedded systems.
Post by Aryeh Friedman
3. What is the entire debate about ports vs. base
At this time, there is absolutely no reason not to use Rust for
programs that will live in ports. Nobody is arguing about that.
However, there is quite a lot of code in the base. Much of it can't
move to ports, because it's too tightly coupled to the kernel or to
other stuff in base. And the fact that we ship our own compilers in
base limits the base to sh, C and C++ (plus a little bit of Lua).
That limitation is a big impediment to both our productivity and our
code quality. Some of us would like to use better languages in the
base (mostly Rust, but Go and Oberon fans have chimed in too), but it
just isn't possible. Making it possible would require either:

1) Importing the Rust toolchain into contrib/ (currently the least
favored option, because compile times are too long)
2) Allowing some parts of the base to depend on an external toolchain
(what Shawn Webb is currently working on)
3) Being more like Linux, meaning that the base system will slim down
to be little more than a kernel while many other programs move to
ports.
Post by Aryeh Friedman
and why should a normal user care?
It probably won't make a difference to a pure desktop user or a
non-programming sysadmin. If anything, they'll just notice that their
operating system of choice gets less buggy. Error messages might look
a little bit different. The size of the .iso download might increase.
But it will make a big difference to developers, even occasional ones.
We'll all be more productive, and we'll build a higher-quality
product. Occasional developers will have more confidence that their
changes won't cause regressions.

I hope that helps.


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Aryeh Friedman
2024-09-12 00:11:03 UTC
Permalink
Post by Alan Somers
Post by Aryeh Friedman
2. The code looks no better than portable assembly and if that is the
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?
I don't know if you're being serious or trolling. I ought to assume
the former, but if you genuinely can't tell the difference between
Rust and assembly source code then you obviously haven't looked at one
or the other for more than a few seconds.
If I had wanted to troll instead of genuinely out of pure curosity I
could of compared all three languages to a language I am currently
writting to use in a forth come PhD thesis that is purefly function,
gate level (with abstractions allowed), has no explicit flow control
except for calling functions and few other really oddball things.
But I am not going to say anything more about that and instead focus
on why I made the comment I did:

1. C when super optimized has about a 2 to 1 ratio between expressions
and emitted machine instructions but it self is semantically much
easier to deal with then assembly and the fact it is a high level
language means it in theory portable to any machine a compiler is
implemented on.

2. I consider assembly fairly high level actually compared to the
topic I am not trolling on (I am at the level of building UTM's from
gates)
Post by Alan Somers
So I think you must be
exaggerating, and you really mean "Rust looks no more or less readable
than C". For a good example of why Rust (and other modern languages)
can be more readable than C, compare these examples, which sort an
in C
====
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
I completely agree pointers are evil and that's why I (like Rust it
appears) *ONLY* allow arrays and array references not direct pointers
into physical address space. This way we still have the advantage of
being able to use base+offset addressing modes instead of having the
language processor/executor compute absolute addresses at run time.
Post by Alan Somers
int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
qsort(arr, n, sizeof(int), compare);
So C is not OO (what a surprise ;-)) but it does do one thing right is
it separates out the concerns of storage from processing at the lowest
levels (hard to get above that level and that is why I use Java for my
freelancing work). Which when working in any language is a good idea
but since C is not OO we are stuck with naked function calls (no harm
in that)
Post by Alan Somers
in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();
The fact the data structure even worries about behaviour instead of
being passable to objects is asking for it (this is from my software
engineering hat). Also the fact there is no explicit size of the
array defined since if it is static a Turing complete process can be
implemented on it but if it is dynamic how do you keep from
overflowing the storage allocated to it (aka buffer overflow).
Post by Alan Somers
* The size of the array
Very good idea from the resource management POV
Post by Alan Somers
* The size of each element
Again correct call for an OS level language.
Post by Alan Somers
* The name of the comparison function
Separation of concerns *STANDARD* software engineering.
Post by Alan Somers
Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
At the cost of coupling stuff far too tightly it appears.


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
B. E.
2024-09-12 02:45:21 UTC
Permalink
Post by B. E.
Post by B. E.
It doesn't matter the technicalities, Rust enthusiasts are looking for
relevancy in a post-language wars world; and they think falsely that their
only recourse is to invade established camps.
Nobody is invading anything. Myself and the other Rust boosters have
been involved with FreeBSD for longer than Rust has existed.
Post by B. E.
I feel sorry for them in a lot of ways, but this is the time for them to
be discovering problem domains or creating solutions that Rust is uniquely
good for; and not copying or corrupting established technical communites.
Augmenting FreeBSD somehow is not a legitimate problmem domain nor is it
something uniquely solved by Rust. Don't be a solution in search of a
problem is my best advice to the Rust community - unfortunately much of the
low hanging problems have been picked; but there are plenty of slightly
less easy problems to solve.
Systems programming IS the problem domain that Rust is uniquely good
for. Nor do we have a solution in search of a problem. As I've
explained elsewhere on this list (but you can 100% be forgiven for
overlooking; there've been a lot of posts), I've already encountered
many problems within FreeBSD that could've easily been solved by Rust.
Being experienced with both C and Rust, but being forced to use the
* I considered writing the fusefs test suite in Rust. It would've
been well-suited. But I was forced to do it in C++ instead.
* I tried to write a prometheus exporter for CTL in Rust. But when I
realized that the API is unstable, I had to abandon using ports, which
meant that I had to abandon using Rust, and use C instead.
* I had to fix several file-parsing and memory-handling bugs in ctld.
Just to help myself understand the code, I rewrote part of it in Rust.
The portion that I rewrote took about 5.5x less code and was free of
memory-handling bugs. But I can't finish it, because the src tree
currently only allows C and C++.
* ALL of the recent security advisories involved memory handling bugs.
We obviously can't rewrite all of the affected components overnight,
but those SAs should serve as a wake-up call that C is insufficient
for developing reliable and secure software. Any components that we
can rewrite will improve the quality of our project.
Post by B. E.
So, this is ideologically and existentially driven, and rational
arguments are not enough (FreeBSD is not experiencing this alone). Setting
extremely hard boundaries, in charity, is the only answer. I am a mere
casual but consistent user of FreeBSD from a long time ago, and I very
strongly support all firm (but charitable) opposition to Rust being
required to run FreeBSD.
I've noticed that the most vociferous opposition to using Rust in
FreeBSD comes from users like yourself: casual users who do little to
no development of FreeBSD. If you aren't a developer, then what are
you afraid of? Longer compile times when updating your desktop from
src? If Shawn Webb's project works out, then you won't have to worry
about that. A larger .iso for installation? Even the smallest thumb
drives are now larger than our dvd image. Please explain to me: what
negative impact do you foresee for yourself?
This ^

Cheers,
Brett
Post by B. E.
-Alan
Post by B. E.
Cheers,
Brett
Post by Aryeh Friedman
Post by Alan Somers
Post by Aryeh Friedman
2. The code looks no better than portable assembly and if that is
the
Post by B. E.
Post by Aryeh Friedman
Post by Alan Somers
Post by Aryeh Friedman
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?
I don't know if you're being serious or trolling. I ought to assume
the former, but if you genuinely can't tell the difference between
Rust and assembly source code then you obviously haven't looked at one
or the other for more than a few seconds.
If I had wanted to troll instead of genuinely out of pure curosity I
could of compared all three languages to a language I am currently
writting to use in a forth come PhD thesis that is purefly function,
gate level (with abstractions allowed), has no explicit flow control
except for calling functions and few other really oddball things.
But I am not going to say anything more about that and instead focus
1. C when super optimized has about a 2 to 1 ratio between expressions
and emitted machine instructions but it self is semantically much
easier to deal with then assembly and the fact it is a high level
language means it in theory portable to any machine a compiler is
implemented on.
2. I consider assembly fairly high level actually compared to the
topic I am not trolling on (I am at the level of building UTM's from
gates)
Post by Alan Somers
So I think you must be
exaggerating, and you really mean "Rust looks no more or less readable
than C". For a good example of why Rust (and other modern languages)
can be more readable than C, compare these examples, which sort an
in C
====
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
I completely agree pointers are evil and that's why I (like Rust it
appears) *ONLY* allow arrays and array references not direct pointers
into physical address space. This way we still have the advantage of
being able to use base+offset addressing modes instead of having the
language processor/executor compute absolute addresses at run time.
Post by Alan Somers
int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
qsort(arr, n, sizeof(int), compare);
So C is not OO (what a surprise ;-)) but it does do one thing right is
it separates out the concerns of storage from processing at the lowest
levels (hard to get above that level and that is why I use Java for my
freelancing work). Which when working in any language is a good idea
but since C is not OO we are stuck with naked function calls (no harm
in that)
Post by Alan Somers
in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();
The fact the data structure even worries about behaviour instead of
being passable to objects is asking for it (this is from my software
engineering hat). Also the fact there is no explicit size of the
array defined since if it is static a Turing complete process can be
implemented on it but if it is dynamic how do you keep from
overflowing the storage allocated to it (aka buffer overflow).
Post by Alan Somers
* The size of the array
Very good idea from the resource management POV
Post by Alan Somers
* The size of each element
Again correct call for an OS level language.
Post by Alan Somers
* The name of the comparison function
Separation of concerns *STANDARD* software engineering.
Post by Alan Somers
Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
At the cost of coupling stuff far too tightly it appears.
B. E.
2024-09-12 00:36:06 UTC
Permalink
It doesn't matter the technicalities, Rust enthusiasts are looking for
relevancy in a post-language wars world; and they think falsely that their
only recourse is to invade established camps.

I feel sorry for them in a lot of ways, but this is the time for them to be
discovering problem domains or creating solutions that Rust is uniquely
good for; and not copying or corrupting established technical communites.
Augmenting FreeBSD *somehow* is not a legitimate problmem domain nor is it
something uniquely solved by Rust. Don't be a solution in search of a
problem is my best advice to the Rust community - unfortunately much of the
low hanging problems have been picked; but there are plenty of slightly
less easy problems to solve.

So, this is ideologically and existentially driven, and rational arguments
are not enough (FreeBSD is not experiencing this alone). Setting extremely
hard boundaries, in charity, is the only answer. I am a mere casual but
consistent user of FreeBSD from a long time ago, and I very strongly
support all firm (but charitable) opposition to Rust being required to run
FreeBSD.

Cheers,
Brett
Post by Aryeh Friedman
Post by Alan Somers
Post by Aryeh Friedman
2. The code looks no better than portable assembly and if that is the
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?
I don't know if you're being serious or trolling. I ought to assume
the former, but if you genuinely can't tell the difference between
Rust and assembly source code then you obviously haven't looked at one
or the other for more than a few seconds.
If I had wanted to troll instead of genuinely out of pure curosity I
could of compared all three languages to a language I am currently
writting to use in a forth come PhD thesis that is purefly function,
gate level (with abstractions allowed), has no explicit flow control
except for calling functions and few other really oddball things.
But I am not going to say anything more about that and instead focus
1. C when super optimized has about a 2 to 1 ratio between expressions
and emitted machine instructions but it self is semantically much
easier to deal with then assembly and the fact it is a high level
language means it in theory portable to any machine a compiler is
implemented on.
2. I consider assembly fairly high level actually compared to the
topic I am not trolling on (I am at the level of building UTM's from
gates)
Post by Alan Somers
So I think you must be
exaggerating, and you really mean "Rust looks no more or less readable
than C". For a good example of why Rust (and other modern languages)
can be more readable than C, compare these examples, which sort an
in C
====
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
I completely agree pointers are evil and that's why I (like Rust it
appears) *ONLY* allow arrays and array references not direct pointers
into physical address space. This way we still have the advantage of
being able to use base+offset addressing modes instead of having the
language processor/executor compute absolute addresses at run time.
Post by Alan Somers
int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
qsort(arr, n, sizeof(int), compare);
So C is not OO (what a surprise ;-)) but it does do one thing right is
it separates out the concerns of storage from processing at the lowest
levels (hard to get above that level and that is why I use Java for my
freelancing work). Which when working in any language is a good idea
but since C is not OO we are stuck with naked function calls (no harm
in that)
Post by Alan Somers
in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();
The fact the data structure even worries about behaviour instead of
being passable to objects is asking for it (this is from my software
engineering hat). Also the fact there is no explicit size of the
array defined since if it is static a Turing complete process can be
implemented on it but if it is dynamic how do you keep from
overflowing the storage allocated to it (aka buffer overflow).
Post by Alan Somers
* The size of the array
Very good idea from the resource management POV
Post by Alan Somers
* The size of each element
Again correct call for an OS level language.
Post by Alan Somers
* The name of the comparison function
Separation of concerns *STANDARD* software engineering.
Post by Alan Somers
Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
At the cost of coupling stuff far too tightly it appears.
Steffen Nurpmeso
2024-09-12 19:48:59 UTC
Permalink
Alan Somers wrote in
<CAOtMX2iMhHyr_-***@mail.gmail.com>:
...
|Systems programming IS the problem domain that Rust is uniquely good
|for. Nor do we have a solution in search of a problem. As I've
|explained elsewhere on this list (but you can 100% be forgiven for
|overlooking; there've been a lot of posts), I've already encountered
|many problems within FreeBSD that could've easily been solved by Rust.

Let me be the one who doubts this, please.

|Being experienced with both C and Rust, but being forced to use the
|former, feels like a real handicap. To recap:
|
|* I considered writing the fusefs test suite in Rust. It would've
|been well-suited. But I was forced to do it in C++ instead.
|* I tried to write a prometheus exporter for CTL in Rust. But when I
|realized that the API is unstable, I had to abandon using ports, which
|meant that I had to abandon using Rust, and use C instead.
|* I had to fix several file-parsing and memory-handling bugs in ctld.
|Just to help myself understand the code, I rewrote part of it in Rust.
|The portion that I rewrote took about 5.5x less code and was free of
|memory-handling bugs. But I can't finish it, because the src tree
|currently only allows C and C++.

This sounds to me as if you have a natural relationship with some
programming language. Congratulations, this makes the most fun.

|* ALL of the recent security advisories involved memory handling bugs.
|We obviously can't rewrite all of the affected components overnight,
|but those SAs should serve as a wake-up call that C is insufficient
|for developing reliable and secure software. Any components that we
|can rewrite will improve the quality of our project.

Here you seem to pamper over to what seems to me realities after
looking in more detail to the list of problems you mentioned.

...
|I've noticed that the most vociferous opposition to using Rust in
|FreeBSD comes from users like yourself: casual users who do little to
|no development of FreeBSD. If you aren't a developer, then what are

This is why i will not post no more, and i already said so, that
i have no voice that is (and this is understandable and even,
well, good), but your above claims seem to contradict reality even.

--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Steffen Nurpmeso
2024-09-12 19:58:28 UTC
Permalink
Steffen Nurpmeso wrote in
<***@steffen%sdaoden.eu>:
...
||* I considered writing the fusefs test suite in Rust. It would've
||been well-suited. But I was forced to do it in C++ instead.

Btw i have forgotten to give you sympathy for this.

But i am wondering in general, the OpenBSD guys (no girls at all
i think, except a plus HTML generator that is now also gone
i think) seem to allow "external" toolchains for at least tests.
I am pretty confident i have often seen a network stack guy
(German i think) to use Python for network tests.
Wouldn't this be an option for FreeBSD, to allow at least certain
parts of the unit tests to be written in freely chosen languages?

--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Alan Somers
2024-09-12 20:32:24 UTC
Permalink
Post by Steffen Nurpmeso
Steffen Nurpmeso wrote in
...
||* I considered writing the fusefs test suite in Rust. It would've
||been well-suited. But I was forced to do it in C++ instead.
Btw i have forgotten to give you sympathy for this.
But i am wondering in general, the OpenBSD guys (no girls at all
i think, except a plus HTML generator that is now also gone
i think) seem to allow "external" toolchains for at least tests.
I am pretty confident i have often seen a network stack guy
(German i think) to use Python for network tests.
Wouldn't this be an option for FreeBSD, to allow at least certain
parts of the unit tests to be written in freely chosen languages?
Actually, that's already the case. FreeBSD already has quite a few
test programs written in Python. That's not a problem, because Python
is an interpreted language. We install the .py files directly to
/usr/tests. A Python interpreter is required to execute the tests,
but not to build them. That's not true of a compiled language like
Rust.

-Alan


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Charlie Li
2024-09-12 01:33:39 UTC
Permalink
Post by Alan Somers
Post by Aryeh Friedman
1. It takes FOREVER to compile
I assume you mean lang/rust. It does take FOREVER to compile, because
it builds its own version of LLVM. That's why I suggest adding it to
ALLOW_MAKE_JOBS_PACKAGES , if you're using Poudriere. Ordinary Rust
programs generally compile at a similar speed as C programs. Slower
than Go, but faster than C++.
rustc (lang/rust) supports using an existing LLVM toolchain
(devel/llvm*). Since LLVM 8.0, the Rust Project maintain their copy of
LLVM nearly the same way we do in base, and as such track the latest two
release branches. Using the PORT_LLVM option in the port reduces the
build time significantly (from not building LLVM) with no change in
runtime behaviour.

--
Charlie Li
...nope, still don't have an exit line.
Alan Somers
2024-09-12 01:38:18 UTC
Permalink
Post by Charlie Li
Post by Alan Somers
Post by Aryeh Friedman
1. It takes FOREVER to compile
I assume you mean lang/rust. It does take FOREVER to compile, because
it builds its own version of LLVM. That's why I suggest adding it to
ALLOW_MAKE_JOBS_PACKAGES , if you're using Poudriere. Ordinary Rust
programs generally compile at a similar speed as C programs. Slower
than Go, but faster than C++.
rustc (lang/rust) supports using an existing LLVM toolchain
(devel/llvm*). Since LLVM 8.0, the Rust Project maintain their copy of
LLVM nearly the same way we do in base, and as such track the latest two
release branches. Using the PORT_LLVM option in the port reduces the
build time significantly (from not building LLVM) with no change in
runtime behaviour.
Oh, sweet. I need to try that out. What's the downside? Do you know why it
isn't the default?
Charlie Li
2024-09-12 04:51:35 UTC
Permalink
Post by Charlie Li
rustc (lang/rust) supports using an existing LLVM toolchain
(devel/llvm*). Since LLVM 8.0, the Rust Project maintain their copy of
LLVM nearly the same way we do in base, and as such track the latest two
release branches. Using the PORT_LLVM option in the port reduces the
build time significantly (from not building LLVM) with no change in
runtime behaviour.
Oh, sweet.  I need to try that out. What's the downside? Do you know why
it isn't the default?
Well, it's not the default upstream :-P The port option was resurrected
after a long while and is maintained by yours truly.

Some history: The rustc config.toml has always had the ability to
(optionally) specify a path to llvm-config. The port option was
originally removed during 1.22.1, at which Rust upstream tracked their
*fork* of LLVM trunk, at the time the development for 7.0 (6.0 was the
latest release). Rust added an API into their LLVM fork that gecko@
software started to use, so building gecko@ software using an external
LLVM-pilled rustc would fail. Once Rust started tracking LLVM 8.0
release branch, this problem went away and their current maintenance
practice similar to us in base [0] started.

Someone started to resurrect the PORT_LLVM option in the port as a phab
review during the intervening period but didn't go anywhere quick
because ENOTENOUGHEYEBALLS. It took until me waking up from a fever
dream on this subject (and of course wanting to reduce port build time)
to give it the additional work and testing needed to receive blessing
for this option to return.

The only downside is a minor nit over the WASM target bundling LLD that
upstream probably didn't catch but we have mitigated it in the port. And
again, the aforementioned build failures on gecko@ software have long
been resolved with the changed LLVM tracking practice.

[0] https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html

--
Charlie Li
...nope, still don't have an exit line.
DaLynX
2024-09-12 01:51:28 UTC
Permalink
Post by Aryeh Friedman
Post by Alan Somers
in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();
The fact the data structure even worries about behaviour instead of
being passable to objects is asking for it (this is from my software
engineering hat). Also the fact there is no explicit size of the
array defined since if it is static a Turing complete process can be
implemented on it but if it is dynamic how do you keep from
overflowing the storage allocated to it (aka buffer overflow).
Post by Alan Somers
* The size of the array
Very good idea from the resource management POV
Post by Alan Somers
* The size of each element
Again correct call for an OS level language.
Post by Alan Somers
* The name of the comparison function
Separation of concerns *STANDARD* software engineering.
Post by Alan Somers
Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
At the cost of coupling stuff far too tightly it appears.
Hi,

I am more of an IT security guy by trade and just do programming for fun but I have played with Rust. I think your worries are very legitimate but come from a lack of knowledge or understanding of the language.

- Size questions are not absent from the language. They are explicit. Even more than in C (I do not need to know the arch to know that an u32 is 32 bit and a u64 is 64.). They do not appear at the sort function level because it is automatically taken into account by the compiler through typing.

- The vector we are looking at here (which technically is automatically typed as a Vector<u32>, I believe) is a container class, pretty much like the STL's vector<T> in C++. It keeps track of its length (and capacity, which you can also work with if you need to be precise about that).

- You seem to worry that the sort function is implemented at the data structure level, like you would do by putting a method in a class, coupling too tightly to your taste behaviour with structure. This is not really the case. Rust works with traits: there is an Ord trait, for which you provide an implementation for the types you want to work with, then the sort function automatically applies to any type implementing that trait.

You seem to think the sort function is defined in the vector's class because you look at the "." like it accessed the member of a C struct. It is not. That's just syntaxic sugar. The sort function is implemented separately, agnostically, taking anything that implements the Ord trait as arguments. So that behaviour is totally separate from the data structure, and applies to a Vector of anything that implements an Ord trait (a comparison function).

(Actually you can work with a PartialOrd too if you don't have a total order, with some extra precautions.)

And of course you can just use vec.sort_by(f) if you want to provide a specific comparison function that is different from the one in the Ord trait for your data type. So if you prefer to keep the separation explicit that way, you can. It's just coding guidelines.

As I said, I think the points you raise are most pertinent and legitimate. But making your opinion of another language just based on brief examples sent to you by email will never be enough to let you construct a complete, accurate and thus fair opinion of it.

So to anyone who doesn't know rust I advise to take some time to look at it and play with it. That's how we all learn.

I hope that's constructive.

Kind regards,
DaLynX
Alan Somers
2024-09-12 02:00:42 UTC
Permalink
It doesn't matter the technicalities, Rust enthusiasts are looking for relevancy in a post-language wars world; and they think falsely that their only recourse is to invade established camps.
Nobody is invading anything. Myself and the other Rust boosters have
been involved with FreeBSD for longer than Rust has existed.
I feel sorry for them in a lot of ways, but this is the time for them to be discovering problem domains or creating solutions that Rust is uniquely good for; and not copying or corrupting established technical communites. Augmenting FreeBSD somehow is not a legitimate problmem domain nor is it something uniquely solved by Rust. Don't be a solution in search of a problem is my best advice to the Rust community - unfortunately much of the low hanging problems have been picked; but there are plenty of slightly less easy problems to solve.
Systems programming IS the problem domain that Rust is uniquely good
for. Nor do we have a solution in search of a problem. As I've
explained elsewhere on this list (but you can 100% be forgiven for
overlooking; there've been a lot of posts), I've already encountered
many problems within FreeBSD that could've easily been solved by Rust.
Being experienced with both C and Rust, but being forced to use the
former, feels like a real handicap. To recap:

* I considered writing the fusefs test suite in Rust. It would've
been well-suited. But I was forced to do it in C++ instead.
* I tried to write a prometheus exporter for CTL in Rust. But when I
realized that the API is unstable, I had to abandon using ports, which
meant that I had to abandon using Rust, and use C instead.
* I had to fix several file-parsing and memory-handling bugs in ctld.
Just to help myself understand the code, I rewrote part of it in Rust.
The portion that I rewrote took about 5.5x less code and was free of
memory-handling bugs. But I can't finish it, because the src tree
currently only allows C and C++.
* ALL of the recent security advisories involved memory handling bugs.
We obviously can't rewrite all of the affected components overnight,
but those SAs should serve as a wake-up call that C is insufficient
for developing reliable and secure software. Any components that we
can rewrite will improve the quality of our project.
So, this is ideologically and existentially driven, and rational arguments are not enough (FreeBSD is not experiencing this alone). Setting extremely hard boundaries, in charity, is the only answer. I am a mere casual but consistent user of FreeBSD from a long time ago, and I very strongly support all firm (but charitable) opposition to Rust being required to run FreeBSD.
I've noticed that the most vociferous opposition to using Rust in
FreeBSD comes from users like yourself: casual users who do little to
no development of FreeBSD. If you aren't a developer, then what are
you afraid of? Longer compile times when updating your desktop from
src? If Shawn Webb's project works out, then you won't have to worry
about that. A larger .iso for installation? Even the smallest thumb
drives are now larger than our dvd image. Please explain to me: what
negative impact do you foresee for yourself?

-Alan
Cheers,
Brett
Post by Aryeh Friedman
Post by Alan Somers
Post by Aryeh Friedman
2. The code looks no better than portable assembly and if that is the
case why does it need to be in the kernel when there is already a
perfectly good portable assembly already there known as C?
I don't know if you're being serious or trolling. I ought to assume
the former, but if you genuinely can't tell the difference between
Rust and assembly source code then you obviously haven't looked at one
or the other for more than a few seconds.
If I had wanted to troll instead of genuinely out of pure curosity I
could of compared all three languages to a language I am currently
writting to use in a forth come PhD thesis that is purefly function,
gate level (with abstractions allowed), has no explicit flow control
except for calling functions and few other really oddball things.
But I am not going to say anything more about that and instead focus
1. C when super optimized has about a 2 to 1 ratio between expressions
and emitted machine instructions but it self is semantically much
easier to deal with then assembly and the fact it is a high level
language means it in theory portable to any machine a compiler is
implemented on.
2. I consider assembly fairly high level actually compared to the
topic I am not trolling on (I am at the level of building UTM's from
gates)
Post by Alan Somers
So I think you must be
exaggerating, and you really mean "Rust looks no more or less readable
than C". For a good example of why Rust (and other modern languages)
can be more readable than C, compare these examples, which sort an
in C
====
int compare(const void* a, const void* b) {
return (*(int*)a - *(int*)b);
}
I completely agree pointers are evil and that's why I (like Rust it
appears) *ONLY* allow arrays and array references not direct pointers
into physical address space. This way we still have the advantage of
being able to use base+offset addressing modes instead of having the
language processor/executor compute absolute addresses at run time.
Post by Alan Somers
int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
qsort(arr, n, sizeof(int), compare);
So C is not OO (what a surprise ;-)) but it does do one thing right is
it separates out the concerns of storage from processing at the lowest
levels (hard to get above that level and that is why I use Java for my
freelancing work). Which when working in any language is a good idea
but since C is not OO we are stuck with naked function calls (no harm
in that)
Post by Alan Somers
in Rust
=======
let mut arr = vec![170, 45, 75, 90, 802, 24, 2, 66];
arr.sort();
The fact the data structure even worries about behaviour instead of
being passable to objects is asking for it (this is from my software
engineering hat). Also the fact there is no explicit size of the
array defined since if it is static a Turing complete process can be
implemented on it but if it is dynamic how do you keep from
overflowing the storage allocated to it (aka buffer overflow).
Post by Alan Somers
* The size of the array
Very good idea from the resource management POV
Post by Alan Somers
* The size of each element
Again correct call for an OS level language.
Post by Alan Somers
* The name of the comparison function
Separation of concerns *STANDARD* software engineering.
Post by Alan Somers
Each of those is error-prone. Stuff like that is a common source of
bugs in C code. But Rust tracks it automatically.
At the cost of coupling stuff far too tightly it appears.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Aryeh Friedman
2024-09-12 03:31:40 UTC
Permalink
Post by B. E.
Post by Alan Somers
I've noticed that the most vociferous opposition to using Rust in
FreeBSD comes from users like yourself: casual users who do little to
no development of FreeBSD. If you aren't a developer, then what are
you afraid of? Longer compile times when updating your desktop from
src? If Shawn Webb's project works out, then you won't have to worry
about that. A larger .iso for installation? Even the smallest thumb
drives are now larger than our dvd image. Please explain to me: what
negative impact do you foresee for yourself?
This ^
I am starting to be sorry I ever decided to ask such "stupid
questions". But to dismiss any and all critics as not being
developers and thus don't count, to be incredibly arrogant (something
I would have done a few decades ago). It is often best to assume
absolutely nothing about the person's skills until proven otherwise.
I get the feeling I didn't get a similar answer is I showed beyond all
doubt your claims about my background were unfounded.

--
Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Charlie Li
2024-09-12 04:57:46 UTC
Permalink
Post by Charlie Li
Post by Charlie Li
Oh, sweet.  I need to try that out. What's the downside? Do you know
why it isn't the default?
The only downside is a minor nit over the WASM target bundling LLD that
upstream probably didn't catch but we have mitigated it in the port. And
been resolved with the changed LLVM tracking practice.
I forgor to mention, the chosen devel/llvm* needs at least CLANG,
COMPILER_RT, LIT and LLD options enabled. Need to double check which
exact options but I got bit when I didn't have LIT enabled.

--
Charlie Li
...nope, still don't have an exit line.
Loading...