Threads for guiraldelli

    1. 3

      Of course grep is good for searching, but the real gain, to me, was learning sed.

      And I don’t mean the pun that grep is just a command of sed.

      But searches such as “find the first ocorrence of ‘foo’ after an ocorrence of ‘bar’” are so easily done in sed [1][2], but impossible with grep.

      [1]: Also possible in awk, but I prefer the syntax of sed for this type of searches.
      Besides, the memory footprint should be smaller as well.

      [2]: For the curious ones, it would be

      $ sed -ne '/\<foo\>/{: loop; n; /\<bar\>/{p; q;}; b loop;}'
      
      1. 4

        It’s even easier in Perl ;-P

        $ perl -ne '/\bfoo\b/ .. /\bbar\b/ && print && exit'

        1. 1

          Grep -E, if you have gnu grep rather than some toy version, allows you to use PCRE.

          1. 1

            I think you mean grep -P.

            1. 2

              I did. Thanks for the correction.

    2. 1

      It seems a 2023’s version of eXtreme Go Horse.

      It also seems that Brazilians have a thing for satire software methodologies. 😂

    3. 7

      I have a script that does something similar, but it is only UNIX-dependent, not editor-dependent.

      This is it:

      $ cat -vT fix_table.sh
      COLUMN_SEPARATOR='|'
      
      sed 's/'"$COLUMN_SEPARATOR"'/&^\/g' |
      column -t -s "$COLUMN_SEPARATOR" |
      sed 's/^\/'"$COLUMN_SEPARATOR"'/g' |
      sed 's/[ ]\{2\}'"$COLUMN_SEPARATOR"'/'"$COLUMN_SEPARATOR"'/g'
      

      Note that I change the file separator (shown as ^\ in the sed entries) to the $COLUMN_SEPARATOR, so it handle empty columns properly—as far as I remember.

      $ ascii FS
      ASCII 1/12 is decimal 028, hex 1c, octal 034, bits 00011100: called ^\, FS
      Official name: File Separator
      

      If you feel it is useful, feel free to copy and use it: treat it as “public domain”.

      EDIT 01: you will have to change the ^\ of the sed entries with the file separator.

      EDIT 02: No: I concatenate the file separator because column removes the | as column separator. So I mark the places the column separators are (supposed to be), then column makes all beautiful, except it removes the column separators, then I put then back.

    4. 5

      Please do not advise using macros for constants or functions.

      For constants,

      Unlike variables, you can use macros in contexts where you need a “constant expression,” like array lengths or switch statement cases.

      For these cases, please use enum.

      Having constants actually be “constant expressions” is very useful and hence they should usually be defined as macros.

      Please don’t. Your compiler is smarter than you and a simple static const is enough.

      For functions,

      The code is pasted right in the surrounding code, instead of compiling function call instructions. This can make code faster, as function calls have some overhead.

      No. The compiler is smarter than you.

      They can be type-generic. For example, x + y is valid syntax for any numeric type. If we made that a function, we’d have to declare them as arguments and choose their type, i.e. size and signedness, in advance, which would make it only usable in some contexts.

      Please define functions with specific types, and use _Generic to make a generic macro that uses actually defined functions.

      1. 4

        Lots of this advice has aged poorly, because it was passed down without context. Now people read it the way they read advice on Rust or Python, unaware of two major caveats that frequently degrade its quality:

        • That there isn’t a single authoritative implementation of (generally) reasonable quality that works across the architectures that the single authoritative upstream considers important and is able to support.
        • That part of C’s cancerous spread success laid in its ability to usefully leak quirks of the underlying hardware in a way that enabled you to (mostly) use it as a portable assembler for the boring parts and a non-portable assembler for the interesting parts.

        So lots of C optimization advice floating around the Internet, including e.g. the one that the author quotes about macros vs. inline functions and constants, is mostly about handholding ancient or (even contemporary, sadly) proprietary compilers.

        There’s surprisingly little C optimization advice that’s correct everywhere. Every generation discovers this. Lots of my “grasping C” process consisted of unlearning optimization advice (including “no, the compiler is smarter than you”) that I’d absorbed without realizing it was mostly specific to Watcom and x86, and Watcom was not a bad compiler.

        If anyone’s still learning C today, my advice would be to focus more on understanding common compiler idioms and platform-specific optimizations that compilers use (or not!) and less on “optimization tips”. After the initial adjusting period, reading assembly outputs is usually more productive than reading language tips.

        1. 3

          Well, if the programmer suggests using macros for optimization purposes, the answer is always “no, the compiler is smarter than you.” If the programmer suggests looking at assembly for optimization purposes, the answer is always “the compiler makes dumb decisions.”

      2. 1

        The advice around const is also misleading. You can cast from const T to T, but doing so must be explicit. Some standard library functions must do this (e.g. memchr). It’s also worth noting that, for pointer and array types, it doesn’t mean that the object is immutable, it just means that you promise not to mutate it through this pointer. In the presence of aliasing, the object may still be mutated between two reads through a const pointer.

      3. 1

        Please don’t. Your compiler is smarter than you and a simple static const is enough.

        Not here it isn’t:

        static const int foo = 4;
        // ...
        const uint *arr[foo]; // foo is not a constant
        

        That would work in C++, but not in C. Not in C99 at least.

        1. 2

          I think the way /u/jxy would write that is like this (“For these cases, please use enum.”):

          enum { foo = 4 };
          const int *arr[foo];
          

          https://godbolt.org/z/MT1Eobxfh

          1. 4

            The Apple system headers use this idiom a lot. I had never come across the idea of an unnamed enumeration in C until I read some of them, but they seem to be a good way of getting constants into headers. They also play a lot nicer with FFI tooling than using defines if they’re an expression. Consider the following two lines:

            #define BIT4 (1<<4)
            enum { Bit4 = 1<<4 };
            

            If your FFI uses libclang to parse the header then it can extract the value of Bit4 with a single call, independent of how complex the expression is, because clang can evaluate things that the C specification says are integer constant expressions and exposes this with the clang_getEnumConstantDeclValue function. In contrast, the first requires that you identify that this is a macro that doesn’t take any arguments, then parse it to determine that it doesn’t refer to any external variables, and then evaluate it. In this case, it’s quite simple, but consider if it’s some dependent value:

            #define BIT4 (1<<4)
            #define NEXT_BIT (1<<((sizeof(int)*CHAR_BIT) - __builtin_clz(BIT4)))
            enum
            {
                    Bit4 = 1<<4,
                    NextBit = (1<<((sizeof(int)*CHAR_BIT) - __builtin_clz(Bit4)))
            };
            

            The second one will be parsed by libclang and exposed in the AST. Indeed, if you compile this with -Xclang -ast-dump, then you will see that clang has evaluated the enum constants while creating the AST. This has one additional benefit: when I first wrote this, I missed some brackets and so got a warning from the enum version, whereas the warning would appear on each use with the macro version.

            Now consider trying to evaluate NEXT_BIT for FFI. It depends on the sizeof operator, fortunately on a type and not an expression, but it also depends on a compiler builtin and on two symbols CHAR_BIT and BIT4 that come from the other macros. These are also preprocessor macros and so you first need to evaluate them (fortunately, CHAR_BIT, at least, is a single integer). This introduces a lot of work into the FFI binding generator and a lot of things will correctly handle simple cases and then suddenly fail on more complex ones. The __builtin_clz case is particularly interesting because most will not handle it correctly, yet C code that uses it will compile correctly with clang or gcc.

      4. 1

        For constants,

        Unlike variables, you can use macros in contexts where you need a “constant expression,” like array lengths or switch statement cases.

        For these cases, please use enum.

        I read the same argument in Kernighan’s and Pike’ Practice of Programming, and I get the elegance of it, besides what @david_chisnall already told us.

        But besides it being a C construct, not a pre-processor one, and making it show in the results of ctags(1) (the latter being already an advantage, in my perspective), what is the real technical explanation for this advice? Is it solely these two, or does it improve optimisation passes?

        1. 2

          It’s mostly the same to any C compiler, except that the compiler should error if you define an enum twice, but would only warn if you define a macro twice. For programmers, it saves you from people laughing at your SIX*NINE.

    5. 1

      To be fair, only the grep(1) equivalent is implemented by now.

      Still, I find it promising.

      And there is another project, which implements a sed(1)-like equivalent.

    6. 4

      Just some thoughts on the why, from someone having used FreeBSD quite a bit in the past (but not really so much anymore currently).

      I’d argue that FreeBSD used to be a better desktop system than it currently is because of the initial setup. Once set up FreeBSD can still be very good, because of its extremely active porters community, that pretty much makes every other OS look like a joke on this front. Up to date, stable, quality packages are something nobody talks about when it comes to FreeBSD, but in my experience its by far their greatest for day to day usage on both server and desktop. The nginx package and its options alone leave every Linux distribution far behind.

      In my experience people tend to recommend FreeBSD on the desktop essentially for the proprietary NVIDIA graphics cards drivers. And while for some that might be a requirement, if you are not even using their graphics cards that won’t matter anyways.

      That leaves the incredible amount of ready to install software as the remaining factor. And again, this might not be what you care about, because all you do is use your browser, and an editor anyways, with all the games you like being supported anyways.

      But beyond that I agree with others. You might be better off with a different OS/BSD. Even though I enjoy it not having some quirks Linux does. Like sound coming out the wrong device based on whether it was attached at boot and some other little things that tend to bug me. But you get that with other BSDs as well.

      I think the majority of people using FreeBSD on the desktop on a regular basis either have an ancient installation or a set of scripts/commands to execute, be that one of the guides or something personal. So they are used to it. And there’s just so many great guides to get you started.

      The reason might be that most FreeBSD users don’t use it on the desktop as their daily driver. From my interactions the people that do pretty much only work on ports. People that run FreeBSD on servers on the other hand tend to have some kind of setup scripts, images, etc. made already or see set ups as a one time thing not to care about. Just copy over configs and you are fine. On top of that there’s quite a few tools to define a custom installation for you you, also for desktops. For example some people install FreeBSD and then run pkg install -y desktop-installer && desktop-installer.

      All of that might make better defaults a rather low priority for a large portion of contributors.

      At least that’s my rationale. It would explain why FreeBSD has both criticisms like in the article and criticism overall when it comes to defaults. At the same time it manages to explain why OpenBSD (as well as DragonFly and maybe NetBSD) seem to do a much better job there, despite FreeBSD probably being the best funded - by companies that anyways have their custom versions of FreeBSD or just incorporate tools. Netflix, Apple, Sony, Juniper, NetApp, Trivago, etc. don’t really care about how FreeBSD behaves out of the box despite heavily relying on it.

      I see similar problems in other open source projects, usually ones that are more “beginners only” or “customers only”, where the developers don’t really dog food their products. But with FreeBSD it’s very extreme, because a lot of potential contributors, and even user don’t follow what one might consider the standard way.

      As for packages pulling in a lot of dependencies it’s a similar topic. FreeBSD has ports, which are highly configurable, but there’s also packages. So what a typical port would do is add options and set a lot of them to “enabled by default”. Sometimes like in the nginx example mentioned above there’s even multiple ports that are identical, with different default options, so different packages are being built.

      This is yet another case, of how people use FreeBSD. If you have a serious setup you’ll likely run poudriere and have a couple of config options. On a server that might be build everything with Postgres 14 support, on a desktop that might be build everything with GTK or QT support and for example “Use sndio instead of PulseAudio”. Where Debian and its descendants package everything into dozens of packages FreeBSD makes everything an option.

      And then there’s another cultural thing regarding “scaring away people”. Evangelism never has been a huge topic for FreeBSD. Quite the opposite, for a while people and companies were secretive about FreeBSD usage, as it was seen a competitive advantage. Of course for actual products you’d have to tuck on the license, for services not too much. And which macOS user here thinks about how every time they run grep it’s FreeBSD’s grep, every time they run docker a bhyve instance is started, etc.

      1. 1

        OK, this is quite interesting.

        A few things as general context:

        I often get asked on the Reg why I don’t look more at server distros, or enterprise stuff. There are multiple reasons:

        • partly due to the very considerable difficulty in talking to PRs and marketing folks about this;
        • because I don’t have a testing lab available to me;
        • it’s a long time since I’ve been a sysadmin;
        • benchmarks and pricing comparisons are really irrelevant here, because those aren’t the bases on which such decisions are made;
        • TBH a lot of this would make very dull reading. When it comes down to it, any server Linux can do anything that any other can. There’s no useful way to grade by features; it’s FOSS, any of them has all the features.

        Anyway, in summary, I don’t care about server stuff. It’s not very interesting to me, I lack the resources or time or specialist knowledge to evaluate it.

        But desktops I can test. Here, there are real differences, and in places, big ones. Some distros are just startlingly bad at some everyday things, and, occasionally, others startlingly good.

        I don’t see many reviews of xBSD so I thought I’d do some. I am a competent xNix user with about 35Y of experience. I have experience of about half a dozen different xNixes, counting Linux as 1.

        Saying that…

        I’d argue that FreeBSD used to be a better desktop system than it currently is

        Well, that is startling. What changed?

        Up to date, stable, quality packages are something nobody talks about when it comes to FreeBSD, but […] its by far their greatest for day to day usage on […] desktop.

        That is hard to assess. Frankly, I find the repos for mainstream distros like Ubuntu and openSUSE to be superb, and almost anything that is mainstream and FOSS is just there and just works.

        These days, if it’s not there or it’s not FOSS, Snap or Flatpak probably make it very fast and easy.

        Not on FreeBSD.

        Last night, I discovered that I did not have nano or pico or joe or anything but rancid old Vi in FBSD13.1. I detest Vi. My preferred console editor, Tilde, isn’t in the repos.

        So, there’s a fail straight out of the gate.

        The nginx package and its options alone leave every Linux distribution far behind.

        I know nothing of that. It’s server stuff; see above.

        In my experience people tend to recommend FreeBSD on the desktop essentially for the proprietary NVIDIA graphics cards drivers.

        Odd. Very easy on Ubuntu; fairly easy on openSUSE Leap. Can be a pain on Fedora. Is a pain on Debian etc.

        Not sure why anyone would look to an xBSD for this, but please do enlighten me.

        BTW, I strongly suggest you read my Register reviews on FreeBSD, NetBSD and OpenBSD to get a handle on where I’m coming from, because already, I think your view is wildly different to mine.

        To me, your sentence I quote is equivalent to “people favour Morgan hand-built automobiles because they have wheels!” Well of course they have wheels. All cars have wheels. So what?

        You might be better off with a different OS/BSD.

        Um. I am guessing you are not aware, but I am the FOSS and Linux reporter for the Register. I’ve been using Linux for over 25 years now and have been writing about it professionally since the 1990s. I helped build the first customised cover-mounted Linux distro on a UK computer magazine, and wrote the accompanying 2-month multipage feature on it, about 25Y ago.

        Before that, I mainly worked with SCO Xenix and SCO UNIX, but also AIX and Solaris a little.

        Even though I enjoy it not having some quirks Linux does.

        I always hear that from BSD enthusiasts. I have never understood it.

        For me, all the BSDs are about 100x quirkier and weirder than even the most way-out Linux.

        And there’s just so many great guides to get you started.

        Google never found that one, but it directly reinforces my point about how all the guides you’ll find are weird, quirkly, and will refer to a version several years old and you have no way to tell what works any more.

        For example some people install FreeBSD and then run pkg install -y desktop-installer && desktop-installer.

        Then why the bloody blue blazes doesn’t the installation program even MENTION that?! How the hell am I supposed to know? My advanced psychic powers?

        I see similar problems in other open source projects, usually ones that are more “beginners only” or “customers only”, where the developers don’t really dog food their products.

        Strongly agreed.

        But with FreeBSD it’s very extreme, because a lot of potential contributors, and even user don’t follow what one might consider the standard way.

        That would indeed explain a lot.

        As for packages pulling in a lot of dependencies it’s a similar topic.

        I really don’t think it is. Installing a PDF viewer and it trying to install an entire desktop environment is not OK. That is a broken package IMHO.

        Where Debian and its descendants package everything into dozens of packages FreeBSD makes everything an option.

        This is directly falsified by the comment above, which you acknowledged.

        Evangelism never has been a huge topic for FreeBSD.

        Very true. I don’t think its community realises that right now it faces a make-or-break opportunity, though. Linux is going very mainstream now, to an extent that 99% of Linux users and vendors are totally oblivious to.

        Chromebooks outsold Macs.

        Chromebooks are standalone end-user Linux desktops and laptops. And while the pandemic gave them a huge boost because hundreds of millions of people suddenly needed cheap computers for working and studying at home, and that probably won’t happen again, nonetheless, something ITRO a quarter of a billion people now use Linux as their desktop OS.

        That kind of Linux is influencing desktop Linux.

        We are getting immutable-root, containerised Linuxes with apps delivered in bloated portable packages, run in sandboxes, that the user can’t change or alter in any material way. Old UI conventions are being ripped away, and a lot of users are very unhappy.

        This time, since about 2019-2020, is the single biggest chance for FreeBSD that it’s ever had or ever will have. To scoop up those disaffected Linux users who hate systemd and snap and flatpak and all that.

        But FreeBSD is, metaphorically, standing there oblivious, chewing the cud and gazing into space.

        PC-BSD became TrueOS then got cancelled.

        TrueNAS is oblivious to the fact that it alienated all the FreeNAS users because it doesn’t like to run from a USB key any more. Their sights are set on enterprise sales and they haven’t noticed that they have annoyed and alienated and driven away 100% of their desktop users AND their home-office free users.

        FuryBSD was a good try. It’s dead.

        I am not impressed at all by either GhostBSD or MidnightBSD. They will alienate more people than they attract, I think.

        FreeBSD has another year or 2 to try to win over Linux users alienated by all the weirdness encroaching on Linux now. If it doesn’t, it will never escape its tiny niche.

        I don’t think it ever will. It doesn’t care. It is what it is and you either meet in where it lives, or you can just go do something else.

        The Hello System has a chance, a very small one. I really hope it succeeds.

        I bet most FreeBSD users haven’t even noticed it, and can’t see any importance to it.

        And which macOS user here thinks about how every time they run grep it’s FreeBSD’s grep, every time they run docker a bhyve instance is started, etc.

        I am typing on a Mac. I am aware.

        OTOH, most Mac users don’t use the CLI much. That’s a good thing. They shouldn’t have to. The original Mac didn’t even have one.

        Most CLI type Mac users use Homebrew or similar extensively, meaning they replace the weird half-crippled Apple tools with Linux ones using a Linux package manager.

        Also, macOS has its own unnamed hypervisor, which AFAIK is unrelated to bHyve.

        https://developer.apple.com/documentation/hypervisor

        I do not use Docker – again, server stuff, don’t care – but I wouldn’t be surprised if it used the “official” tool. I don’t know, though.

        1. 3

          Last night, I discovered that I did not have nano or pico or joe or anything but rancid old Vi in FBSD13.1. I detest Vi. My preferred console editor, Tilde, isn’t in the repos.

          If you don’t like vi(1), FreeBSD also ships another editor in base that is very similar to GNU nano. See edit(1). I have to agree though that it is not easy to discover that it exists.

          1. 1

            But man -k editor (or apropos editor) would have revealed it.

            And I never used FreeBSD (but use OpenBSD and NetBSD), but I knew there would be a port for nano: it literally took me 10 seconds to get to it.

            EDIT: after giving it a few minutes, I decided to remove my unnecessary rant, which adds nothing to the discussion.

            1. 1

              it’s very easy to find things if you know what they’re called and where to look

              Both man -k and apropos are meant to search for commands that you are not aware of the name, but have a fairly idea of the keywords that would refer to them—in your case, editor.

              You would have been capable to discover ee(1) using the editor keyword because you wrote (bold is mine):

              [m]y preferred console editor, Tilde, isn’t in the repos.

              Also, I would assume you are aware of what ports are given you used the term repos above, and I simply found nano in the standard FreeBSD’s ports’ search website.

              Now, if you are not aware of apropos and man -k, that is a totally different class of problem, which I could simply advise you to address, especially when fiddling with the console is part of what you do for a living: in my experience, being able to find information offline is a enormously useful (and almost necessary) skill in the UNIX world.

              1. 1

                I think I specifically mentioned… Let me check…

                Oh, no, it’s only in the comments:

                I didn’t have to compile anything.

                I am aware of the ports collection. I was interested to see it’s now an optional install. I ticked the box, but I never needed it. That’s good. I am happy I didn’t need it.

                If I am looking for an easy clean desktop OS, that means, for me, not having to compile any of my own software. I was using Linux in the mid-1990s. I remember building my own kernels, and not with any pleasure or nostalgia. I expect this stuff to just work, and to be in the repos, by which I mean 1 command installs a binary in the right place – wherever that may be, I don’t want to have to know – and then it is automatically kept updated forever.

                I think this may seem like an odd attitude to FreeBSD habitués.

                I don’t actually like nano or joe or pico. The opposite, in fact. I dislike them all, I just dislike them less than I dislike Vi or Emacs, which I loathe.

                I like Tilde. Perhaps I should have looked in the ports tree for that, instead. I may still do that, if I remember.

                1. 1

                  Small follow-up (because I am listening and trying to learn here)…

                  No, I could not find Tilde in the ports tree.

                  I tried to install ee and got nowhere, and strings such as “ee” and “ree” are too short to search for – they return dozens or hundreds of hits.

                  It took a while to find out it’s already there. That was… puzzling.

                  Anyway, yes, it’s easier, but I’m not sure it’s going to be much quicker.

                  I am put in mind of the Reg review comments: that BSD users were baffled I’d use Ctrl+cursor keys to move around. They’d never heard of that before, apparently.

                  Ctrl+cursor word-by-word movement has been part of the CUA standard for over 30 years now. This is a standard so old, it’s even older than the ancient “Unix means it uses AT&T code” canard.

                  IOW it predates Novell buying AT&T Unix Labs and giving the trademark to the Open Group… in 1993.

                  The basic CUA keystrokes are honoured by, and work on, basically every GUI editor on every xNix OS, as well as on Windows and macOS. They are not one rival standard: they are the standard and have been since the late 1980s.

                  I have no idea what keystrokes FreeBSD uses to move word-by-word around the command line, but it’s not the standard one. Maybe it is some strange Emacs-ism or something. No idea.

                  The reason I like Tilde is not because it’s easier or simpler: it’s because it works with the editing commands that have been part of my muscle memory since about 1989. That doesn’t apply to Joe, Nano, Pico etc. and it doesn’t apply to EE either.

                  So, good to know, but not actually much real help. :-/

        2. 1

          Thanks – I will take a look.

      2. 2

        Just to be sure, these are speculations based on just catching up every now and then.

        Well, that is startling. What changed?

        I am not completely sure, but some thoughts are that Unix-like operating systems consolidated to Linux and Linux desktop being a niche FreeBSD became even more a niche. I also think a lot of people somehow got happy with macOS. While it was somewhat common for a lot of open source software to work just fine on any POSIX system, I think a lot of work now has to go into making things work well on FreeBSD, so that’s what people focus on.

        Maybe also hardware got a lot more complex? Raising the bar. And while many companies nowadays also write Linux drivers, very few write them for BSDs (most stuff like enterprise network cards, etc.). Or take bluetooth, which is annoying both on Linux and the BSDs.

        I am not sure but the community also seemingly shrunk, maybe as a side-effect. Probably lots of tiny things. Take video games. Nowadays Steam works fine on Linux, but FreeBSD requires Wine, OpenBSD doesn’t support it, and even if it did it wouldn’t work for 32bit stuff. So now Mono/XNA/… based games, like Stardew Valley, Northgard are what works on OpenBSD. Or take video streaming. Kind of ironic that Netflix won’t work out of the box on the system they use, because of DRM/Widevine which is also something that hinders browsers (and everything Electron based for example).

        There’s also a ton of technologies that essentially are anti-porting. Software depends on one of systemd’s “parts”, or the default way of a service is spinning up a Docker container, or that current trend of using flatpak and snap.

        What also simply went wrong is some desktop BSDs, like PC-BSD/TrueOS, which a long time ago was certainly on par with Linux distributions in the same space, but somehow ended up experimenting a bit too much, making risky decisions that didn’t really work out causing it to now be dead. DesktopBSD also stopped. But I guess that space is now recovering, as there’s some Desktop BSD projects. So maybe it will get better here.

        Anyways, all of that I think simply made developers drop FreeBSD for macOS, which is close enough with its userland (base utilities, bhyve, dtrace, etc.). Since they weren’t too “religious” about OSs in first place they might just have switched, which means there’s fewer people that care about FreeBSD on the desktop. And those who do are fine with how it is for the reasons mentioned in the previous post.

        That is hard to assess. Frankly, I find the repos for mainstream distros like Ubuntu and openSUSE to be superb, and almost anything that is mainstream and FOSS is just there and just works.

        I can’t talk about openSUSE, but I find Debian and Ubuntu a complete mess. Software is either ridiculously outdated (years), has been patched to not work, has non-default flags, and you need a ton of third party sources be it for postges (and postgis), for nginx, for your programming language of choice, etc. Good luck when they are not compatible, and good luck when they drop that service. Also this can be very annoying to debug. I’d argue that it’s a huge part of why Docker is successful as a workaround. And probably also why people use horrible hacks like snap and flatpak.

        Odd. Very easy on Ubuntu; fairly easy on openSUSE Leap. Can be a pain on Fedora. Is a pain on Debian etc. Not sure why anyone would look to an xBSD for this, but please do enlighten me.

        I think you misunderstood me/I wrote that badly. This was to say why people are being told to use FreeBSD over other BSDs, like OpenBSD with which they might be more happy in other regards.

        Um. I am guessing you are not aware, but I am the FOSS and Linux reporter for the Register. I’ve been using Linux for over 25 years now and have been writing about it professionally since the 1990s. I helped build the first customised cover-mounted Linux distro on a UK computer magazine, and wrote the accompanying 2-month multipage feature on it, about 25Y ago.

        Before that, I mainly worked with SCO Xenix and SCO UNIX, but also AIX and Solaris a little.

        So? I am not sure what you mean by that response as it doesn’t seem to have anything to do with the sentence you are quoting. You obviously are better off with a different OS since you don’t seem to be happy with your FreeBSD experience, or am I completely misunderstanding something?

        I always hear that from BSD enthusiasts. I have never understood it. For me, all the BSDs are about 100x quirkier and weirder than even the most way-out Linux.

        I gave you an example that you seemingly just ignore, without giving a single counter example. I also wouldn’t consider myself a BSD enthusiast, as I am writing this on a Linux system. Also does “all the BSDs” include macOS and iOS?

        Anyways, why not use Linux then? I don’t understand where you are heading with that.

        On ChromeOS fanboying: I also think ChromeOS is really good. I think a major part of it is that it basically ignore the Linux world, because it has resources to do so. It just uses Linux for having a (kernel) interface that much software already targets. It’s a bit like with Android. By that standard FreeBSD is widely successful because of macOS, iOS and Playstations, Enterprise grade routers, Netflix, etc. But I guess that’s not what you talk about.

        This time, since about 2019-2020, is the single biggest chance for FreeBSD that it’s ever had or ever will have. To scoop up those disaffected Linux users who hate systemd and snap and flatpak and all that.

        Like you are not interested on servers, I am not really interested in FreeBSD getting users.

        FreeBSD has another year or 2 to try to win over Linux users alienated by all the weirdness encroaching on Linux now. If it doesn’t, it will never escape its tiny niche.

        How so? Why one to two years?

        The Hello System has a chance, a very small one. I really hope it succeeds.

        I bet most FreeBSD users haven’t even noticed it, and can’t see any importance to it.

        I’d think most FreeBSD users interested in FreeBSD desktops enough to read news on the topic did notice it. It was widely mentioned. I am no such user and still read about it many times.

        But: Why is it important to FreeBSD users? Do you mean desktop users? Even then, how is it important to them?

        Also, macOS has its own unnamed hypervisor, which AFAIK is unrelated to bHyve.

        Don’t really know about that. I was talking about Docker, which is the only instance where I’ve ever used a hypervisor on macOS. Also I was talking about FreeBSD users and developers using macOS for their desktop need saying that they don’t really have a reason not to.

        BTW, I strongly suggest you read my Register reviews on FreeBSD, NetBSD and OpenBSD to get a handle on where I’m coming from, because already, I think your view is wildly different to mine.

        I am not really interested in any reviews on them. I don’t think I’ve really shared my views on these OSs or at least it wasn’t my goal. I completely agree with the article, which is why I don’t use FreeBSD on the desktop.

        I do not use Docker – again, server stuff, don’t care – but I wouldn’t be surprised if it used the “official” tool. I don’t know, though.

        You don’t care, but just as a note: Docker on macOS uses xhyve, which is bhyve for macOS, because it’s not Linux, requiring it to use a hypervisor. Fun fact, FreeBSD provides a Linux API.

        I am honestly a bit unsure where you wanted to head with your response. I hope I somehow clarified something, because I wanted to add some context to the problems you mentioned in your original article and follow up on the bits where you asked questions.

        1. 1

          Without going into a quoting frenzy, I will try to answer your general questions.

          You gave the impression that there were specific changes which have made matters worse in recent versions, but you don’t seem to have any. That’s disappointing.

          I agree with you about desktop BSD distros overreaching and thus failing. New desktops, new packaging formats, etc. Bad plan. The path to success is generally to change the minimum you can, and take as much advantage as possible of others’ efforts.

          I find it interesting that you call projects like Ubuntu and Debian – arguably the two most successful non-Windows free OSes there are or have ever been – a total mess. I’d like to hear stuff that is more specific. They work great for me. Ubuntu has been my main OS since the first version and has served me very well indeed.

          As for my talking about experience with other OSes, what I was trying to get at was very simple: I’m not a newbie, I’m an experienced professional with pretty broad experience at that. Whenever I criticize any of the BSDs in any public article or blogpost or whatever.

          https://www.theregister.com/2022/04/22/openbsd_71_released_including_apple/

          https://www.theregister.com/2022/08/10/netbsd_93/

          … I get upset BSD fans saying I’m a fool who doesn’t understand anything. I am not. I suspect I may have broader xNix experience than anyone who has ever attacked me on this.

          I am not evaluating FreeBSD as my potential new OS. (And no, I am not comparing it directly to any commercial variants or products that use it.) I was and am attempting to evaluate it as a potential free OS for general computer users. Whether it’s right for me is irrelevant. I am trying to point out and highlight weak points, and it saddens me that I am apparently failing to get that across.

          You say that you’re not interested in getting users, which is exactly the same thing that I hear from Vim fans when I criticise Vim, or from Emacs fans when I criticise Emacs.

          The core point that this response misses is that any and every FOSS project lives and dies on the health of its community. All projects need new people coming in, trying it, liking it, and sticking with it, whether they fix the code, or hunt bugs, or document it, or talk about it, or simply quietly sponsor it and get other people to do those things.

          Software needs users. Not customers, if it’s free, but users who like it and want it to survive. No user community means certain death, and a rapid transition to being a fossil, maybe occasionally run in a VM for nostalgia.

          Communities need to grow, because if they don’t, then their members age out and die, and then the software dies with them.

          Currently the other 2/3 of the human race is coming online, the digitally disenfranchised billions in Africa and Asia. Meantime, the developed world is aging and childbirth rates are dropping – globally, a good thing for us all! – but bad news for old software that is beloved and maintained by aging people.

          I recently wrote about Chinese Linux distros: https://www.theregister.com/2022/08/30/kylin_the_multiple_semiofficial_chinese/

          It didn’t get many comments or shares. That’s a shame. This is a vital part of the Linux market, and I suspect that Ubuntu now has many many more users in China than in all other countries put together – and it doesn’t know, and it doesn’t take anything much from that distro.

          For example, Ubuntu Kylin will if given a disk to itself install in a complex setup with a boot partition, two root partitions, and a separate data partition. I have not been able to find out much about this but I think it is in an attempt at fault-tolerance; Deepin Linux, the leading Chinese distro, does the same.

          ChromeOS does this, which is one reason it’s almost impossible to dual-boot it with anything else. It’s very important tech but mainstream Western distros are completely ignoring it.

          In a few years, all the big commercial distros are probably going to move to this sealed-down model, where the root filesystem is read-only, apps are in sandboxed modules layered on top, and you can’t change anything you don’t like. SUSE is doing this with MicroOS, Red Hat with Sliverblue and Kinoite and the remnants of Project Atomic, Ubuntu is doing it with Ubuntu Core. Smaller desktop distros like Endless OS are in fact leading the way.

          Once this is normal and accepted and just how Linux works, that will soon be what everyone expects, and there will be no selling point any more in an OS where it isn’t true and it’s not like that.

          That is why I say FreeBSD has a critical window of opportunity now, one which will soon close. Pick up some of the influential Linux migrants now, while it’s still a comparable offering, and before it’s too different and too weird and the window is gone.

          1. 1

            I get upset BSD fans saying I’m a fool who doesn’t understand anything. I am not. I suspect I may have broader xNix experience than anyone who has ever attacked me on this.

            That’s quite reasonable. Update: Sorry, I misread that as, “I get upset by BSD fans…”.

            I am not evaluating FreeBSD as my potential new OS… I was and am attempting to evaluate it as a potential free OS for general computer users.

            I think the controversial thing is that you aren’t just evaluating it as an OS for general computer users, you are also quite strongly saying that it should be an OS for general computer users. When you write things like this:

            I feel that these teams need a bit of a kick up the arse, TBH, to be forced to see and register and acknowledge their context and that others don’t share it.

            You are saying, in quite a strong way, that FreeBSD developers have the wrong goals and should be forced to change their goals to align with what you want. That’s obviously going to rub some people the wrong way!

            Your justification, if I understand you correctly, is that if they don’t realign their goals then the project will fail. You seem to think that if FreeBSD doesn’t attract a bunch of Linux exiles, then FreeBSD will collapse. But it really isn’t clear why that should be so. Why can’t they carry on doing what they do well now, and leave the Linux users to their ChromeOS/Android fate?

            1. 2

              Comments like this are why I try to engage with readers, why I read and respond to the comments on my Register articles, and why I post my blogs here.

              Because it’s fascinating to me to see how badly people misread what I say, and it’s educational. I am trying to learn from this. Trying to write less ambiguously, to learn what people don’t see or get wrong, so I can avoid doing it again.

              You have got my comment and indeed my blog post – and note, not an article, ‘cos I am off work with COVID and don’t have much focus or concentration at the moment – almost totally backwards.

              I am not saying FreeBSD should be anything. I am not saying it ought to change because I say so. I am not saying heed my infinite wisdom and thee shall profit thereby. Nothing like that.

              What I am saying is that this is, somewhat to my surprise, actually a pretty competent desktop OS.

              It’s not billed as on, it’s not sold or described as one, and there is bugger all help in the installer in making it into one. But if you are determined and don’t give up, it’s significantly easier than it was just a few versions ago.

              It offers a good selection of apps, and once you find the magic incantations to install a few things, a tonne of handy extras come in with them. So, by installing just half a dozen packages, not only do you have those apps, but you also have things like volume controls and media keys and a JVM and so on. That you can easily add a network icon to your panel.

              I am not saying “FreeBSD needs to do all it can to be a better desktop OS.”

              That is the opposite of what I am getting at, which is:

              FreeBSD is actually a surprisingly capable desktop OS, and if only there were a few more easy steps in the installer, and a few more hints, this is something that could be accessible and useful to a lot more people.

              A very common way for people to learn a new OS is to make it their desktop and do their ordinary desktop stuff with it for a while. That is a great way to get familiar with it.

              As such, this is something it would really benefit the installation program to acknowledge. Give it something like Debian’s tasksel, and make one of the options a tool to install and configure a graphical desktop.

              As it was it took me about 2-3h of work and Googling and manually installing packages, and there is no need for that in 2022.

              Some modest changes, to help people a bit further with the installation process, and this OS could win itself tens of thousands more users and some of those people will hang around and contribute. It would be a net benefit for the OS.

              If you install a desktop, then that should pull in X.org automatically. When you’ve got a desktop, there should be an .xinitrc written automatically for every user account. Sudo ought to be there as standard, preconfigured with the appropriate groups – I mean, Octopkg even expects it!

              I am not talking about massive changes that are needed for other’s benefits.

              I am saying that for FreeBSD’s own benefit, the install program should not just build a basic text-only OS and then dump you at a shell prompt, because it is not 1992. That was 30Y ago now.

              A few basic options – bare server, LAMP server, fileserver, graphical desktop – and when the user picks one of them, leave them with a working ready-to-use OS, complete with SSH configured and running, some seerver packages installed with default configs; or, if they pick a desktop, give them a basic desktop in which they can read the friggin’ Handbook.

              I just recently reviewed MX Linux and to my own amazement I gave it a rave review. They have a good handbook, and they’re proud of it, and you know how you can tell?

              Because they put a link to it right there on the desktop.

              On my shiny new FreeBSD box, there is no visible sign whatsoever of this magical document you are all extolling. No icon, no menu entry, no login prompt that says “welcome to your first login, type handbook to RTFM.”

              These are not big things. These are not difficult to do.

              The hard work is already done.

              What is left is just sweeping up the sawdust, throwing down a welcome mat and leaving a note to tell people where the mains switch is in their new house.

              I should not have to install my own graphics drivers! That is horrendous! I should not have to write my own lines into init scripts! When I install a package, that should just happen. If there is some deep philosophical objection, then ASK and if the user keeps pressing Return, just do it.

              1. 2

                Well, first of all, thank you for a very reasonable reply to a comment that apparently completely misunderstood yours!

                I am not saying FreeBSD should be anything. I am not saying it ought to change because I say so. I am not saying heed my infinite wisdom and thee shall profit thereby. Nothing like that.

                That is great. I’m sorry that is how I understood your comments (not the original blog post, just your comments here).

                Because it’s fascinating to me to see how badly people misread what I say, and it’s educational. I am trying to learn from this. Trying to write less ambiguously, to learn what people don’t see or get wrong, so I can avoid doing it again.

                In that spirit, here are a few things you wrote that made me think you were saying that FreeBSD ought to change for the sake of its survival:

                I don’t think its community realises that right now it faces a make-or-break opportunity, though.

                FreeBSD is a rival to basically every hardcore Linux distro out there. It needs to compete with those, because that’s where the mainstream is now.

                No users means no money for developers. No developers means you die.

                1. 1

                  :-)

                  I am getting used to it now, TBH. I have a long way to go; there were well over 20 years between my 2 main full-time stints at doing this.

                  FreeBSD doesn’t have to do anything.

                  But right now is a big chance for it, I think… if it just moves a bit closer to the way things are done on the Linux side of the fence.

                  If it doesn’t do it: well, I would not bank on a healthy future, but then, I don’t for any of us; see elsewhere in the thread. It may just trundle along as it is.

                  Or, maybe, the Hello System will somehow prove to be a big hit, and it’ll gain lots of new users that way. Who knows?

                  But there is a chance. Inasmuch as there’s a mainstream BSD, it’s FreeBSD. It doesn’t have the political agenda I see in NetBSD. And it’s so nearly there that it is frustrating to see that the remaining gap is small.

                  If it had ended installation by asking if I wanted a modern editor, or if I wanted a GUI, and told me what to do next, that would have helped a bit. But nerp – and no mention on the web links I found either.

                  1. 1

                    And it’s so nearly there that it is frustrating to see that the remaining gap is small.

                    I completely understand that. I’m sorry that I misunderstood what you were saying: I’ve re-read your comments and I guess I just emphasised the wrong things in my interpretation.

                    I suppose once I thought I understood what you were saying, I read the rest in the light of that (mis-)understanding.

                    Or, maybe, the Hello System will somehow prove to be a big hit, and it’ll gain lots of new users that way. Who knows?

                    I wasn’t aware of the Hello System before your comments. I don’t pay a lot of attention to FreeBSD - is the Hello System really unknown among FreeBSD users? From a quick glance at their docs, it looks like it answers (or, at least, is intended to answer) most of your complaints.

                    Anyway, in summary, I don’t care about server stuff. It’s not very interesting to me

                    In my defence, I’m the opposite. I don’t really care about desktop stuff. It either Just Works™ or I’m too old to waste my life configuring things. I’ve used Linux since 1996 but it’s always been shit as a desktop: I’m writing this on a Chromebook :)

                    1. 1

                      That is good to hear. :-)

                      And I see the poor tone and phrasing in my comments now, too.

                      As for wanting low-stress computing… I can totally understand that.

                      I have opted for the easy life where computers are concerned for a long time now. It was around the turn of the century, when I saw the needless but mandatory bloat in WinXP on the desktop (themes, video editors, etc.) and the blasphemous horrors of Active Directory on the server side, that I switched to xNix full time.

                      I ran Caldera Open Linux, then SUSE, then Ubuntu. I still run Ubuntu now. I never liked GNOME 2 much – mainly for its poor handling of vertical toolbars – so I liked Unity and I still use it. Since it’s not available on any other distro, for now, that’s kept me on Ubuntu.

                      I’ve worked for both Red Hat and SUSE, where Ubuntu and Unity weren’t really options, so I tried everything out there and settled on Xfce. It needs a bit more tweaking for me but once that’s done, it’s good.

                      But there is a big difference between playing around with an OS to try to get a feeling for it, on a spare machine or in a VM, and having to fight with it to use it as your primary OS. The evaluation part is fun, for me.

                      The sad thing, for me, is that Ubuntu reached a point where it was pretty damned good, quick, just went on and just worked. Then they lost focus. The downfall began with the disastrous HN thread which led to them cancelling all their innovative stuff and just copying RH. https://news.ycombinator.com/item?id=14002821

                      Mark Shuttleworth failed to achieve his goals: although Bug #1 is fixed: Windows is no longer the automatic #1 OS – macOS and ChromeOS displaced it, not Ubuntu.

                      Ubuntu failed to make big headway on mobiles and tablets, too.

                      So he’s given up, AFAICS. He wants to float the company, and the way to make money from Linux is servers. So Canonical now focusses on servers, and the desktop is suffering from neglect.

                      Red Hat is flailing as it always has, and its nasty corporate culture of meritocracy (a word originally intended as satire), NIH syndrome and neophilia is making a mess of desktop Linux. Ubuntu is distractedly copying it.

                      SUSE bought a container company, so now, everything must be containers.

                      There isn’t much direction or leadership or focus on desktop Linux any more, outside of Google, which nobody can be bothered to copy. There are some good projects. I like Alpine, SpiralLinux is impressive, as is Garuda. The one I might actually use myself as my main offering is MX Linux.

                      But they’re mostly small or one-person efforts, or they lack corporate backing, or they have no server offering, and generally are not laying down a big bold path for others to follow.

                      That, ISTM, leaves an opening.

    7. 1

      The nginx package and its options alone leave every Linux distribution far behind.

      Not every: nix is doing well in those areas https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/http/nginx/modules.nix , https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/http/nginx/generic.nix

  1. 1

    It misses a rant flag, as I noticed the original submission five years ago had, particularly because it is more of a rant about UNIX than any reflection on the UNIX philosophy.

  2. 1

    This format seems to bring many of the good design items highlighted in the chapter “Data File Metaformats” of “The Art of UNIX Programming”.

    Particularly, I like it is easier to set nested scopes than the record-jar format, but that is simply by the fact the record-jar’s parser is simply a deterministic finite-state machine, while the SML’s is a pushdown automaton.

    Still, a valuable contribution, which I will be triggered to use when in need of a context-free configuration language.

  3. 3

    I seriously want to use something like Thunderbird, especially since mail/calendar is one of the main blockers to my using Linux, but I don’t understand what anyone uses it with. What email provider and protocol are you all using with it? Does everyone use it with gmail?

    The lack of Exchange support is what keeps me from switching and every Exchange-supporting client on Linux seems to be abandonware (eg Hiri/Mailspring). I’m not willing to switch to gmail.

    1. 10

      Works with any decent IMAP server as far as I know, including Outlook.

    2. 6

      The lack of Exchange support is what keeps me from switching and every Exchange-supporting client on Linux seems to be abandonware (eg Hiri/Mailspring).

      For many years, I use DavMail + Thunderbird to address the same use-case of yours, and it works flawlessly. DavMail even provides a step-by-step documentation on how to set it up with Thunderbird.

    3. 5

      Works great with Fastmail including calendar

    4. 3

      I’m using it with OpenSMTPD and Dovecot. Not using the calendar.

    5. 3

      Works for me, with Gmail, Hotmail, AOL Mail, Yahoo Mail, and in $JOB-1, with Office365, and with Novell Groupwise. Of course it also works with every FOSS POP3/IMAP combo I’ve ever thrown it at.

      I tried over a dozen FOSS mail clients when I started at $JOB-1. The only one I stuck with for more than a few days was CLAWS, but its single-threading became a deal-breaker. I went back to Thunderbird and I still use it today, as I have for most of the time it’s existed as a standalone product.

      1. 3

        On which note, I’d post my review from the Register when it goes live (any minute now), but AFAICT Lobste.rs still bans the Reg.

        As that is $JOB, this makes me sad.

        1. 2

          the irony of a tech site banning the reg! sad state of affairs indeed :(

          1. 2

            I agree.

            OTOH, although I do want feedback and discussion, I also do not want to spam people with self-promotion. :-/

            Some of my stories have done very well on The Orange Site and on Slashdot, so it’s all good, I suppose.

    6. 2

      Doesn’t Evolution have good EWS and MAPI support?

    7. 2

      Thunderbird supports Exchange with a plugin. It is “paid”, but trivial to circumvent by extracting the extension.

    8. 2

      The lack of Exchange support is what keeps me from switching and every Exchange-supporting client on Linux seems to be abandonware (eg Hiri/Mailspring). I’m not willing to switch to gmail.

      Evolution is the only Exchange client on Linux that works for me. It’s pretty OK, though I’ve had issues with 365 authentication.

  4. 5

    Why does nobody complain about how OpenSSL doesn’t follow the UNIX philosophy of “Do one thing well”?

    1. 34

      Probably because there’s already so many other things to complain about with openssl that it doesn’t make the top 5 cut.

    2. 18

      Because the “Unix philosophy” is incredibly vague and ex-post-facto rationalization. That, and I suspect cryptography operations would be hard to do properly like that.

    3. 4

      Does UNIX follow the UNIX philosophy?

      I mean, ls has has 11 options and 4 of them deal with sorting. According to the UNIX philosophy sort should’ve been used for sorting. So “Do one thing well” doesn’t hold here. Likewise, other tenets are not followed too closely. For example, most of these sorting options were added later (“build afresh rather than complicate old programs” much?).

      The first UNIX, actually, didn’t have sort so it can be understood why an option might’ve been added (only t at the time) and why it might’ve stayed (backwards compatibility). Addition of sort kinda follows the UNIX philosophy but addition of more sorting options to ls after sort was added goes completely contrary to it.

      1. 3

        Theoretically, yes: it seems that Bell Labs’ UNIX followed the UNIX philosophy, but BSD broke it.

        Reference: http://harmful.cat-v.org/cat-v/

    4. 4

      Everyone’s still wondering if the right way to phrase it is that “it does too many things” or “it doesn’t do any of them well” ¯\_(ツ)_/¯

    5. 2

      Maybe because it’s not really a tool you’re expected to use beyond a crypto swiss army knife. I mean, it became a defacto certificate request generator, because people have it installed by default, but there are better tools for that. As a debug tool it is a “one thing well” tool. The one thing is “poke around encryption content / functions”.

      Otherwise, what would be the point of extracting things like ans1parse, pkey, or others if they would be backed by the same library anymore. Would it change anything if you called openssl-asn1parse as a separate tool instead of openssl asn1parse?

    6. 1

      For the same reason no one complains about curl either?

      1. 1

        related, here’s a wget gui that looks similarly complex https://www.jensroesner.com/wgetgui/#screen

  5. 5
    “The moral lesson”

    [If you] want to find and replace all instances of a string in your repo […] https://stackoverflow.com/a/6759339/2129219 […] tell us

    find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;

    […] [T]his command is dangerous to use in a git repository. Specifically, this can corrupt your .git contents.

    […]

    What is better?

    Read the manpages of find(1) and sed(1) before copying-pasting commands from StackOverflow. Or use one of the many “explain a command” tools.

    I use find(1) all the time in Git repositories. In fact, I have shell functions that do so. Here is one of them:

    function search {
    	find . \( -type d -name '.git' -prune \) -o -type f -exec egrep -Hn $* {} \+
    }
    

    The important trick (which I am sure I got from a comment from @andyc) is to use -prune; the GNU’s find(1) manpage even gives an example on how to use it:

    -prune

    True; if the file is a directory, do not descend into it.  If -depth is
    given, then -prune has no effect.  Because -delete implies -depth, you cannot
    usefully use -prune and -delete together. For example, to skip the directory
    src/emacs and all files and directories under it, and print the names of the
    other files found, do something like this:
    
    find . -path ./src/emacs -prune -o -print
    

    Now, about sed(1), just add the suffix to the -i, so it makes a backup of the file before overwriting it.

    The fix

    OK, so the “let’s give a moral” section is over.

    How the command should have been?

    find ./ \( -type d -name '.git' -prune \) -o -type f -not -name '.git*' -exec sed -i.bkp -e 's/apple/orange/g' {} \+
    

    (Yes, \+ instead of \; speeds up the process, in this case.)

    What does it do?

    • Go down all the tree, except for the .git directory;
    • then search for all files, except those named .git* (e.g., .gitignore); and,
    • for every file provided by find(1):
      • make a copy of it with the suffix .bkp; then,
      • change all the occurrences, in every line, of “apple” to “oranges” in the original file, and save it.

    What does it do that git ls-files | xargs sed -i -e 's/apple/orange/g' doesn’t?

    It also replaces the files not tracked by Git, yet.

    P.S.

    I actually went to read the StackOverflow question which one of the answers is referred by the post.

    Well… The (comment on the) immediately answer below the one referred has the closest to the proper solution the author was looking for:

    grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'

    To be fair, I would prefer

    grep -rl 'apples' dir_to_search_under/ | grep -v '/\.git' | xargs sed -i.bkp 's/apples/oranges/g'`
    

    Because it would also change files not tracked by Git—that is why I haven’t used the git ls-files (as suggested in the post) or the git grep -l (as suggested in the comment of the “immediate answer” in StackOverflow).

    This answer is way better, because:

    • it simply shows the files that matches “apples”;
    • it ignores everything related to Git (i.e., files or directories starting with .git);
    • it makes a copy of the files which contains “apples” before changing them.
    1. 3

      has the closest to the proper solution the author was looking for:

      grep -rl 'apples' /dir_to_search_under | xargs sed -i 's/apples/oranges/g'

      It’s not a proper solution in cases when there are spaces in filenames, which is not that uncommon.

      $ echo x > '1 2'
      $ echo x > '3 4'
      $ grep -rl x
      1 2
      3 4
      $ grep -rl x | xargs -n1
      1
      2
      3
      4
      

      This can be fixed in a non-portable way by ensuring that the output entries are separated by the null byte.

      $ grep -rlZ x | xargs -0 -n1
      1 2
      3 4
      
  6. 6

    I have to disagree with the author, by what I understood via skimming the article.

    In my opinion, computer science programs (which, from now on, I will call “university”) should teach students the tools to deeply understand what is built today, and prepare them to “push the boundaries of the knowledge” on their field, tomorrow (i.e., when they graduate).

    Universities are not vocational schools, so they do not have the duty to prepare “good, well-trained employees that will be productive in a blink of an eye”.

    I also disagree with the session “what not to teach”:

    What Not To Teach

    […]

    In terms of required courses? Math. I found every single math course useless except for discrete math […]

    Computer science isn’t about Math.

    Mathematics is, generally speaking, about modelling abstract knowledge, highlighting its patterns and predicting outcomes based on inputs.

    That is precisely what programmers, in the industry, have to do day-by-day.

    In my experience, the poorest programmers I worked with also lacked (applied) mathematical insight, even though they were savvy communicators or “technologists”.

    I like to test this theory changing “computer science” by any other program of an university: medicine, civil engineering, law.

    Should a physician know how to communicate with the ward’s staff? Of course.

    Should be taught at the medicine school as a subject? I am not sure.

    Should anatomy not be taught as a subject? I don’t think so!

    Good-to-have in the day-by-day of the profession is not a must-have in the university: “the market” has, also, the duty to train their professionals in the skill they find useful! (Physicians have residence for a reason, huh? Lawyers and civil engineers also are supervised in their first years for some reason.)

    Unfortunately, utilitarian extremists are not able to see it, and it is easy to see why: many of the benefits of the choices in the university are holistic, long-term and “fill many gaps” that an individual may not experience in his professional life. (The power of big numbers…)

    What I do think is necessary is a better professionalisation of the “programming professions”; and as part of it, a reform in the education is necessary: not every cook must be a chef, and I think that not every programmer has to have a computer science degree.

    OK, that was quite a messy train of thought. I hope that at least someone can make something useful from the words above.

    1. 5

      Universities are not vocational schools

      Yes, that’s why in an ideal world basically everyone who gets a CS degree today (minus an extremely small number of people who love math) would do an apprenticeship instead. The university is a guild where weirdos who like to spend all day reading and writing support their habit by spending ~10 hours a week teaching people and recruiting the next generation of weirdos. If you want to learn to paint like Vermeer, you gotta work in his workshop. If you want to read about how Vermeer was a master of light, his role in perpetuating Dutch bourgeoisie values, etc. you go to university. For some reason, we have CS departments where people who want to learn how to program like Brian Kernighan instead learn from people like Scott Aaronson. It doesn’t make sense. I love reading Aaronson’s writing, but it’s not what I went to school to learn how to do.

  7. 2

    Seems like a lot of situational (“nuclear apocalypse”) roleplaying to say that OpenBSD has better manpages than Linux. With FreeBSD my experience has been that the manpages are about equally terse as Linux, but the Handbook makes the system a joy to read about and use. Are OpenBSD’s manpages that much better? xinit has the same manpage on OpenBSD as it does on Ubuntu. mail has a good manpage. Is there a good example of these differences between Linux and OpenBSD in a manpage? I’d love to see it.

    OpenBSD was create for free men like you, enjoy it.

    Lol

    1. 2

      Is there a good example of these differences between Linux and OpenBSD in a manpage? I’d love to see it.

      I find the OpenBSD’s manpages better written. Some of the examples I routinely consult (OpenBSD vs. Linux):

      As you will notice above, some of the OpenBSD’s manpages are shorter than Linux’s (or GNU’s) ones—notably, awk(1) vs gawk(1).On the other hand, awk(1) links to script(7), what doesn’t have an equivalent (as far as I am concerned) on Linux.

      However, in general, I tend to find the information I want on OpenBSD’s manpages way quicker than on Linux’s ones, and I usually find the explanation better.And the fact almost all of them have an examples’s section is very handy.

      As a side effect of its readability, I tend to read OpenBSD’s manpage more often, and more thoroughly, than the I use(d) to do in other system (including other BSDs).

      I wonder whether mdoc(7) is the reason OpenBSD’s manpages are so uniformly better than their equivalents.

      P.S.: I linked to the Ubuntu’s manpages instead of the man7.org’s ones because man 1 ed in my (Ubuntu) system presents the same telegraphic manpage linked, while man7.org’s one is the POSIX Programmer’s Manual manpage, which isn’t even installed in my system.

      1. 3

        I wonder whether mdoc(7) is the reason OpenBSD’s manpages are so uniformly better than their equivalents

        Having somewhat recently switched to mdoc from classic/Linux man macros, it certainly doesn’t hurt. It’s dramatically better in every way. Semantic markup, built-in decent HTML output, tool-enforced uniformity, etc. It shows that it was built by people who actually think man pages are good.

      2. 1

        I decided to go a little further and compare equivalent manpages which are introduced only for the OpenBSD and only for Linux, triggered by your comment about the manpage of xinit(1) being the same on OpenBSD and Linux—it is so because it is an “imported code” on both systems, so it makes sense it is the same in both operating systems. (The same happens, for example, for tmux(1)).

        So, I compared OpenBSD’s ktrace(1) vs. Linux’s strace(1) and, in my opinion, it shows the good difference between those systems: those tools provide the same functionality, but the manpage of the latter is overwhelming and abstruse compared to the one of the former.

        Thus, I think the manpages of OpenBSD is a great example of their KISS attitude, without sacrificing on completeness of information.

    2. 2

      I’m not sure the degree to which it’s enforced, but OpenBSD used to refuse to merge any changes that affected an interface that didn’t come with updates to the man page. FreeBSD was never quite as aggressive, most Linux things don’t come close to either. For example, consider something like _umtx_op, which describes the FreeBSD futex analog. Compare this to the futex man page and you’ll notice two things: first, it’s a lot less detailed, second it has an example of a C wrapper around the system call that isn’t actually present in glibc or musl. OpenBSD’s futex man page isn’t that great - there are a bunch of corner cases that aren’t explicit.

      Or kqueue vs epoll - the pages are a similar length, but I found the kqueue one was the only reference that I needed, whereas the epoll one had me searching Stack Overflow.

      The real difference between *BSD and Linux is in the kernel APIs. For example, let’s look up how to do memory allocation in the kernel. FreeBSD has malloc(9), OpenBSD has malloc(9), both with a description of the APIs. The level of detail seems similar. Linux has no kmalloc man page.

  8. 5

    Figured out something in the terminal?

    Paste it into a bash script verbatim

    Obligatory reference to Ctrl+X+E, which I learned from The Shell Hater’s Handbook presentation.

    1. 2

      and I learned it from you. thanks!

    2. 1

      Thanks for sharing! I love how neatly it ties into the design philosophy: write small programs that does one thing well. I’ve been studying quite a bit about various IPC mechanisms lately, and ultimately I discovered that the kernel gives you everything you need for performant and robust IPC. It’s not a perfect fit for every use case, but I think it is vastly overlooked.

    3. 1

      Or, in set -o vi or bash-rsi mode, esc-v.

  9. 4

    My website is about 30 lines of shell; I guess I need to brag now: http://len.falken.directory/misc/writing-for-the-internet-across-a-human-lifetime.txt

    1. 2

      looks like http://len.falken.ink is a bad link in yout text

      1. 1

        Yeah, I refused to pay $40 to renew the .ink domain so I let it expire and bought a super cheap .directory domain.

        1. 1

          Considering your old domain is now scammy as hell you probably did the right thing… but you should update old links.

          1. 1

            Good point; will do :)

    2. 1

      Hard wrapped text looks weird on a screen that’s narrower than the chosen width.

    3. 1

      Your site is a little gem!

      Not only plain text, but some posts are valid Prolog programs!

      I must admit find it is a little too radical to not have any clickable links, so I find difficult to reproduce your style in my own page; on the other hand, your site is easily read in all the platforms and a browsers I use, including lynx(1)!

      Very well done!

      1. 1

        Double click -> Right click -> open in new tab. Browsers could be smarter and highlight links in text files.

        1. 2

          Certainly it is not a problem on the desktop.

          But that workflow is more complicated on lynx(1), where I have to trigger tmux(1), navigate to the part of the page it has the link, copy it, then paste it on the command line to open a page inside lynx(1).

          Given you are using plain text files, I imagined you had TUI browsers in mind. It does not seem the case. (In fact, I just noticed your landing page is a RSS feed, which is nicely rendered in the desktop, but not much on mobile, lynx(1) or w3m(1).)

          Anyhow… I liked it quite a lot! 🙂

  10. 2

    A few people asked me about the “Task file” pattern (variously called run.sh, “go” script, etc.)

    I just added this Github blog post to my list of related examples:

    Four More Posts in “Shell: The Good Parts” (It would have been nice to expand this into a nice blog post, maybe someday)

    Here is a real example: https://github.com/github/linguist/tree/master/script

    Notice that some scripts are Ruby; some are shell. That is how you’re supposed to use shell! It’s a polyglot system.

    “Task file” is perhaps slightly inaccurate since it’s a script directory in this case, not a file. But it serves the same purpose.

    Related to this comment: https://lobste.rs/s/iofste/please_stop_writing_shell_scripts#c_asvpef

    1. 4

      Notice that some scripts are Ruby; some are shell. That is how you’re supposed to use shell! It’s a polyglot system.

      I just want to reinforce your statement via a quotation from Eric Raymond’s “The Art of UNIX Programming”, section “Applying the Unix Philosophy”:

      • Mixing languages is better than writing everything in one, if and only if using only that one is likely to overcomplicate the program.
  11. 3

    @adi_onl, I really appreciate the simplicity of the scripts, as well as the way you distributed it: a simple page, a simple tar.gz, and able to navigate all the raw source code from the project page.

    Given that ability to easily see the source code, there goes a piece of unsolicited advice: your install target in the Makefile could be simplified using the install(1), which is available in all OS derived from 4.2BSD.

    That is a trick I learned from the Makefile of pert, which is elegantly simple.

    1. 3

      I chose cp(1), mkdir(1) and chmod(1) for shorter commands purposes vs install(1), purely a matter of preference.

  12. 5

    writing markdown is faster than applying styling by using the mouse

    Strawman detected.

    1. 3

      I’ve never known anyone who uses hotkeys for styling in Word. I’ve tried to learn them and they’re too inconsistent. None of these programs are designed with hotkeys in mind.

      1. 9

        Cmd-I for italics or Cmd-B for bold should work in every program dealing with text. Please don’t tell me they don’t work in Word (which I’ve rarely used).

        1. 3

          That is true if, and only if, your Office is in English.

          In Portuguese, I am sure Ctrl+N is the keystroke for making it bold (negrito in Portuguese).

          Therefore, @theblacklounge has a point: the keystrokes aren’t consistent in Word, and not consistent among same version in different idioms.

          1. 2

            In Portuguese, I am sure Ctrl+N is the keystroke for making it bold (negrito in Portuguese).

            I would be surprised as it would surely conflict with the new document shortcut.

            1. 2

              You would think that, but that is solved in a very elegant manner! I can’t speak for Portuguese, but in Norwegian ctrl + F is not search, it is bold because of the Norwegian word for bold is “fet”. So how do you search? Ctrl + B of course. That key isn’t used for anything.

              It wouldn’t surprise me that Ctrl + F is new file in Portuguese Office…

          2. 2

            I think you’re abusing the phrase “if and only if”. Pretty sure last time I used Office in Hebrew, the keyboard shortcuts were all the same.

          3. 2

            That’s not an iff with two f’s — I have never used Office in English.

            You are correct that Ctrl+N makes bold text in Microsoft Office on Windows in Portuguese, but that is obviously something you managed to learn, with a simple mnemonic. Compared to learning vim, it seems fairly manageable.

          4. 1

            That is true if, and only if, your Office is in English.

            Yes. I need to use Word at work. In German Word, it’s CTLR+F for making text bold (as the German word for “bold“ is “fett”). Since for office documents sent to me I use LibreOffice at home (which does use the familiar CTRL+B regardless of locale) I am eternally suffering by Word’s special way to handle this.

        2. 2

          You’re not supposed to just bold text, so that’s a pittance. They’ve put so much work in the semantic styles but only the first 3 styles have their own hotkeys, and my European keyboard breaks one of them.

          1. 3

            I mean… Isn’t there a similar gap in semantic styling in Markdown itself?

            1. 2

              If your output is HTML+CSS, you can manually add styling information to Markdown.

              To me, the ability to seamlessly “escape” into HTML is a big draw of Markdown. I despise its table syntax so I generally just use HTML tables in the rare cases I need them.

              1. 2

                The HTML “escape” makes Markdown internally inconsistent (as if it wasn’t already due to lack of standardisation) and one of the most complex formats invented, right next to MS Word.

                1. 2

                  There are 2 kinds of programming languages text markups: the ones everyone complains about, and the ones no-one uses.

                  1. 1

                    Very well. But in case anyone’s curious, here’s the text-markup-no-one-uses that I’ve got my eyes on: DocBook.

                    (Content warning: good stuff, but also written by Eric Raymond, whom you may find disagreeable. Shoot the proverbial messenger, though, not the message.)

                    1. 1

                      DocBook looks like XML to me. If I were to accept XML, I’d rather use a tool to generate conformant XHTML and use CSS to get different outputs.

                      The point of MD (and similar, like reStructured Text, Textile, Asciidoc etc) is to avoid the tagsoup of {SG,H,X}ML when actually writing content.

                      I actually think (La)TeX is the sweetspot here. It has markup, sure, but it’s much less intrusive when writing than tag-based markup. I.e. you write \emph{text} instead of <em>text</em>.

                      According to Wikipedia, DocBook is still being supported by the OASIS group.

                      1. 3

                        The point of MD (and similar, like reStructured Text, Textile, Asciidoc etc) is to avoid the tagsoup of {SG,H,X}ML when actually writing content.

                        Asciidoc is semantically equivalent to DocBook. It is a plaintext representation of DocBook without the tag soup. With Asciidoc driving a DocBook toolchain, you can have all of the output formats supported by DocBook for free. As someone who prefers reading documentation in info mode under emacs, I really appreciate that.

                        I’ve advocated for it in a situation where markdown wasn’t capable enough, and I’d do so again.

                      2. 1

                        LaTeX is a nice nesting markup syntax, for sure. However, at its core, it’s still an imperative language—with pervasive use of global variables, to boot.

              2. 1

                True, but I’ve always had an issue with the fact that Markdown embeds HTML in a way that doesn’t nest. Once you’re inside a single HTML element, no more nice link and emphasis syntax for you. On top of that, this can also date an individual document to the trends in play when it was written, making it a poor document format in the long term.

                This connection also limits Markdown to a format that must be converted to HTML before anything else. But I guess that matches its most common use case, even if it also makes it significantly less than ideal for a document authoring format.

            2. 1

              Making a title is easier than bolding in md. You can’t fake a title with just style cause you can’t set font size etc.

          2. 1

            I just fired up Word (365, Windows 10).

            I could select a word, navigate to the “subtle emphasis” section, and apply it, all using the keyboard. When you hit ‘Alt’, a bunch of letter appear in the ribbon that allows you to access the different parts of the ribbon and select them.

            Is it as easy as “Cmd-I”? No, but it’s more discoverable than Emacs…

            1. 1

              That’s not a hotkey, it’ll never be faster than using the mouse.

          3. 1

            Why are you not supposed to bold text? Not everyone writes for the semantic web.

            1. 1

              Word came up with semantic styles way before the semantic web was established. It’s just a very good invention. Bolding a word to highlight it is fine, but way too often people use it for titles, and then it’s not just bolding but bigger size and different font too. This is not uncommon in offices. Decades of human labor have been lost to “oh I want all h2 headers one size smaller”, and mistakes are easy so it ends up ugly.

              1. 1

                Semantic headings are also important for accessibility. Using screen reader commands to jump to elements matching particular criteria, such as headings or even headings at a specific level, is the closest that a blind person can get to skimming.

                1. 1

                  This is defeatist thinking about screen reader technology.

                  A sighted person does not have semantic headings to help them skim. They just have text size and weight.

                  Today, we have to provide screen readers with semantic hinting in order to enable skimming (and this helps the content creator, as well, through styling etc, so I’m not really arguing against it). But there’s no reason a BETTER screenreader can’t deduce these semantics from rendered font sizes.

                  You can’t hope to fix a problem by expecting a billion content creators to do the right thing. We have to fix it by enabling tools to do the right thing with the wrong input.

                  1. 2

                    I get your point. In fact, my company provides a tool that tries to automatically make documents more accessible, using the best available heuristics for things like headings and tables, as well as OCR. For the many existing documents out there, especially PDF documents, this is the best we can do. And of course, there will continue to be new inaccessible documents as well. But heuristics are fundamentally unreliable, so we should encourage document authors to directly convey document structure, and make it as easy as possible for them to do so. We should take both approaches at once.

                    1. 1

                      Agreed.

      2. 6

        Reading this comment on a site where people regularly debate vi vs emacs made my day.

        1. 1

          I haven’t seen this for ages, and it’s the biggest tragedy of the impending vscode monoculture.

      3. 4

        It’s common for word processors and transcriptionists to use keyboard shortcuts.

    1. 14

      That is an unfair, and low effort, point: do the same search for JSON, and the list is way bigger.

      Even the darling of the moment, Rust, has a list bigger than ASN.1.

      But it is worth to remind that ASN.1 is from 1984, while JSON is from around 2000, and Rust is 2010. And… That is a full text search, which doesn’t imply the problem is with ASN.1 (or JSON, or Rust), but that the keyword shows up in any text of the CVE, which my include the description of the product affected.

      1. 5

        In summary:

        • ASN.1, mentioned in 131 CVEs
        • JSON, mentioned in 686 CVEs
        • Rust, mentioned in 318 CVEs

        As you noted, it’s good to click through and read the details, certainly before going off the beaten grammar and encodings road.

  13. 1

    For those interested in Unicode, I would recommend to take a look at the work @FRIGN has been doing for years on suckless regarding Unicode. Search for Unicode in his personal website to see two talks of him on the subject (which were the best talks on the subject I’ve seen so far!), as well as his libgraphene.

    In the first talk, he goes a little more technical than the article on why UTF-8 (comparing to UTF-16 and UTF-32), as well as the reason the reasons to compare strings in the canonical form, and (if I remember correctly, in the second talk) addressing string length problems on composed characters.

    1. 2

      Thank you for the compliments! I’m glad you liked my talks on the topic and recommend libgrapheme.

      I had the chance to continue work on libgrapheme this week (not committed yet), working out the long-overdue API stabilization. Even though Unicode remains to be relatively complicated, I’m glad to now know that the “relevant” algorithms from the specification are possible to implement within a simple C-API, which is the goal after all. :)