HNHacker News
TopNewBestAskShowJobs

iigijshaba

4 karma · joined July 9, 2026

submissionscomments
iigijshaba··on My thoughts on the Bun Rust rewrite
Those systems are primarily written in C or C++-but-in-C-style, right? Without exploiting RAII among other features, as Jarred mentioned that he liked in Rust. While Rust took RAII from C++.
iigijshaba··on Postgres rewritten in Rust, now passing 100% of the Postgres regression tests
Now that I have taken a closer look, the code looks significantly better than it seemed at first glance, though there are still peculiarities, and some drawbacks.

An unfortunate aspect is that the code has become a bit more bloated in some regards due to usage of Result, instead of an implicit elog() macro and similar. Passing Result around, in some ways as an alternative to an unwinding exception, is cleaner in some ways, but it also bloats the code somewhat.

The rewrite also could have simpler code in some cases, like

https://github.com/malisper/pgrust/blob/3646a73515a5e4ac7d0b...

could perhaps just be

match syscache_seams::search_pg_class_full_form::call(ctx.mcx(), relationId)? {

        Some(form) => Ok(form.relhassubclass),

        None => {

            Err(ereport(ERROR)
                .errmsg(format!("cache lookup failed for relation {relationId}"))
                .into_error())

        }

    }
but that is a smaller thing.

I see a lot of MemoryContext. I am not sure how much that bloats the code (though the C code is bloated due to C's issues and problems, like re-using collections and such). Does it incur an overhead?

iigijshaba··on Postgres rewritten in Rust, now passing 100% of the Postgres regression tests
More that I got confused by the C function returning bool, not as an error value, but as a result, which is my fault for skimming it quickly.

I have taken a closer look at the code, and it seems superficially a somewhat faithful rewrite, not quite idiomatic Rust, but closer than I anticipated at first. I know there are non-LLM rewriting tools for C to Rust, and with a test suite to help, a rewrite to Rust might be greatly helped. The new Rust code does have some drawbacks in some ways, and there are topics I am curious about.

iigijshaba··on Postgres rewritten in Rust, now passing 100% of the Postgres regression tests
I have read up on it again, and while it was entirely dysfunctional at the very early stages, it quickly came up to par or beyond, with the LLM especially helped by the huge test suite written in Typescript, different from both Zig and Rust.

However, Jarred still describes a lot of unsafe, and usage of Miri in continuous integration.

Funnily enough, RAII is cited as a major benefit of rewriting from Zig to Rust, while C++ already has RAII. I wonder if C++ and Rust are more suited to larger programs than Zig, unless the architecture in Zig is handled carefully.

iigijshaba··on Postgres rewritten in Rust, now passing 100% of the Postgres regression tests
Sorry, I wrongly assumed in the C code when I skimmed it that the boolean was for error handling, not the result value. The elog() macro is used for error handling.