https://news.ycombinator.com/item?id=48609168
https://grigio.org/bun-1-4-the-controversial-ai-driven-rewri...
> 13,044 unsafe blocks in the resulting Rust code (hand-written Rust projects of similar size average ~73)
Grok is this true?
I've heard the meme that AI written rust code is absurdly full and safe blocks but... that's pretty funny.
Hang on. A claim like that can be verified with a single grep! Give me a minute...
$ rg -U "unsafe\s+\{" . | wc -l
10551
Hey, that's progress!It's unironically a good practice when you port from an unsafe language (C/Zig) to Rust. Porting isn't refactoring. One should keep the logic mapping one-to-one as much as possible.
The high number of unsafe blocks is a good sign.
Counting instances of "unsafe {" is pretty useless. Unsafe is needed in "safe" code. What it allows is to create a boundary where the caller is the one that uphelds the contract. If the unsafe is in an internal library, it’s much more difficult to misuse.
This is ironically a skill issue in prompting, especially if they had Fable access - or, more likely, they just really, truly don’t care.
> I've heard the meme that AI written rust code is absurdly full and safe blocks but... that's pretty funny.
If I understand what happened here correctly this isn't really a case of any such meme, but the result of the porters (heh) telling the LLM to directly convert zig code using unsafe to match the previous code "exactly".
I.e. more like using the LLM as a fancy version of c2rust [1] (which would result in just as much unsafe) than a result of LLMs reaching for escape hatches too liberally.
[1] https://github.com/immunant/c2rust