HNHacker News
TopNewBestAskShowJobs

OskarS

8,399 karma · joined September 4, 2016

submissionscomments
OskarS··on Comparison of configuration file languages (2016)
More and more the last couple of years, I’ve started to realize that ”configuration languages” are just a bad idea. Please, for the love of all that is holy, just let us use a real programming language. For simple declarative configuration, it’s no more difficult to use Python (or Lua or whatever) than YAML, and for complex configuration (looking at you, YAML files for GitLab CI), it’s an absolute godsend to be able to use real if-statements and for-loops. If security/runtime is a concern, you can sandbox it or use something like Starlark.

JSON is a fine over-the-wire format, but can’t we leave YAML in the dustbin and just do it ”properly” from now on? Please?

OskarS··on The Electoral College was nearly abolished in 1970 (2020)
I'm very pessimistic this is ever going to work. Even if they get above the threshold with everyone still on board, I'm certain this is going to be challenged in court and overturned. Not that there's anything unconstitutional about it, but the popular vote (generally speaking) benefits the Democrats, so there's no way the current Supreme Court is going to allow it. Which is a very depressing view of the Supreme Court, but that's the world we live in.
OskarS··on Why Safety Profiles Failed
Yeah, this one is so weird. You've been able to do that forever in C, and virtually all big compilers have this keyword in C++ as well, just named __restrict. Why is it so hard to get into the standard, at least for pointers? I can imagine that there are complex semantics with regards to references that are tricky to get right, but can't we at least have "'restrict" can only be used on raw pointer types, and it means the same thing as it does in C"?
OskarS··on Show HN: I made tool for slicing up samples to Ableton Move presets
Yeah, fair, but the slots in Life are mapped to MIDI, so you can trigger them that way if you want, you don't have to use the built-in sequencer.
OskarS··on Show HN: I made tool for slicing up samples to Ableton Move presets
We were very happy to get that working as well as it did, the first time we've ever made an app (we're VERY much audio plugin people, not app developers). Worked really nicely in the end!
OskarS··on Show HN: I made tool for slicing up samples to Ableton Move presets
You might want to check out Life by XLN Audio, which does some of what you want here as well: https://www.xlnaudio.com/products/life

(disclaimer: I work for XLN Audio)

OskarS··on Show HN: I made a git rebase TUI editor
I think "every PR should be a single commit when merged" is a bit too dogmatic. If the PR is logically split up into bits of work that conceptually separate and that compile/run independently, then it makes sense to have those as separate commits. You might argue that those should then be separate PRs, but that's going a bit too far, I think. You can still revert it, it's just have to revert the individual commits and squash the revert commits.

IMHO the guideline should be "clean up your branch and rebase it before merging. Usually that means a single commit, but it can be multiple if that makes more sense to <future person> reading the history".

OskarS··on Conway's Gradient of Life
Lovely video, and it was enormously personally satisfying to me while he was describing his evolutionary algorithm I just sat thinking "why not just use a SAT solver, this seems like child's play for z3?" and then hearing him go "then I asked Reddit and someone suggested using a SAT solver". Hell yeah, good job, brain! I mean, not as good a job as Brian who actually implemented it and made the video and everything, but still!
OskarS··on Hash Ordering and Hyrum's Law
I wanna say that Abseil's hash function does something like this? It was a couple of years ago, but I remember tearing my hair out figuring out why hash tables passed from a C++ api to my tests were failing. Turns out, the tests and the API was compiled by my build system as separate libraries and dynamically linked, and that abseil seeded their hash function with the address of a dummy global variable (which had a different location in the main program and the tests).

Presumably because they didn't want people to depend on the value of the hash function because of Hyrum's Law, but that meant the hash tables couldn't be passed across a DLL boundary, which seemed like an insane tradeoff to me. But hey, I'm not google, I get why they would do it.

OskarS··on Sqlite3-Rsync (Draft)
Very cool! This seems like an excellent backup utility as part of core SQLite. Great that you can still run write transactions on the origin while it’s in progress, i wonder what the guarantees are there for which in-progress transactions are synced to the replica.

EDIT: ah, missed this part

> REPLICA becomes a copy of a snapshot of ORIGIN as it existed when the sqlite3-rsync command started. If other processes change the content of ORIGIN while this command is running, those changes will be applied to ORIGIN, but they are not transferred to REPLICA Thus, REPLICA ends up as a fully-consistent snapshot of ORIGINAL at an instant in time.

OskarS··on How Raw sockets behave differently in macOS and Linux
Linux != UNIX
OskarS··on Hallelujah, Leonard Cohen, and a Pulitzer Prize-winning writer's suicide
One of my favorite Cash songs is The Mercy Seat, I just think it’s a masterpiece. And it’s SO Johnny Cash (religion! crime! last line twist!) that I was stunned when I recently looked it up and realized he didn’t write it, it’s a cover of a Nick Cave & The Bad Seeds song. The Nick Cave version is… fine? I mean, it’s good! But the Johnny Cash version is sublime, there’s no comparison.

