Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Sep 2024 15:11:51 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Stefan Esser <se@freebsd.org>
Cc:        Bob Bishop <rb@gid.co.uk>, FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Rust: kernel vs user-space
Message-ID:  <CANCZdfq-as=YyY6fLpr=9WsoUbqThm51FxMbOEh6kvVegxTeiQ@mail.gmail.com>
In-Reply-To: <40836902-cb68-45e0-b4ec-623c21aa47ba@FreeBSD.org>
References:  <202409031532.483FW0If007252@critter.freebsd.dk> <7533543.20240904114624@yahoo.com> <0.2.0-final-1725440949.866-0xb4bb20@qmda.emu.st> <65ED39B7-099F-43FD-9F53-68286125A65E@FreeBSD.org> <0.2.0-final-1725443552.800-0x2fa4dc@qmda.emu.st> <bd1419b2-5705-4ea6-8238-d98eb072cda0@FreeBSD.org> <FAB9B773-A51A-4208-A2C9-0CE0604A5235@gid.co.uk> <40836902-cb68-45e0-b4ec-623c21aa47ba@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000001cc4ae062151a08f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Sep 4, 2024, 10:42=E2=80=AFAM Stefan Esser <se@freebsd.org> wrote:

> Am 04.09.24 um 17:21 schrieb Bob Bishop:
> > Hi,
> >
> >> On 4 Sep 2024, at 15:37, Stefan Esser <se@FreeBSD.org> wrote:
> >>
> >> Am 04.09.24 um 11:52 schrieb Mark Delany:
> >>> On 04Sep24, David Chisnall apparently wrote:
> >>>> There are lots of control-plane things that I'd love to see
> >>>> written mostly in Lua,
> >>> It was remiss of me to not mention Lua given that it's already in the
> project.
> >>> Yet another language which could make life easier, more productive an=
d
> more accessible in
> >>> user-land.
> >>> I'm not suggesting for an instant that any of these programs need
> rewriting, but one could
> >>> imagine that if commands like ifconfig, route, arp, ndp, ipfw (that
> is, programs which
> >>> take a lot of user input and do a lot of data manipulation but aren't
> super-critical on
> >>> the performance front) were written in a more accessible language,
> then it might attract
> >>> new developers without disenfranchising the core C developers.
> >>
> >> Here is ldconfig in LUA, written more than 2 years ago, for example:
> >>
> >> https://github.com/stesser/ldconfig/blob/main/ldconfig.lua
> >
> > And this is better than C because ...?
> >
> > (Asking for a friend :-)
>
> There had been a request for an architecture independent implementation
> that works on all FreeBSD releases and architectures.
>
> The LUA run-time has been available in FreeBSD for a long time, and it
> is a stable platform suitable for the implementation of commands that
> operate on text and might take advantage of features like associative
> storage. It is a "safe" implementation since memory is automatically
> managed, which reduces the risk of memory management errors (but we
> have to trust the LUA interpreter to be free of such issues, instead).
>
> I have not made this version available for review (but instead updated
> the C version to work with hints files of either byte order). But this
> code is much simpler than the C version it replaces, and it could easily
> be extended to, e.g., prepare hints files in chroot environments or in
> images prepared for an architecture with a (possibly) different byte orde=
r.
>
> And it is not only independent of the byte order and portable over all
> architectures, but also independent of the FreeBSD version.
>
> The LUA version is much shorter and easier to understand (if you know
> LUA), but one reason not to propose it for inclusion in FreeBSD is that
> there are many more developers that know how to work on the C version
> than on the LUA version.
>
> David and Mark have mentioned LUA, and there is little LUA code in the
> base system, currently (mostly the loader). I'd like to see LUA being
> used for more functionality that is not time critical, and since the LUA
> language has been very stable over time (other than many other interprete=
d
> languages), it is unlikely that a LUA script will not work on a later
> FreeBSD release (it only depends on a working flua and possibly some
> LUA include files).
>

I do most of my string processing code in lua these days.

I think this reimplementaion makes sense: it helps in cross building.

I have a config successor doodled out in lua...

Warner

Anyway, this is off-topic for the discussion about rust, other than
> that LUA is a language that is not affected by many bugs that are
> typical for programs written in C.
>
> Best regards, STefan
>
>

