5 ms·
Just one data point, but: I'm currently learning about embedded microcontrollers. The standard starting point for this is arduino, which is C/C++ based, so ther
by kennywinker 9y ago
Just one data point, but: I'm currently learning about embedded microcontrollers. The standard starting point for this is arduino, which is C/C++ based, so there is a strong pull towards C++ already. But I really wanted to avoid C/C++, and I spent a long time researching alternatives. Rust was one of the most mature for MCUs, but a) it's not very mature and b) you have to pick an MCU with a lot of flash memory as even the smallest rust binary is >100kb. For reference, one of the chips I've been testing out for this project has 127kb of flash. This evening I loaded on a medium-sized C++ project and it took just 24kb.
So that's what's preventing ME from using rust instead of C++
- johnny22 9y agowhich one generated a 100k binary? I see it running on an uno right here, which has less than 100k https://github.com/avr-rust/arduino https://github.com/avr-rust/arduino Were you using zinc or some other project as the base? I figure it is an arm cortex * in your case.
- kennywinker 9y agoI was using the standard rust compiler, plus a bunch of articles on thinning rust binaries. Best I managed was about 80kb after three or four layers of thinning. That link is pretty interesting! The Rev3 uno has 32kb flash, so someone has found a way to thin the binaries enough to fit on an MCU. Cool.. now if only I knew how they did it!
- johnny22 9y agosee how zinc does it https://github.com/hackndev/zinc https://github.com/hackndev/zinc EDIT: Zinc seems to not have been updated in awhile I'm not sure what the current status is of other mcu efforts. I bet some of the other rust folks can elaborate.
- kam 9y agoThe size of a binary statically-linking libstd and targeting a desktop OS has nothing to do with the size of a binary targeting a bare-metal microcontroller where you use only libcore. If you compile for a MCU target with MCU-style code, your code size will be in the same ballpark as the equivalent C++.
- AstralStorm 9y agoHow different is a desktop OS when you're doing syscalls directly (or through a tiny libc) from an embedded OS? See your post sounds like a say so story without data behind it.
- 35bge57dtjku 9y agoThere's really no way to trim down the rust binaries??
- kennywinker 9y agoThere are a bunch of articles on trimming. I think I managed to get it down to like 80kb before I gave up.
- steveklabnik 9y agoThere absolutely is; the smallest known Rust binary is 151 bytes.
- AstralStorm 9y agoHow about a smallest real application that doors something useful? Say, basic networking on the level of static pages like uhttpd. (Used in many routers.) Or a busybox ash equivalent at least.