Must have been a weird feeling for an artist to hear Johnny Cash is covering your song. On the one hand, he’s a legend who inspired you and who you worship, but also it has to be a bit of “oh shit, his version is going to be so much better than mine, isn’t it? Well, I guess it’s Johnny’s song now. ”

OskarS··on Posting a 5x5 crossword every day
Yes, that kind of thing, but with an illustration and usually styled nicer. This is a very typical look (the first crossword i found by googling): https://www.argument.se/wp-content/uploads/2018/10/Korsord-2...
OskarS··on Posting a 5x5 crossword every day
I grew up with Swedish crosswords, where the clues are written into the "non-letter" cells (the ones that are shaded in an American crossword). There's no separate clue section, it's just all part of the grid. They almost always have some illustration as well, they look really delightful compared to American crosswords, though from a "puzzle" angle they're not always as fun.
OskarS··on Honey, I shrunk {fmt}: bringing binary size to 14k and ditching the C++ runtime
> In order for delete[] to work, C++ must track the allocation size somewhere.

That is super-interesting, I had never considered this, but you're absolutely right. I am now incredibly curious how the standard library implementations do this. I've heard normal malloc() sometimes colocates data in similar ways, I wonder if C++ then "doubles up" on that metadata. Or maybe the standard library has it's own entirely custom allocator that doesn't use malloc() at all? I can't imagine that's true, because you'd want to be able to swap system allocators with e.g. LD_PRELOAD (especially for Valgrind and stuff). They could also just be tracking it "to the side" in some hash table or something, but that seems bad for performance.

OskarS··on Calendar Queues: A Fast O(1) Priority Queue Implementation (1988)
You don't actually need to have the "adjust priority of element" operation to implement Dijkstra or A-star. The standard description of the algorithm always include this, but it is not actually necessary: instead of adjusting element priority, you just push duplicate vertices with new priorities on to the queue, and when you pop the queue, you just check if you've already seen this vertex before. If so discard it and pop the next one. The algorithm still works, since the first time you pop a vertex that is the shortest path, and the rest of the time you can ignore it. Simple to implement and plenty fast. There's no difference in time complexity: you have to consider the "duplicate" case at some point, you're just pushing to a later time when you pop it from the queue.

You might argue that is wasteful of space pushing these duplicates, but your other options are either to graft this functionality on to a normal priority queue in which case you're using that space anyway, or to use a much more complex and usually slower kind of priority queue with this operation naturally (e.g. Fibonacci heaps). The space wasted is quite small in practice, since the only time this happens is if multiple nodes on the frontier points to the same element, but most nodes ("in practice") have small degree of incoming paths. The benefit of being able to use standard (and very fast!) priority queues without this weird operation is well worth it.

In my experience of implementing Dijkstra and A-star a couple of dozen times (I like Advent of Code problems!) this has always been the better way to do it. I mean, I haven't put Dijkstra/A-star into production or anything (I don't work for Google Maps or whatever), but in my experience this is the simplest and fastest way in practice to implement these algorithms.

OskarS··on Diffusion models are real-time game engines
> 1 billion frames in memory... With such dataset, you have seen practically all realistic possibilities in the short-term.

I mean... no? Not even close? Multiply the number of game states with the number of inputs at any given frame gives you a number vastly bigger than 1 billion, not even comparable. Even with 20 days of play time to train no, it's entirely likely that at no point did someone stop at a certain location and look to the left from that angle. They might have done from similar angles, but the model then has to reconstruct some sense of the geometry of the level to synthesize the frame. They might also not have arrived there from the same direction, which again the model needs some smarts to understand.

I get your point, it's very overtrained on these particular levels of Doom, which means you might as well just play Doom. But this is not a hash table lookup we're talking about, it's pretty impressive work.

OskarS··on Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)
I agree, this would be useful. Another one I would like is auto-vectorization, a way to mark a loop with an attribute and if it fails to auto-vectorize, the compiler should print out the auto-vectorization report for that loop, explaining why it happened. It's such a brittle optimization, but it's crucial for a tiny number of extremely hot loops, you would want to know if it failed due to some code change or compiler upgrade. Also, it's just a pain to use auto-vectorization report normally.
OskarS··on Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)
Yeah, that's the way virtual machines have been written forever, some version of

    for instruction in instructions {
        switch (instruction) {
            case OPCODE_X: //....
            case OPCODE_Y: //....
            case OPCODE_Z: //....
        }
    }
