Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wonder what the wasm-backend people are doing that the embedded-backend people aren’t — I’d have thought embedded was even more particular about small size, but I just started playing with rust-esp32 and found that “hello world” is 15MB (to be fair it’s only 4MB with debug info stripped)...


You can check out a number of strategies for reducing rust binary size here: https://github.com/johnthagen/min-sized-rust

I don't think he mentions it, and I doubt it's relevant in your Hello World example, but if you have a lot of generic code, it's useful to extract the non-generic parts into a separate non-generic function. For example:

  fn foo<T: AsRef<str>>(s: T) -> String {
      bar(s.as_ref())
  }
  
  fn bar(s: &str) -> String {
      // A whole bunch of other stuff
      s.to_string()
  }




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: