Threads for mat

    1. 35

      Battleships can’t be berthed in backyards, but people build wonderful wigwams

      I don’t understand this metaphor at all. A wigwam is a house. Are they thinking wigwam is another word for canoe (which is itself an Arawakan word)?

      Wigwams rarely become battleships.

      No wigwam has ever become a battleship or even a boat.

      1. 8

        Author here! I wanted to illustrate that wigwams are both different in kind and degree from battleships

        Houses rarely become boats, but there’s no reason why they can’t in principle

        1. 7

          Indeed - the 100 Rabbits folks turned their boat into a house and have built software on the wigwam list. Perhaps this is the path to the conceptual through-line?

          1. 3

            Maybe I am nitpicking now, but didn’t they turn their boat into a home, and not a house?

            It’s still a boat, in the water.

            On the linked page, they compare it to a house, as something different:

            Living in a boat, your living space is restricted when compared to a house.

            1. 4

              These distinctions are indeed important. A house is a structure like a wigwam. And as they say, home is where the heart is.

              The metaphor would probably be more clear if it just referenced particular types of living and working spaces. For example, could Common Lisp be a Mies van der Rohe structure full of incredible modularity and audible leakiness built on top of a complex substrate of steel and glass?

              Please forgive me for my own 1/2 backed analogy.

        2. 2

          Perhaps a barge or a houseboat is a clearer analogy (folks I’ve known who live on houseboats definitely feel like the DIY type!) I get there are two dimensions here (size and kind) but the simplicity of just measuring it in one feels quicker to understand at first glance (without needing to dive into comments!)

          love the idea though, I may shoot you an email with some ideas!

      2. 2

        My best guess is they were going for a size and sturdiness analogy, rather than one based on seaworthiness or “boatishness.” Not to say I totally understand why they went that direction…

    2. 3

      mostly tangential: I feel like I have seen NATS mentioned in numerous blog posts and tutorials, but have yet to get an explanation for what it is or why I would use it… The documentation website hasn’t been much help, either.

      also, curious to see what sort of state tvix is in, how usable it might be, etc

      1. 2

        There was a talk on tvix status at NixCon 2023 in September

    3. 2

      Why are Shortcuts dated ending in 2021? Are they deprecated now?

      1. 2

        Probably because it’s when it appeared in macOS, after starting on iOS.

    4. 3

      I’m a bit confused why one of the examples suggest installing pipx or condax globally… wouldn’t you just install tools with pixi directly instead of pipx or condax?

      1. 3

        That’s the whole problem with pixi and all the equivalent projects. The people that need them the most are the ones that are the least likely to understand how to use them correctly.

        I’m pretty sure pixi will cause as many problems as it solves.

        I’m probably borderline spamming at this point, but better post a link again than explain the whole thing in a comment repeatedly: https://www.bitecode.dev/p/why-not-tell-people-to-simply-use

      2. 1

        He I work at prefix, where did you get the feeling that we suggest using pipx or condax because that is not our intention. pixi global install PACKAGE installs a package that will then be globally accessible, like how pipx and condax works.

        1. 1

          from the article:

          Other features that pixi provides out of the box are:

          • Globally install tools like pipx or condax (using pixi global install …).
          1. 4

            on a second reading, i can see this is saying “globally install tools in a manner similar to pipx or condax”, not “globally install tools such as pipx or condax”

            1. 3

              This needs to be rewritten to be less ambiguous.

    5. 5

      Any tips for reading (pages like) this on mobile (safari)? The font is super small, and it seems like it’s wrapped in pre tags or such, because both zooming in, or using the reader mode, forces horizontal scrolling.

      1. 4

        landscape mode is my low-tech suggestion

      2. 2

        I tried a few different things but they all preserved the <pre> tags. One thing that did work was copy and paste the text into the Notes app, which can be automated with a shortcut like this: https://www.icloud.com/shortcuts/ee41c5e74e454ee486568a191ca9b9d2

    6. 2

      I don’t understand why Unison can’t be built on top of Git. It uses content-addressable blobs instead of text files, but isn’t Git just content-accessible blobs that happen to be text files when we use it?

      1. 11

        @mat suggested their Slack, asked on their Slack, and as I joined, Paul Chiusano (I think the lead dev though he doesn’t really say) co-founder of the corp developing the language had this to say:

        Short answer is that a database like SQLite lets us build exactly the behavior we want, whereas git is more optimized for versioning bags of text files. So even though git is conceptually similar and is also versioning content addressed blobs, there are enough differences that building on git was deemed unworkable. Back in the day, Unison did use the file system and git. That didn’t work well. It’s possible that someone with detailed knowledge of git internals could wrangle it into working better as a backend for Unison, but it’s much more straightforward to just build atop a proper database.

        1. 4

          Such a lengthy and thoughtful response. Paul is a Cool Dude (I’ve also interacted with him and he’s a pleasure).

      2. 1

        I cant say for sure myself as I don’t have a deep enough understanding of the hashing/content addressing functions of Unison, but I do know from experience that the inventors and maintainers are very responsive on the Unison Slack. They would definitely be able and willing to discuss this.

    7. 7

      As I mentioned on another site, I have to give this language props for including support for the auspicious fucton keyword.

    8. 11

      That means Blink has an approachable codebase since we’ve only got 63,500 lines of ANSI C11 code

      While I get that this is impressive for what they do, 63k lines of C is in no way “approachable”

      1. 5

        I recently started hacking on a 75k line C codebase, and I was able to get up and running in a few hours. It’s definitely easier to get into than larger codebases, since you can read 5% of the codebase in a short time. You can e.g. read through entire files to get an idea of what functions are available, and be reasonably certain you’ve seen most of them.

      2. 4

        …especially when that code looks like

        double DeserializeLdbl(const u8 b[10]) {
          union DoublePun u;
          u.i = (u64)(MAX(-1023, MIN(1024, ((Read16(b + 8) & 0x7fff) - 0x3fff))) + 1023)
                    << 52 |
                ((Read64(b) & 0x7fffffffffffffff) + (1 << (11 - 1))) >> 11 |
                (u64)(b[9] >> 7) << 63;
          return u.f;
        }
        

        or

        static int xed_modrm_scanner(struct XedDecodedInst *x, int *disp_width,
                                     int *has_sib) {
          u8 b, rm, reg, mod, eamode, length, has_modrm;
          xed_set_has_modrm(x);
          has_modrm = x->op.has_modrm;
          if (has_modrm) {
            length = x->length;
            if (length < x->op.max_bytes) {
              b = x->bytes[length];
              x->length++;
              rm = b & 0007;
              reg = (b & 0070) >> 3;
              mod = (b & 0300) >> 6;
              x->op.rde &= ~1;
              x->op.rde |= mod << 22 | rm << 7 | reg;
              if (has_modrm != XED_ILD_HASMODRM_IGNORE_MOD) {
                eamode = kXed.eamode[Asz(x->op.rde)][Mode(x->op.rde)];
                *disp_width = xed_bytes2bits(kXed.has_disp_regular[eamode][mod][rm]);
                *has_sib = kXed.has_sib_table[eamode][mod][rm];
              }
              return XED_ERROR_NONE;
            } else {
              return xed_too_short(x);
            }
          } else {
            return XED_ERROR_NONE;
          }
        }
        
        1. 6

          The first function is pretty obvious to anyone that understands x86, it transforms an 80-bit long double into a double (which is probably not a good thing to do). The second bit looks like it is part of an x86 instruction parser for handling the ModR/M encodings, which is a common part of many x86 instruction encodings. The bit twiddling here looks like it is decoding the 2-byte ModR/M operand value.

          Context is important for these things. I would prefer code like this to contain some comments and references to the bit of the spec that they’re implementing, but for someone with a passing familiarity with x86 it’s not that hard to read. I would expect that most people that might want to usefully contribute would know enough about x86 to be able to follow that code.

          In a slightly higher-level language (C++, Rust, and so on), the bit twiddling would be replaced by helpers to extract specific bit ranges (and the methods would be attached to the class that they’re operating over), but the code probably wouldn’t be very different overall.

        2. 3

          some days I think “maybe I should go back to my college days and write some C,” but comments like this keep me on the holy path

        3. 2

          This is the kind of code that needs copious comments.

          1. 2

            It’s easy to cherry pick bad examples. Here’s a good one:

            Intel’s ALU instructions are the most important thing. You won’t find a more succinct elegant implementation of them.

      3. 3

        It’s probably relative. How many lines in Qemu?

        1. 8

          Qemu has 1,730,794 lines of code.

          1. 3

            That’s a slightly misleading comparison because a lot of that is driver emulators. Of the remainder, this also includes several different architectures. The x86 portion is quite small and TCG is pretty approachable (in spite of starting life as an obfuscated C competition entry).

    9. 13

      I don’t get it. Dataclasses are already compact. This seems like new syntax for the sake of adding new syntax.

      1. 6

        Dataclasses have a lot of issues, including requiring type annotations, too many features, poor performance, etc. People want to have basic data types that are easy to define and simple to use without all the overhead of OOP. Also, immutable types like this could enable better sharing between sub-interpreters for performance.

        1. 4

          I couldn’t really see the difference with a NamedTuple subclasses, which behave pretty much like structs, the only caveat being reserved attribute names like ‘index’.

          1. 4

            Namedtuple allows positional access, which is an error-prone interface that should be avoided. Namedtuples are really only there to help you migrate existing tuple code over to objects with attributes.

            1. 2

              With the “I haven’t done Python in a while” caveat, I wonder — why not make a new namedtuple-like that doesn’t allow indexing? The Author’s reference implementation could easily be the template here, no?

              1. 3

                Maybe the underlying question is “why can’t it just be a new collection class? why is built-in language support and a new struct keyword needed?” I think it’s this part:

                    def __new__(cls, x: int, y: int) -> Self:
                        """Create a new, immutable instance."""
                        # Pretend this makes everything immutable in the end.
                        self = mutable(cls.__slots__)
                        self.x = x
                        self.y = y
                        return immutable(self)
                

                There’s no immutable in userspace today as far as I understand it. Some values like frozenset and tuple are actually immutable, and there are proposals for others, but not for objects. You can simulate immutability like dataclasses already do but it’s not truly frozen. SimpleNamespace is fully mutable. So that’s part of the gap to fill.

                1. 1

                  So the right thing to do is to make it possible to have immutable class fields, not create a literally new structure/syntax in the language… maybe?

                  1. 1

                    All of the object and class machinery is very expensive, though. So the goal is to avoid that because of performance. Makes sense to me.

                    1. 4

                      If the goal is performance, aren’t you in the wrong language? At some point either the dynamic features of the language are worth having, or they need to be shed (yes, pun). But what I see happening (from a far) is that the language keeps growing and growing in language surface area instead of fixing/creating better baseline abstractions. We’re just minutes away from Python being the next “kitchen sink” language… it seems. Far from the language I loved using in the 00s and early 10s.

                      Oh well.

                      1. 1

                        I agree it no longer “fits in your head”.

                    2. 3

                      It seems like Mojo is sort of working in that same direction.

      2. 2

        This could be a package for structs, does not seem to be needed in the language definition itself. But its good to discuss it.

        1. 3

          But why is it good to discuss it? What does this offer that dataclasses don’t? Honest question here, because I’m not seeing it, but I could be missing something.

          1. 4

            One problem with @dataclass being an annotation is that it will either create a new class or modify an existing class based on slots=True, and creating a new class is an odd behavior as well. Syntax could unify this to a degree and simplify it too.

            Additionally, people won’t choose @dataclass as often. It’s one of those things that is less likely to be reached for because people prefer native features.

            That’s about it though. Personally, I don’t really think a native version is a big win tbh

      3. 1

        One of my biggest issues with dataclasses, specially working with people without a lot of python experience, is that it’s based on deep, dark, magic. The second someone asks “why do I have to put this @symbol over my class”, bam, you either have to say “Trust me, you just have to”, or you will spend the next 7 hours explaining how decorators work and what even are metaclasses.

        1. 3

          Decorators are just functions that take objects, modify or wrap them, and return a new object. Metaclasses need not apply for a basic understanding of decorators. Far cry from “black magic,” I’d say.

          edit: and upon inspection of the dataclasses source, I don’t think it actually relies on metaclasses at all.

          1. 1

            Point taken on metaclasses, although it’s worth mentioning that lots of other libraries that provide similar functionality to dataclasses use metaclasses, and so does other stuff on the stdlib, like enums.

            That said, decorators are only simple if you know them. Even the concept of functions as first class objects can be startling to newcomers. Would be nice if one could introduce simple data objects without having to go into that.

    10. 10

      I feel like “the syntax for specifying type parameters still feels “bolted on” to Python” is really understating how bad the current “syntax” is. “syntax” is also a very generous description.

      1. 1

        How would you improve it? The only obvious improvement to me is you should be able to write f(a, b: int) and have both arguments as int. I don’t know how it would look though.

        1. 6

          I mean this PEP seems to do a really good job of improving it?

        2. 4

          presumably, olliej is talking about the syntax for specifying GENERIC type parameters, not the types of parameters. see the linked PEP for examples.

        3. 3

          God no. Then i would be forced to mark the a as Any in a partially typed program.

          1. 2

            I can’t imagine writing a partially typed program but, fair enough. RE the above replies I misread olliej’s comment because I was real tired.

            1. 3

              one reason to have partially typed programs is progressively retrofitting existing code bases with type annotations, e.g. as part of python upgrades. going all the way is the best of course, but this is not always feasible. partial annotations can be a real help when isolating call sites of loosely typed functions, e.g. does this code deal only with (unicode) strings or also with bytes (binary)?

              1. 1

                Adding to this: Some use typing mainly to aid the language server, not to type check.

    11. 3

      The AOL Kewordification of the Internet continues.

      https://mistakes.computer/gtlds

      1. 8

        this might be more convincing with some reasoning attached

        1. 1

          Yeah, weird. Is the page supposed to be blank aside from the heading?

    12. 2

      It is becoming expected that every computer scientist know some basic Petri net theory.

      ok, i’ll bite! completely unfamiliar with Petri Net Theory, but i’m interested to learn. this book feels a bit long to just dip my toes in, and i quickly bounced off the wikipedia page. any recommendation for getting a basic understanding of the theory before jumping in with something like this book?

      1. 3

        Draw a bunch of circles on a piece of paper. These are your “places”. Throw some coins at random on the places.

        Draw a bunch of lines. These are your “transitions”. Draw some arrows from some places to some transitions, and from transitions to places. Any configuration is ok.

        A transition is “live” if every place with an arrow to the transition has a coin on it. A live transition can “fire”. Remove a coin from every inbound place, and put a coin on every outbound place. Note that if a place is both inbound and outbound, its coin number won’t change. If multiple transitions are live, any of them can fire.

        There, that’s petri nets for ya. Try making a petri net that adds the tokens on two places together.

      2. 2

        The nLab page goes from zero to state-of-the-art research, including pictures and the manufacturing metaphor. A Petri net is kind of like a fancy graph, and Petri-net theory is kind of like fancy graph theory; we are given nets, and we want to compute various properties of each net. Common places where you’ll encounter Petri nets include manufacturing, chemistry, and distributed systems.

    13. 5

      HTMX is on my “things to try” list and I think its approach makes a lot of sense for many kinds of web apps. I love a lot of its design choices.

      At the same time, I think the author neglects to mention some of the arguments against using it. The most obvious one: “Hey, can we make a mobile app too?” The React people will whip out React Native and reuse the server interaction code from the SPA. Their backend colleagues will barely have to do any work since it’s just another caller of the existing API. The server-rendered-HTML people, though, will scramble to design a native-app-friendly API from scratch and will be stuck maintaining two request-handling code paths to work with the same underlying data.

      “We have several kinds of clients some of which aren’t web browsers” is a common enough scenario in my experience that I don’t think any HTML-centric approach is likely to be “the future” in the broad sense the post suggests. But it, or something like it, probably has a place in the future.

      1. 4

        can we make a mobile app too? […] maintaining two request-handling code paths to work with the same underlying data.

        Maybe is it the goal of Hotewire’s Strada? (upcoming in 2023)

        “This makes it easy to progressively level-up web interactions with native replacements.”

        The “HTMX for mobile” seems to be Hyperview: https://hyperview.org/ (from the hypermedia.systems book)

        “Hyperview is a new hypermedia format and React Native client for developing server-driven mobile apps.”

        (it says “server-driven” and “networked mobile apps” and warns: “If your app relies on offline data or local computations, Hyperview won’t be the right choice.”)

      2. 3

        I do agree that HTMX is all-in on the web, and it’s not suitable for native mobile apps. I have made a decent PWA with it, though, and compared to comparable SPAs it runs like greased lightning in a mobile browser.

        That said, for a lot of things, you really could take the same approach as the article does for serving HTMX fragments vs full pages — check for an Accept: application/json header, return the appropriate JSON representation after doing the same logic you would for HTMX or no-JS. The client would have to be from scratch, yeah, you don’t get the benefits of something like React Native, but the backend still barely has to change.

        1. 1

          I’d be really interested to hear more about a PWA in HTMX. Is the service worker very app-specific (like knowing how to render data to HTML) or more generic (like caching visited pages)? Do you end up duplicating logic between the server and service worker, or did you find a good way to divide it up? Or did you try to share the logic somehow?

          1. 2

            For my app, it was pretty much just caching and serving some static internal pages. Since the service worker has to be in JS, I didn’t want to make it too involved. My main goals were just to make the app installable on a phone home screen, and to do something sensible when offline.

      3. 3

        Do you consider media queries a insufficient approach to responsibility?

      4. 2

        I think the author neglects to mention some of the arguments against using it.

        The author commented in this thread, literally three hours before you did, and linked to an essay he wrote about when not to use htmx.

        1. 6

          That is the author of htmx, not the OP.

          1. 2

            Haha, good point.

      5. 1

        It obviously depends on the app. HTMX is primarily targetting hypermedia not rich clients, so a mobile app is often not relevant. However, it would also not be a big deal to write a hypermedia client for mobile that was more limited/special case than a browser if you do need an app, and reuse the HTML descriptions etc without using a webview.

    14. 1

      oh cool, this looks very simple and straightforward, i might have to set it up! have you ever experimented with nidobyte? i’ve been interested, but haven’t yet played around with it

      1. 6

        I believe that project has stopped and the author now works for a commercial GitHub competitor if I’m not mistaken.

        Also, we’re about to release a new, open source version of the Nest with cool new ideas.

        1. 2

          looking forward to this! Excited! Thank you.

    15. 5

      not sure if this counts as “dark” enough, but…

      helix is great, but it still feels very young—occasional panics from the Rust code, not-totally-complete LSP support[1], no hooks or plugins yet. By far my favorite TUI editor, but I still feel the need to drop back to VSCodium sometimes.

      [1]: this might be on me for attributing some of rust-analyzer’s nicer features to LSP when in fact they are custom extensions that have special support in VSC, rather than a shortcoming to be attributed to helix

      1. 3

        I recently switched to Helix and I’m ambivalent about plugins. I kind of like that I can’t torpedo my setup the way I did with Emacs. But I’m sure someone will come up with a plugin that I would absolutely need to have, although for now I am content with what it can do out of the box.

    16. 13

      What a cool achievement! Makes me wonder whether this is on the radar for Nix, or if this is a distinguishing feature of the Guix project.

      1. 12

        I think there is some work in that direction! When reading this post, I came across a link to this PR: stdenv: begin work on 256b bootstrap i.e. Trusting Trust

      2. 6

        I would recommend taking a look at Guix if you are insterested in Nix. I see it as a Nix 2.0, same core idea but better UI, documentation and a more principled approach. Not that it’s a competition, just a matter of taste.

    17. 12

      GPT has an annoying habit of being almost right, to the point that it takes enough research for me to verify it’s results as to just do it myself, and I’m still worried there’s something subtlety wrong with what it tells me.

      It’s not useless, and i use it, but I don’t trust it. If I did, it would have made a fool of me more than once.

      1. 3

        I think the bigger problem is that it’s always confident. I’m working on a paper right now and I’m using pgfplots, which is a fantastic package for generating tables and graphs in LaTeX, with a thousand-page manual that I always spend ages reading when I use it, and then forget because I use it so rarely. This time, I used Bing Chat (which finds the manual and a load of stack-overflow-style answers to add into its pre-trained data). I tried to get it to explain to me how to get labels to use SI prefixes as contractions. It gave me a plausible answer along with an example and the output that I wanted. There was just one problem: copying its example verbatim into my TeX file gave totally different output. No variation on its example worked and I couldn’t prompt it to give me one that worked in half an hour of trying.

        In contrast, when I wanted to create a bar chart with the same package, it basically told me what to do. Everything I wanted to change, I asked it for and it showed me a summary of a relevant part of the manual. For fairness, I had the manual open in another window and tried looking up the answer while it was processing and it was faster almost all of the time. For things that loads of people have done, but I can’t remember how to do (or never knew), it was a great tool.

        Unfortunately, the responses in both cases were indistinguishable. Whether it’s giving me a verbatim quote from an authoritative source or spouting bullshit, it’s always supremely confident that its answer is correct. It definitely reminds me of some VPs that I’ve met.

      2. 2

        this is what I am finding too.

      3. 1

        After provides me with a solution, I always ask “is that correct?” so that it verifies its own output.

        1. 2

          If it produces an incorrect answer to a question, what stops it from “verifying” that initial incorrect answer? Or is this more like, another layer, another chance for it to maybe be accurate?

          1. 2

            I couldn’t tell you, I don’t know how it works, just that on solutions I’ve known to be incorrect, asking that question has provided the expected corrections, so it’s doing something.

            1. 3

              My understanding is in ChatGPT4 data only flows in one direction, by asking it to reflect on its own answer it is giving the network a chance to process its own thoughts in a way (inner monologue?) at the cost of more compute time.

          2. 2

            When asking it if it’s correct, the answer it gave previously will be part of the context, so it will be available from the first layer, so it will be better processed by all the layers of the Transformer. Whereas when you ask it for something, it will use some layers to figure out what you meant and in what direction to answer, meaning there is less compute available to producing the correct answer.

      4. 1

        I’ll start taking this stuff more seriously when the parties lauding it have skin in the game: use a LLM-generated contract, for example.

    18. 5

      You’re probably looking for a small company that does only DNS, that has no loss-leader products, and whose CEO is the kind of person you might find on Lobste.rs. EasyDNS is that. Surely not the only such company.

      1. 2

        luadns.com is great as well, I can’t recall whether the ceo is floating around here…

      2. 1

        That is exactly what I want (less caring about the proclivities of the CEO though), and it took me to Namesilo a while ago. They’ve since gone down the “push add on services unless you’re a domain hoarder with hundreds of ‘investments’”

        EasyDNS also mentions web hosting and email hosting - so seems like they too are not only DNS/Registrar.

        1. 1

          Yes. No loss-leading or cross-subsidy, though, and they’ve never asked me whether I might perchance want to purchase their other products.

          I don’t care whether a CEO posts here, but I do care that the CEO speaks and understands the language spoken here, and shares our values.

    19. 4

      I think the link is broken? This one worked for me: https://github.com/npmaile/blog/blob/main/posts/1.%20flashbang.md

      1. 3

        Thank you. I changed the file name shortly after posting and forgot that that would break the link

        I guess I’ll clean it up later