logoalt Hacker News

irishcoffeetoday at 12:31 PM5 repliesview on HN

So "unidiomatic" rust means, 'don't use these parts of the language even though they're first-class citizens?'

How odd. Lot of mental gymnastics going on there.


Replies

flohofwoetoday at 12:53 PM

The Bun author himself writes that the port is not idiomatic Rust:

    Do the rewrite that looks like we transpiled our Zig code to Rust. We can gradually refactor it to reduce unsafe usage and look more like idiomatic Rust after Bun v1.4 ships.
(from: https://bun.com/blog/bun-in-rust)

The original version of Bun was already a line-by-line (manual) port of esbuild from Go to Zig (also mentioned in this post), so the Zig code already wasn't "Zig-idiomatic" and apparently riddled with problems. That doesn't inspire much confidence in the LLM-translated Rust version tbh.

show 1 reply
tribaaltoday at 12:46 PM

It's mostly the same in any general purpose programming language though, parts of the language features are meant (or became seens as) tools to be used in very narrow cases, which people less familiar with the language tend to "overuse".

Eg. goto/jump, bare "except" statements in python, etc... In Rust, unsafe has its uses and is a first class language feature, but it certainly isn't idiomatic to use it to mimic access patterns from other languages (unless absolutely necessary).

williamdclttoday at 2:00 PM

> "unidiomatic" rust means, 'don't use these parts of the language even though they're first-class citizens?'

that is indeed a roughly accurate definition of what "unidiomatic" means

ModernMechtoday at 12:55 PM

It means "don't misuse parts of the language in ways that circumvent best practices" one of which is "keep unsafe regions as small and few as possible" not "never use unsafe"

vessenestoday at 1:23 PM

Meh. The (a major?) goal of Rust is this sort of type safety flowing down to memory bugs. Not every possible access pattern was known at the beginning, and generally they developed a philosophy of keeping the "unsafe" memory access patterns extremely bounded and heavily inspected. I think that's a fair and admirable goal.