This is how VMs have been written since the dawn of time (or using computed gotos, another non-standard addition to C). It has problems though, like the fact that the `switch` branch is extremely unpredictable, and that you get a massive function which is hard to optimize. This [[musttail]] trick is a huge improvement. But yeah, if you got to support compilers that don't have [[musttail]], you in essence have to have two implementations, the [[musttail]] one and the loop/switch one.
OskarS··on Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)
Yes, that is correct. You cannot do this trick in standard C, C++ or Rust, it requires some version of [[musttail]]. Strong argument for adding it to the C standard, IMHO.
OskarS··on Parsing protobuf at 2+GB/s: how I learned to love tail calls in C (2021)
Obviously compilers have been doing tail call elimination for ever, but for this trick "generates [tail calls] quite reliably" is not enough: you have to GUARANTEE it (or fail compilation), otherwise this structure does not work (it will blow the stack immediately). That's the point of [[musttail]], tail call elimination is required, that's the only choice the compiler has.
OskarS··on Maximal min() and max()
It will be MUCH less, and much less complex than this.
OskarS··on Building rqlite 9.0: Cutting disk usage by half
I so much more appreciate this style of version numbering compared to being eternally 0.something.
OskarS··on SVG Triangle of Compromise
Isn't the fundamental issue here not so much anything to do with `<svg>`, but with the fact that you can't easily include HTML snippets from other files in HTML? Like, the only reason not use the <svg> tag seems to be "it's not cached, and it contains a BUNCH of svg, and it has to be loaded with the main HTML page"

Can't you say that about anything in HTML? Like, imagine you had a huge `<head>` tag that contained a bunch of stuff, but it's essentially the same (except for, like, the title) for all documents. Don't you wanna do this?

    <html>
    <head>
      <<< include head.html >>>
      <title>Cool page!</title>
    </head>
    <body>
        <svg>
            <<< include logo.svg >>>
        </svg>
    </body>
    <html>

Where the `<<< include ... >>>` is a pretend bit of HTML that makes the browser fetch that from somewhere else. A preprocessor, more or less.

I realize this is what templating languages are for, but if this happened on the HTML layer, the browser could do way better caching.

OskarS··on SQLite: 35% Faster Than the Filesystem
If that SELECT query is too much for you, I agree, SQLite is maybe not meant for you. Not a very solid argument against SQLite, though.
OskarS··on SQLite: 35% Faster Than the Filesystem
> As my app matured, I found that I often wanted hierarchical folder-like functionality. Rather than recreating this mess in db relationships, it was easier to store the path and other folder-level metadata in sqlite so that I could work with it in Python. E.g. `os.listdir(my_folder)`.

This is a silly argument, there's no reason to recreate the full hierarchy. If you have something like this:

    CREATE TABLE files (path TEXT UNIQUE COLLATE NOCASE);
Then you can do this:

    SELECT path FROM files WHERE path LIKE "./some/path/%";
This gets you everything in that path and everything in the subpaths (if you just want from the single folder, you can always just add a `directory` column). I benchmarked it using hyperfine on the Linux kernel source tree and a random deep folder: `/bin/ls` took ~1.5 milliseconds, the SQLite query took ~3.0 milliseconds (this is on a M1 MacBook Pro).

The reason it's fast is because the table has a UNIQUE index, and LIKE uses it if you turn off case-sensitivity. No need to faff about with hierarchies.

EDIT: btw, I am using SQLite for this purpose in a production application, couldn't be happier with it.

OskarS··on What's the point of std:monostate? You can't do anything with it
Exactly. The difference here is that std::variant doesn’t “name” the options, you just get the type (and an index, so variant can contain duplicate types). So you have to have some marker type that’s like “this contains nothing”.

Fundamentally, Rust’s enums are a much better way of doing this thing compared to std::variant, but C++ did the best it could without changing the core language. Which arguably they should have done.

OskarS··on What's the point of std:monostate? You can't do anything with it
You're not wrong, if you just want "a T or nothing", optional is the way to go. But what if you want "a T, a U, a V, or nothing"? Then you do

    std::variant<std::monostate, T, U, V>
Or

    std::optional<std::variant<T, U, V>>
But then the "none" state is a bit more "special", it's not just one of the options. The sizeof of the type will also probably be a bit bigger, because it has to contain both the bool for the optional, as well as the tag for the variant.

The other obvious use is what the article states, that it allows the variant to be default constructed even if none of its members are. Though you can do that with optional as well. It's mostly a matter of style. I mostly avoid std::monostate because the name is so confusing, I really agree with the other users that something like std::unit or std::none would be better.

OskarS··on A brief interview with Tcl creator John Ousterhout (2023)
A huge bummer about Guile (and that is frankly shocking for a language designed to be embeddable) is that it relies on a bunch of global state, which means that you can't embed multiple interpreters a single process. This totally kills it as a embedded scripting language for many applications, and it's also just bad practice in general. Even Python, far less easily embeddable, supports multiple interpreters, though before Python 3.13 (I think) they all shared the GIL.

Aside from this issue, the Guile API is pretty good, but the best one by far is Lua's C API, which is just a thing of beauty. I'm curious to try it with Tcl.

OskarS··on CrowdStrike Update: Windows Bluescreen and Boot Loops
For sure, no question! There's a reason people choose Microsoft. My question was narrower, just the question on reliability (hence "all else being equal"). I don't think you can say that, leaving aside issues like this, that Windows is as or more reliable than Linux.

For instance, if you had to make deploy a mission critical server, assuming cost and other software was the same, would you choose Linux or Windows for reliability? Of course you would choose Linux.

← PreviousPage 8 of 34Next →