Re: My experiences with Rust

From: Sulev-Madis Silber <freebsd-hackers-freebsd-org952_at_ketas.si.pri.ee>
Date: Sat, 23 Aug 2025 11:51:44 UTC

On August 22, 2025 9:42:15 PM GMT+03:00, Vadim Goncharov <vadimnuclight@gmail.com> wrote:
>On Fri, 22 Aug 2025 19:10:15 +0300
>Konstantin Belousov <kostikbel@gmail.com> wrote:
>
>> For ktcplist, the more natural action would be to extend netstat(8)
>> then to write a new tool, but I cannot make myself to use libxo.  It
>> is less painful to write Rust then to try to use libxo, at least for
>> me.
>
>What's the problem with libxo?
>


the problem with libxo is that it makes this:


bin/df/df.c

                xo_emit("{T:/%-*s}", mwp->mntfrom, "Filesystem");
                if (Tflag)
                        xo_emit("  {T:/%-*s}", mwp->fstype, "Type");
                xo_emit(" {T:/%*s} {T:/%*s} {T:/%*s} {T:Capacity}",
                        mwp->total, header,
                        mwp->used, "Used", mwp->avail, "Avail");
                if (iflag) {
                        mwp->iused = imax(hflag ? 0 : mwp->iused,
                            (int)strlen("  iused"));
                        mwp->ifree = imax(hflag ? 0 : mwp->ifree,
                            (int)strlen("ifree"));
                        xo_emit(" {T:/%*s} {T:/%*s} {T:\%iused}",
                            mwp->iused - 2, "iused", mwp->ifree, "ifree");
                }
                xo_emit("  {T:Mounted on}\n");


if you have feeling that this is written by disgruntled employee or perhaps even satan himself to annoy others then you're right

it also makes all your utils need to have --libxo or similar option

it's easy to make mistakes with this crazy formatting. i recall spotting one and reporting

on good side it does indeed allow machine readable and other outputs. currently it was iirc still text/json/xml/html. all that hassle for little good

of course, what's alternative? write lib for that? maybe libsys?

this has been discussed within "Massive libxo-zation that breaks everything" (which i created because i was pissed about using utils converted to it) and possibly earlier or later too, god knows in which lists, irc channels, forums or what not

i think he meant that if he found xo bad