Threads for ianloic

  1. 1

    It’s nice to see more safety in the Linux kernel but I worry about Linux following the BSDs in dropping support for older platforms that don’t have the corporate backing for a high quality LLVM port.

    1. 6

      Writing an LLVM back end is usually a lot easier than writing a GCC back end, so if a platform has enough community support to maintain a GCC back end then it should be able to handle maintaining an LLVM one. We’re seeing that at the moment with m68k, where the hobbyist community is able to fund development of an LLVM m68k back end that’s en route to upstreaming. If an community for a niche architecture can’t generate enough interest to contribute an LLVM back end (or maintain one out of tree) then it’s unlikely to be tested well enough by the rest of the stack for things to work reliably.

      1. 5

        To be fair there are quite a few architectures that have better support on NetBSD and/or OpenBSD than especially unpatched Linux.

        Many years ago I was fooling around with some of them. Parisc for example. Debian simply didn’t work, some others also didn’t despite claiming to support it, Gentoo managed to run.. somewhat. OpenBSD worked.

        Similar situation on super exotic systems like Dreamcast which only every booted NetBSD.

        While Linux in theory supports various old systems in reality third party patches on outdated kernel versions are needed and then you only have a kennel. Userland tends to be even worse.

        In Linux land you notice a lot more whether a developer recently came across it.

        FreeBSD dropping support for architectures seems to mostly be about making that state official and while I would assume that Linux itself has better support for things like Sun’s architectures or Itaniums still I really wonder how much that goes above a theoretical level when “nobody” actually does so and maintain it.

        With such architectures you are really dependent on the mood and time of individual people.

        NetBSD for a while had big pride in portability so people actually made sure stuff works. I mean they do similar things with pkgsrc which are or were the official package manager for Minix, some Open Solaris/Illumos distros, Linux distros, DragonFly and worked on many other systems.

        So llvm, clang and Rust are certainly not where gcc is, but I’d argue that this is changing both in the theoretical and practical.

        But I agree the initial commercial banking is something that llvm misses on older platforms. But I also think that Rust in the kennel would suddenly completely replace C with no alternatives available.

        1. 1

          This has been a long-running problem with GCC, too.

        1. 2

          This article doesn’t speak about cache invalidation at all - and isn’t that the hard part?

          1. 2

            Cache invalidation is hard in any language; the things that make it hard aren’t Rust-specific. This article is about how the design of Rust makes writing caches more difficult than one may expect.

          1. 0

            Can we avoid posting this author’s blog posts? Without going into details, his presence in C++ community spaces has caused problems.

            1. 7

              I think you would need to go into details or at least provide some links. Otherwise we will be banning posts left and right just because someone found the author problematic, don’t you think?

              1. 2

                I’m guessing this is in relation to his criminal history. I understand the reason of why not wanting to discuss details and in this case I do understand your concerns. Could we avoid posting this author’s comments?

                1. -2

                  Can we avoid posting this author’s blog posts? Without going into details, his presence in C++ community spaces has caused problems.

                  Can we avoid posting this author’s comments? Without going into details, his presence in C++ community spaces has caused problems.

                1. 1

                  I’m glad to see a coordinated effort to maintain this project with a conventional license and more healthy governance.

                  1. 1

                    For those of us who haven’t been following closely: what’s the problem that this is solving?

                    1. 3

                      The primary maintainer decided to really start treating the simh/simh GitHub repository as their personal branch, and changed the license from MIT to a pretty strange personal variant that would prevent people from using future changes of theirs if they believed applying a patch to reverse a contentious change was a good idea.

                  1. 2

                    Another problem no one’s mentioned yet is performance. At work we use formatters on large generated files, and we’re having a lot of trouble with clang-format (https://fxbug.dev/78303). On my MacBook Pro, it can format 1 MB/s but the max RSS also scales linearly at 150x file size. So formatting a 1 MB file takes 150 MB of memory. The clang++ parser deals with these files without that memory blowup. My teammate @ianloic is trying to optimize some of clang-format’s data structures.

                    (Why format generated code? Because people can jump-to-definition and read it. Why generate huge files? We’re also working on splitting or shrinking, but these sizes aren’t unusual compared to e.g. protobuf, thrift.)

                    1. 3

                      Rustfmt isn’t good on generated code either. The performance is in the same ballpark as what you quoted for clang-format: 2.8 MB/s. For formatting generated code I made https://github.com/dtolnay/prettyplease based on a simpler algorithm, which does 60 MB/s and fixes other shortcomings of rustfmt that tend to occur in generated code.

                      The same approach may be adaptable to C++, but I admit I’m not sure how it would accommodate preprocessor macros. Rust’s macros are much easier to format in comparison because the syntactic positions that they can be invoked in are strictly limited.

                      1. 2

                        I hope to have some simple patches that can land easily and some others that might take a little more convincing. The peak memory reduction is only about 20% though, IIRC.

                      1. 8

                        I just kind of love that Zoom uses XMPP, which I had no idea about. Big fan of XMPP as an unsung hero of the messaging realm.

                        1. 5

                          Without federation it’s as heartwarming as knowing that Apple’s App Store interface is a WebView.

                          1. 1

                            Did they switch to HTML? People always claimed that the itunes store was HTML but it was a custom format with a custom renderer.

                          2. 3

                            Facebook Messenger also uses it internally, or at least it did at some point. Now if only all the XMPP users actually federated…

                            1. 1

                              It did, but it’s all MQTT these days

                          1. 1

                            I wonder what % of nvidia gear is used on Linux these days. Between eth mining, machine learning and non-switch Tegra devices it must be a fair amount.

                            1. 1

                              “data center” and “gaming” revenues are about the same and they’re no explicit call-out for cryptocurrency mining, so I assume that’s largely from the “gaming” bucket.

                              https://nvidianews.nvidia.com/news/nvidia-announces-financial-results-for-fourth-quarter-and-fiscal-2022

                              1. 4

                                Recently we learned that this is not a great summary. NVIDIA has been sued by investors for knowingly benefiting from sales to the miners, but lumping them into the “gaming” category in their financial reports.

                            1. 9

                              For my web app, I looked into replacing a JS-based blurhash implementation with a Rust-based one. I benchmarked it, and found that the JS one was just as fast after the 3rd iteration (presumably because of the JIT kicking in).

                              As said elsewhere, WASM is not magic performance pixie dust. It makes sense in certain cases, but benchmark before jumping to conclusions.

                              1. 5

                                I have been playing with WASM and Rust for a few things. The motivation hasn’t been speed though It has been the ability to use a far superior typesystem. After all both wasm and javascript are interpreted. The primary benefit is being free to use something other than only javascript for browser based frontend development.

                                1. 3

                                  TypeScript also has a pretty nice type system. I was surprised at how comfortable it felt, coming from a C++ (and some Swift) background. The flow-based typing is especially handy.

                                  1. 4

                                    When compared to Javascript, Typescript’s type system is a massive leap forward. I wholeheartedly endorse it’s usage by anyone.

                                    However, compared to Rust, Typescript doesn’t come anywhere near giving me the same guarantees. Rust/WASM let’s me get an even more expressive type-system to model my software’s contracts with. It won’t always be the best choice but all else being equal a Rust type system beats TypeScript any day.

                                    1. 6

                                      I prefer TypeScript’s types to Rust’s a lot of the time, but it often depends on the domain I’m in. For lower level things around managing resources Rust’s shines but for higher level modelling of app data I prefer TypeScript’s. What’s universal is that when I’m using one, at some point I miss a feature of the other :-)

                                      1. 2

                                        There’s also PureScript and Elm, as well as some other very young options for browser languages that have nice type systems.

                                1. 6

                                  “Mcrib” is the best code name I’ve heard in a while.

                                  In a way it’s comforting that Slack, with these brilliant engineers, has these issues too. I mean, I know everyone does, but when a product I designed or worked on has an issue, I always beat myself up about it. Realizing I can make mistakes too and not be an imposter is a lesson I still haven’t fully learned after all these years.

                                  1. 21

                                    Its appropriate for a service called “mcrib” to be only intermittently available…

                                    1. 2

                                      Bravo.

                                      1. 2

                                        This is the greatest comment I have ever seen here.

                                      2. 3

                                        EVERYONE does!

                                        Let me tell you about some internal only post mortems (We call them COEs - Correction Of Error) that made my hair stand up :)

                                        And I guarantee you that every other BigCorp in existence has them too. Solving problems at crazy pants scale means that sometimes despite everyone’s best efforts you end up with disasters at said scale :)

                                        1. 2

                                          In a way it’s comforting that Slack, with these brilliant engineers, has these issues too.

                                          Haha! Not just Slack … literally every place I’ve worked at has had something like this.

                                        1. 4

                                          But many people want more… flexibility. Open source developers, for example, often want to distribute cross-platform applications with minimal effort. There are entire programming language ecosystems where the operating system you are running on is abstracted away as an implementation detail for many applications. By creating a de facto requirement that macOS, iOS, etc development require the direct access to macOS and (often above market priced) Apple hardware, the distribution requirements imposed by Apple’s software ecosystems are effectively exclusionary and prevent interested parties from contributing to the ecosystem.

                                          Mildly hot take: It’s not hard to have access to a Mac. And if you don’t have access to a Mac, I wouldn’t be confident that the binaries you made would even work. I myself try to avoid cross-compiling with the issues I’ve had with i.e. MinGW on Linux.

                                          1. 14

                                            Counterpoint: I build Windows binaries for my Go software but depend on users to report any platform issues as I don’t use Windows. 🤷🏻‍♂️

                                            1. 3

                                              I wouldn’t feel comfortable shipping binaries for a platform I didn’t use. Imagine trying to figure out Windows issues without a knowledge of Windows.

                                              1. 1

                                                Yeah, I’ve been there. It can be tricky, but fortunately Go and Rust abstract away a few common pitfalls. If your project is open-source, someone else may help.

                                            2. 3

                                              Having open tooling can be extremely useful even if you do have access to Macs. Apple binds toolchain and OS compatibility pretty tightly these days - a given version of Xcode typically runs on the current major macOS version; if it’s Xcode ?.0 ~ ?.2, it’ll typically also run on the previous version (?.3+ will typically not), and usually it’ll work for about one more future major OS version. Individual tools might run outside that range, but it’s certainly all unsupported. If you need to use different toolchain versions for whatever reason, this can get quite annoying. Especially with the x86-64 -> ARM64 transition, “just spin up a VM with an older OS” is no longer a simple go-to solution. (I’m not aware of any emulators which run x86-64 macOS guests with usable speed on M1 based Macs.)

                                              1. 2

                                                Do you cross compile software for iOS? Most people do, but they’re stuck doing that on a single vendor’s OS that’s locked to specific hardware and virtualization constraints.

                                              1. 20

                                                Too bad this is not the default in Firefox. It should have been, since AMP was first introduced. I will never use Brave because of their BAT cryptocurrency scam.

                                                1. 6

                                                  Any resources/info on it being a scam (other than “it’s crypto”, ideally)? I was under the impression that it was a helpful idea, but maybe I’m missing something.

                                                  1. 4

                                                    My understanding is that they crawled social media to find photos of the owners of websites in order to make it look like the website owners were part of their website donation project. If people then subsequently donated in the belief that the money would go to the people Brave claimed it would go to, but the site owners weren’t participating in the project, the money would be held in some escrow account for some time until Brave took the money themselves.

                                                    They’ve also been really shady in increasingly making their browser pretend it’s just Chrome, making it impossible to block or inform visitors about the scam.

                                                    Here’s pushcx’s comment about it when it affected lobste.rs: https://github.com/lobsters/lobsters-ansible/issues/45

                                                    EDIT: And here’s Tom Scott’s twitter thread about it: https://web.archive.org/web/20181224160027/https://twitter.com/tomscott/status/1076160882873380870

                                                    1. 2

                                                      Hm. I’d heard of those things. I guess I agree that’s not a great impression. I can understand why they would make such a mistake in good faith. Then again, when you’re trying to “fix the web” you can’t steamroll the very content creators you’re trying to help. And even if it was the result of ignorance as they suggest, it certainly calls into question their diligence in less visible parts of their operation. Maybe they need to do more to assure potential users of their ecosystem that such oversights won’t happen again.

                                                      In any case, I can understand better now why someone would hew towards Firefox rather than Brave. What a shame… Anyways, thanks for your reply!

                                                  2. 2

                                                    They’re also run by a bigot. Stay away.

                                                    1. 3

                                                      don’t you work for google? might be worth mentioning if you’re commenting on an article about how a competing browser is sidestepping one of google’s more evil recent projects

                                                      1. 4

                                                        I’m not speaking as a Google employee and I don’t work on Chrome. It’s a big company. I did work on other browsers for a long time in the Mozilla ecosystem, including working with LGBT ex-Mozillans when we looked around the Prop-8 donations to see if anyone we knew had made donations and saw Eich’s significant donations to deprive equal human rights to people he knows and worked with. My feelings about this have nothing to do with who I happen to work for at one time or other. I’m a huge fan of a broad ecosystem of browsers offering a variety of takes on the web - I spent half my career working on that vision - but don’t get your supposedly privacy focused browser from someone with a history of attacking the human rights of vulnerable people.

                                                        1. 3

                                                          If Brave’s technology is sound, it could always be forked. Similar to how people run de-Googled forks of Chrom(e|ium) to opt out of Google’s spying.

                                                  1. 36

                                                    The core problem is the only entities currently paying for web browser development have mixed motives. The EU should just buy out Mozilla and make Firefox into the browser for the people instead of waiting around for Google to stop breaking their laws.

                                                    1. 9

                                                      What’s to buy? It’s open source. They can contribute to it or fork it if Mozilla Corp doesn’t like their changes.

                                                      1. 21

                                                        The Mozilla organization, including the expertise necessary to develop and maintain Firefox. It would probably cost more to build an independent organization capable of doing the same thing.

                                                        1. 3

                                                          Which Mozilla organization? The non-profit Mozilla Foundation or the for-profit Mozilla Corporation?

                                                          1. 7

                                                            I’m not sure, what do you think?

                                                            1. 5

                                                              The Mozilla Corporation is owned in its entirety by the Mozilla Foundation. Even if somehow the Foundation were convinced to sell the Corporation, the Foundation is the one that owns the key intellectual property and is the actual steward of the things people think of as “Mozilla”. The Corporation’s purpose is to be an entity that pays taxes and thus can have types of revenue and business deals that are forbidden to a non-profit.

                                                              1. 1

                                                                The employees who work on Firefox and everything that encompasses work for the Corporation. It has more of a purpose than “taxes”.

                                                                1. 3

                                                                  I am a former employee of the Mozilla Corporation, so I am aware of what the MoCo employees do.

                                                                  1. 1

                                                                    MoCo gets all of the revenue that’s generated by Firefox and employs most of the developers. All but one of the members of the Firefox Technical Leadership team work for Mozilla Corp - the one that doesn’t did until relatively recently: https://wiki.mozilla.org/Modules/Firefox_Technical_Leadership

                                                                    While the Foundation technically owns the IP the Corporation controls the direction of the product and collects all of the revenue generated by the work of both their employees and contributions from the community.

                                                          2. 9

                                                            Declare Firefox a public infrastructure and fund Mozilla or another entity to upkeep and enhance that infrastructure.

                                                          3. 11

                                                            No thanks, I’ve had enough cookie popups for one day.

                                                            1. 55

                                                              The GDPR is specific about cookie banners not being obtrusive, and that rejecting tracking is as easy as accepting.

                                                              The only compliant banner I regularly see is from gov.uk, and I find it doesn’t annoy me at all.

                                                              The popups are as obnoxious as possible to make us hate the GDPR. Can’t we oppose the tracking instead of the law telling us when it’s happening?

                                                              1. 8

                                                                And of course the core thing is you don’t need the cookie popups if you’re not doing random tracking of people!

                                                                Every cookie popup is an announcement that the site has some automated trackers set up. If you are just using cookies for things like handling sessions you do not need the cookies.

                                                                1. 8

                                                                  Absolutely. The options are either make your tracking opt-in through genuinely informed consent, or don’t track at all.

                                                                  Companies found the secret third option, which is just ignore the law and dark pattern your users into agreeing to anything.

                                                                  Banners say things like “we need cookies for this site to work” and pretend they need your permission to use them. Ironically they only need permission for the cookies that aren’t essential to make the site work.

                                                                  Hiding things away under “legitimate interest” makes things even more confusing. Are the other things illegitimate interests?

                                                                  1. 2

                                                                    Can someone explain to me what “legitimate interest” actually means?

                                                                  2. 2

                                                                    …you do not need the cookies.

                                                                    Do you mean the cookies or the popups? I’m not familiar with how the GDPR treats non-cookie based things like JWT in local storage and sent with every request.

                                                                    1. 2

                                                                      The same. You require consent to store any data on user computer. However it do not require some “essential” cookies - for example cookie with preferences for dark/light theme do not require consent if it is direct action on website, cookie containing session ID do not require consent, etc. That applies for local cookies only though.

                                                                2. 11

                                                                  Same. I really wish companies would stop choosing to add them to their websites.

                                                                  1. 4

                                                                    If you already block tracking by any mean, you can get rid of those banners using something like https://addons.mozilla.org/en-GB/firefox/addon/i-dont-care-about-cookies/.

                                                                    1. 3

                                                                      Yeah, the EU’s heart was in the right place, but implementation has been a disaster. It’s like passing a law that murder is okay as long you say “I am going to murder you” as you take out the knife.

                                                                      1. 27

                                                                        What the EU did was basically passing a law that makes murder illegal. Companies/Murderers just ignore it and go around saying “anyone that doesn’t want to be murdered please answer by saying your name within of the next millisecond. Guess no one answered, so you’ve just consented to murder!”

                                                                        GDPR explicitly bans all the annoying dark patterns of cookie banners. A GDPR-compliant cookie banner would ask you once whether you consent to tracking. It’d have one huge no button (but no easily accessible yes button). If you ever click no, it’d have to remember as long as possible and close itself immediately. If you click yes, you’d have to go through a handful of options to specifically choose which tracking methods to allow.

                                                                        1. 10

                                                                          So, basically the polar opposite of many cookie popups today, which have a big “I ACCEPT” button and a “More options” button that you have to click to manually turn off all tracking…

                                                                        2. 3

                                                                          Except large Internet companies are much more powerful and accountable to public pressure than murderers, so they should face at least as much public scorn as the lawmakers.

                                                                          1. 2

                                                                            There’s a saying, that road to hell is paved with good intentions.

                                                                            That often means that if someone’s is not sure how to help, then proceeding with helping can create more problems than resolve anything.

                                                                            1. 2

                                                                              That’s better than having no law against murder. Then we can move away from all the people saying “I am going to murder you.”

                                                                            2. 2

                                                                              Umm… we’ve just today decided to instruct Matomo not to use cookies rather then implement cookie banner for our new Wagtail-based websites. I think it’s working?

                                                                              1. 1

                                                                                Cookie popups on websites linked to by Google?

                                                                            1. 26

                                                                              When I saw this elsewhere, it was revealed (or at least discussed) that this was not actually created by Scott McCloud, though there is (IMO) a high risk of it being misconstrued that way. The PDF version has the name “Leah Elliot” on it, who is presumably the real author of this work.

                                                                              1. 18

                                                                                Yeah, it’s definitely confusingly presented. I appreciate the way the original Scott McCloud comic has been remixed is clever, but it wasn’t obvious for a few pages that this wasn’t a new comic from McCloud and Google.

                                                                                1. 30

                                                                                  I was totally misled. I thought he had come back around and revisited his earlier work with regret.

                                                                                  1. 4

                                                                                    Same.

                                                                                    1. 2

                                                                                      Same. A very well-done remix…

                                                                                1. 3

                                                                                  This is pretty great. I’ve been playing around with toolbox a bit but this is a other approach that looks exciting.

                                                                                  1. 4

                                                                                    6th generation Thinkpad X1, cannot think of a better machine at this point in time (only wish it would be more repairable) - X220 for recreation

                                                                                    1. 2

                                                                                      I use a 5th gen X1 Carbon and keep failing to find a good reason to update it.

                                                                                    1. 10

                                                                                      How many connections to google it does while compiling/booting?

                                                                                      1. 11

                                                                                        It’s a shame Google can’t run open-source projects. Fuchsia looks like one of the more interesting operating systems but as long as Google has complete control over what goes in and no open governance it’s not something I’d be interested in contributing to.

                                                                                        1. 11

                                                                                          To be fair to Google - they’re doing work in the open that other companies would do privately. While they say they welcome contributions they’re not (AFAIK) pretending that the governance is anything it’s not. On their governance page, “Google steers the direction of Fuchsia and makes platform decisions related to Fuchsia” – honest if not the Platonic ideal of FOSS governance.

                                                                                          To put it another way - they’re not aiming for something like the Linux kernel. They know how to run that kind of project, I’m sure, but the trade-off would be to (potentially) sacrifice their product roadmap for a more egalitarian governance.

                                                                                          Given that they seem to have some product goals in mind, it’s not surprising or wrong for them to take the approach they’re taking so long as they’re honest about that. At a later date they may decide the goals for the project require a more inclusive model.

                                                                                          If the road to Hell is paved with good intentions, the road to disappointment is likely paved with the expectation that single-vendor initiatives like this will be structured altruistically.

                                                                                          1. 6

                                                                                            The governance model is pretty similar to Rust’s in terms of transparency: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs

                                                                                            Imperfect in that curreny almost all development is done by Google employees, but that’s a known bug. But (to evolve the animal metaphors) there’s a chicken and egg issue here. Without significant external contributions it’s hard for external contributors to have a significant impact on major technical decisions.

                                                                                            This same issue exists for other OSes like Debian, FreeBSD, etc - it’s the major contributors that have the biggest decision making impact. Fuchsia has the disadvantage that it’s been bootstrapped by a company so most of the contributors, initially, work for a single company.

                                                                                            I’m optimistic that over time the diversity of contributors will improve to match that of other projects.

                                                                                            1. 4

                                                                                              A real shame indeed. Its design decisions seem very interesting.

                                                                                              1. 1

                                                                                                yeah I’d bet the moment they have what they wanted it’ll be closed down, because this is ultimately the everything-owned without GPL -OS for google

                                                                                              2. 7

                                                                                                Probably zero. Or if you’re using 8.8.8.8 for your DNS probably less than Windows or macOS.

                                                                                                1. 5

                                                                                                  They all start like this, but at the end it will be another chrome.

                                                                                                  1. 5

                                                                                                    Co-developed with companies as diverse as Opera, Brave, Microsoft and Igalia, as well as many independent individuals? As a Fuchsia developer that’s a future I aspire to.

                                                                                                    1. 13

                                                                                                      Chrome, which refused to accept FreeBSD patches with a community willing to support them because of the maintenance burden relative to market share, yet, accepted Fuchsia patches passing the same maintenance burden on to the rest of the contributors, in spite of an even smaller market share? If I were an antitrust regulator looking at Google, their management of the Chromium project is one of the first places that I’d look. Good luck building an Android competitor if you’re not Google: you need Google to accept your patches upstream to be able to support the dominant web browser. Not, in my mind, a great example of Google running an inclusive open source project.

                                                                                                      1. 6

                                                                                                        It’s not just about whose labor goes into the project, but about who decides the project’s roadmap. That said, maybe it’s about time to get the capability-security community interested in forking Fuchsia for our own needs.

                                                                                                        1. 3

                                                                                                          You should be more worried about the “goma is required to build Chrome in under 5 hours” future, in my opinion.

                                                                                                          1. 0

                                                                                                            Keep aspiring on google salary. It would be good to disclose conflict of interest btw.

                                                                                                            1. 11

                                                                                                              I mentioned that I’m a Fuchsia developer. I’m not sure what my conflict of interest here is. I’m interested in promoting user freedom by working on open source software across the stack and have managed to find people to pay me to do that some of the time, though generally less than I would have made had I focused on monetary reward rather than the impact of my work.

                                                                                                      2. 5

                                                                                                        The website doesn’t have working CSS without allowing gstatic.com, so I’d guess at least one?

                                                                                                        1. 1

                                                                                                          /me clutches pearls

                                                                                                      1. 20

                                                                                                        The logic in this article appears to be: gethostbyname is a blocking call; therefore all serious applications should use a dedicated DNS library; therefore gethostbyname is unreliable. These points do not automatically follow, and no point is raised indicating why a blocking call must be intrinsically less reliable than a nonblocking one. The existence of the article implies glibc must have a more reliable implementation, suggesting that the function signature isn’t the problem.

                                                                                                        1. 17

                                                                                                          That isn’t exactly what I got out of it.

                                                                                                          That all serious applications don’t use gethostbyname() because gethostbyname() is unreliable, is assumed. Exactly why the author assumes this isn’t given, but I assume it too, so I didn’t have a problem with this, and I’m happy to speak to them. My reasons are simple:

                                                                                                          1. gethostbyname() cannot return multiple address types, and,
                                                                                                          2. gethostbyname() cannot be trusted to return more than one address (this is what the author is referring to by talking about Alpine and ancient BSD)

                                                                                                          “Serious applications” do complicated stuff to make for a good user-experience, and there’s no way to do that with gethostbyname(). I think this may have been the author alluding to the address types issue, but (more to the point) I can believe if you don’t know about this (or how to do this) that you might think gethostbyname() is fine – it isn’t, and to that end yes the function signature is absolutely the problem. It’s not as bad as gets() but everyone on the Internet really should be using getaddrinfo() instead.

                                                                                                          Something else I think is important requires backing up for a minute. I think what kubernetes/coredns does is stupid too: It knows all the services and already knows how to update files dynamically, so it can in some systems substantially reduce delays and network traffic by just making hosts files; e.g.

                                                                                                          (echo '127.0.0.1 localhost.localdomain localhost';
                                                                                                          kubectl get svc -A -ogo-template --template="{{range .items}}{{.spec.clusterIP}} {{.metadata.name}}.{{.metadata.namespace}}.svc.cluster.local
                                                                                                          {{end}}") | kubectl create cm hosts --from-file=hosts=/dev/stdin
                                                                                                          

                                                                                                          that is to say, there’s no reason for this incompatibility to be a problem: Push is always better than polling. And think about all that code people could delete.

                                                                                                          But maybe this isn’t obvious (after all, someone thought they should be disabusing DNS).

                                                                                                          1. 2

                                                                                                            gethostbyname isn’t threadsafe. It’s defined to be not thread-safe in POSIX and documented as such in the Linux man pages.

                                                                                                            Eventually even macOS added the thread-safe GLIBCism gethostbyname_r.

                                                                                                            1. 5

                                                                                                              There’s no good reason for adding gethostbyname. getaddrinfo is defined to be thread safe, and if you’re modifying the source code then you should update to the API that doesn’t hard-code so many assumptions.

                                                                                                              1. 2

                                                                                                                gethostbyname_r’ predates getaddrinfo by 5 years. New code should be using getaddrinfo, but there’s a lot of code out there…

                                                                                                          1. 5

                                                                                                            tl;dr avoid musl?

                                                                                                            1. 3

                                                                                                              how did you come to that conclusion after reading the article?

                                                                                                              1. 7

                                                                                                                The article seems to take a myopic view of name resolution only considering DNS resolution even though the whole point of gethostbyname is to be a unified interface to host name resolution, regardless of the source of those names. In modern system names come from many places, just relying on DNS resolution isn’t going to work well.

                                                                                                            1. 20

                                                                                                              If you use a a custom library for DNS lookups, will it support multicast DNS, i.e. the .local domain? Will it obey your wishes to e.g. use different DNS servers in different network environments, or to only use DNSsec? Will applications using different custom DNS libraries share a cache to avoid redundant queries?

                                                                                                              DNS lookup seems to me to be a core shared system service (as it is on Apple platforms), not something you outsource to a smorgasbord of different libraries. And the fact that some ancient Unix API has awful semantics shouldn’t prevent the OS from offering a better API in that core service, relegating gethostbyname/getaddrinfo to legacy status.

                                                                                                              1. 6

                                                                                                                This. It really sucks that nobody tried to extend NSS with a well-designed async API.

                                                                                                                I guess what prevents this kind of thing is the lack of coordination. POSIX is mostly treated as “something that comes from above and we kinda should follow it”, there doesn’t seem to be an active W3C style participatory process for unix APIs :(

                                                                                                                1. 6

                                                                                                                  Yeah, I want name resolution, not DNS lookup and that’s what gethostbyname offers. Using NSS on Linux and netinfo (or whatever replaced it) on Mac users & administrators & distributors can establish how that should be done.

                                                                                                                1. 4

                                                                                                                  Some weeks I spend more time in Compiler Explorer than my local text editor…