logoalt Hacker News

chrismorganlast Friday at 10:46 AM1 replyview on HN

> Even a basic hello world in rust will set you back a few megabytes

Lies. It’s 35 kB:

  $ cargo new x
  …

  $ cd x

  $ cat src/main.rs
  fn main() {
      println!("Hello, world!");
  }

  $ cargo build --release --target=wasm32-unknown-unknown
  …

  $ ls -l target/wasm32-unknown-unknown/release/x.wasm
  … 34597 …
And that’s with the default allocator and all the std formatting and panic machinery. Without too much effort, you can get it to under 1 kB, if I remember correctly.

For the rest: I mention comparisons being unbalanced because people often assume it will scale at the rate they’ve seen—twice as much code, twice as much size. Runtimes and heavy tables make for non-scaling overhead. That 35 kB you’ve paid for once, and now can use as much as you like without further growth.


Replies

hajilelast Friday at 5:19 PM

35kb is the size of a lot of entire JS frameworks.

show 1 reply