3 ms·
By removing the C standard lib and using a custom linker you can get the Hello World down to 150 bytes. Here is a fun read: https://hookrace.net/blog/nim-binary
by mratsim 8y ago
By removing the C standard lib and using a custom linker you can get the Hello World down to 150 bytes. Here is a fun read: https://hookrace.net/blog/nim-binary-size/ https://hookrace.net/blog/nim-binary-size/.
- marmaduke 8y agoOther than a sort of ELF golf why would dropping the C lib be useful?
- nickpsecurity 8y agoIn high-assurance fields, the mindset is all code is malicious, buggy garbage until proven otherwise by rigorous analysis. That means everything we include will cost us. If we don't use it, we don't include it by default to save us work.
- lylecubed 8y agoEmbedded development.
- vmchale 8y ago> ELF golf actually turns out to be important in embedded work
- steveklabnik 8y agoIncidentally, in Rust this kind of thing could get you 151 bytes out of Rust: http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-static-linux-binary-in-rust.html http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-... (linked in that post) But that was before 1.0. Updating the example and applying some more tweaks, it’s down to 145: https://github.com/tormol/tiny-rust-executable https://github.com/tormol/tiny-rust-executable
- Annatar 8y agoRust is also terribly overcomplicated and a mishmash salad of different languages, so much so that in the end, it's just simpler to call ld(1) on a .o file directly.