14 votes

NaN boxing or how to make the world dynamic (2020)

5 comments

  1. Zorind
    Link
    Every time I read anything about how interpreters or low-level languages function (or how high-level languages use them), I find it really interesting, and am so glad most of the tricks are things...

    Every time I read anything about how interpreters or low-level languages function (or how high-level languages use them), I find it really interesting, and am so glad most of the tricks are things I can completely ignore (as someone who primarily uses JavaScript, Python, and C#. Sure, I have to deal with byte arrays in some of the C# code I use, but rarely have to actually manipulate things on a bit level).

    The original programming practices and how we got to modern, optimized-under-the-hood programming languages astounds me. I am so grateful for the things I can write and generally trust that either: the compiler will handle optimization for me, or the optimization doesn’t matter all that much given the constraints of the systems I work with.

    Everything happening/explained in this article is so fascinating to me, but I’m extremely glad I will likely never need to think of it or try to use it (directly).

    5 votes
  2. skybrian
    Link
    This is something you can do in low-level languages such as C that I really missed when I wrote an interpreter in Go. These bit-packing tricks are unsafe (particularly for pointers) and would need...

    This is something you can do in low-level languages such as C that I really missed when I wrote an interpreter in Go. These bit-packing tricks are unsafe (particularly for pointers) and would need to be built in the implementation of union types in a safe, high-level language.

    Writing interpreters is a niche, though, so it’s understandable that the Go implementers don’t prioritize it.

    3 votes
  3. cazydave
    Link
    First time I post link, so sorry for any missing tag (there will be many). This is a walkthrough (guide?) on a way to optimize having a single variable storing (and switching) value of different type

    First time I post link, so sorry for any missing tag (there will be many).

    This is a walkthrough (guide?) on a way to optimize having a single variable storing (and switching) value of different type

    1 vote
  4. [2]
    donn
    Link
    Super, super interesting read. Nice seeing IEEE 754 being used like this. What's surprising to me though is that V8 uses tagged pointers, and thus no direct doubles. That's interesting given that...

    Super, super interesting read. Nice seeing IEEE 754 being used like this.

    What's surprising to me though is that V8 uses tagged pointers, and thus no direct doubles. That's interesting given that I think unless you do something like let x = (0 << 0); numbers in JS are doubles by default…

    1 vote
    1. [2]
      Comment deleted by author
      Link Parent
      1. donn
        Link Parent
        That would make a lot of sense, thanks for the insight

        That would make a lot of sense, thanks for the insight