--0000000000001cc4ae062151a08f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Wed, Sep 4, 2024, 10:42=E2=80=AFAM Stefan Esser &lt=
;<a href=3D"mailto:se@freebsd.org">se@freebsd.org</a>&gt; wrote:<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex">Am 04.09.24 um 17:21 schrieb Bob Bishop:<br>
&gt; Hi,<br>
&gt; <br>
&gt;&gt; On 4 Sep 2024, at 15:37, Stefan Esser &lt;se@FreeBSD.org&gt; wrote=
:<br>
&gt;&gt;<br>
&gt;&gt; Am 04.09.24 um 11:52 schrieb Mark Delany:<br>
&gt;&gt;&gt; On 04Sep24, David Chisnall apparently wrote:<br>
&gt;&gt;&gt;&gt; There are lots of control-plane things that I&#39;d love t=
o see<br>
&gt;&gt;&gt;&gt; written mostly in Lua,<br>
&gt;&gt;&gt; It was remiss of me to not mention Lua given that it&#39;s alr=
eady in the project.<br>
&gt;&gt;&gt; Yet another language which could make life easier, more produc=
tive and more accessible in<br>
&gt;&gt;&gt; user-land.<br>
&gt;&gt;&gt; I&#39;m not suggesting for an instant that any of these progra=
ms need rewriting, but one could<br>
&gt;&gt;&gt; imagine that if commands like ifconfig, route, arp, ndp, ipfw =
(that is, programs which<br>
&gt;&gt;&gt; take a lot of user input and do a lot of data manipulation but=
 aren&#39;t super-critical on<br>
&gt;&gt;&gt; the performance front) were written in a more accessible langu=
age, then it might attract<br>
&gt;&gt;&gt; new developers without disenfranchising the core C developers.=
<br>
&gt;&gt;<br>
&gt;&gt; Here is ldconfig in LUA, written more than 2 years ago, for exampl=
e:<br>
&gt;&gt;<br>
&gt;&gt; <a href=3D"https://github.com/stesser/ldconfig/blob/main/ldconfig.=
lua" rel=3D"noreferrer noreferrer" target=3D"_blank">https://github.com/ste=
sser/ldconfig/blob/main/ldconfig.lua</a><br>
&gt; <br>
&gt; And this is better than C because ...?<br>
&gt; <br>
&gt; (Asking for a friend :-)<br>
<br>
There had been a request for an architecture independent implementation<br>
that works on all FreeBSD releases and architectures.<br>
<br>
The LUA run-time has been available in FreeBSD for a long time, and it<br>
is a stable platform suitable for the implementation of commands that<br>
operate on text and might take advantage of features like associative<br>
storage. It is a &quot;safe&quot; implementation since memory is automatica=
lly<br>
managed, which reduces the risk of memory management errors (but we<br>
have to trust the LUA interpreter to be free of such issues, instead).<br>
<br>
I have not made this version available for review (but instead updated<br>
the C version to work with hints files of either byte order). But this<br>
code is much simpler than the C version it replaces, and it could easily<br=
>
be extended to, e.g., prepare hints files in chroot environments or in<br>
images prepared for an architecture with a (possibly) different byte order.=
<br>
<br>
And it is not only independent of the byte order and portable over all<br>
architectures, but also independent of the FreeBSD version.<br>
<br>
The LUA version is much shorter and easier to understand (if you know<br>
LUA), but one reason not to propose it for inclusion in FreeBSD is that<br>
there are many more developers that know how to work on the C version<br>
than on the LUA version.<br>
<br>
David and Mark have mentioned LUA, and there is little LUA code in the<br>
base system, currently (mostly the loader). I&#39;d like to see LUA being<b=
r>
used for more functionality that is not time critical, and since the LUA<br=
>
language has been very stable over time (other than many other interpreted<=
br>
languages), it is unlikely that a LUA script will not work on a later<br>
FreeBSD release (it only depends on a working flua and possibly some<br>
LUA include files).<br></blockquote></div></div><div dir=3D"auto"><br></div=
><div dir=3D"auto">I do most of my string processing code in lua these days=
.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I think this reimpleme=
ntaion makes sense: it helps in cross building.</div><div dir=3D"auto"><br>=
</div><div dir=3D"auto">I have a config successor doodled out in lua...</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">Warner</div><div dir=3D"aut=
o"><br></div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
Anyway, this is off-topic for the discussion about rust, other than<br>
that LUA is a language that is not affected by many bugs that are<br>
typical for programs written in C.<br>
<br>
Best regards, STefan<br>
<br>
</blockquote></div></div></div>

--0000000000001cc4ae062151a08f--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfq-as=YyY6fLpr=9WsoUbqThm51FxMbOEh6kvVegxTeiQ>