Post 9jgTcbaVsz86arCEaW by architect@linuxrocks.online
 (DIR) More posts by architect@linuxrocks.online
 (DIR) Post #9jby5w0d45jbA3Vu1g by architect@linuxrocks.online
       2019-06-07T18:14:38Z
       
       0 likes, 0 repeats
       
       I decided to start looking at programming languages other than C to expand my skills, some fun notes from what I noticed after just writing simple "Hello World" programs:Rust: Noticeably slower to compile than others, ~250K binD w/dmd: ~900K binD w/ldc2: ~5M binC: 8K bin, not strippedI'm still planning to work on these to varying degrees, but this is absurd to just write a string to stdout.
       
 (DIR) Post #9jbzTzWfk0KUyMXK9g by architect@linuxrocks.online
       2019-06-07T18:30:04Z
       
       0 likes, 0 repeats
       
       All of these were built as "release" or similar, with as many obvious optimizations as possible.
       
 (DIR) Post #9jc06eviFbcCO9gfTM by Halbeard@linuxrocks.online
       2019-06-07T18:37:09Z
       
       0 likes, 0 repeats
       
       @architect The overhead in Rust could be all the measures for safer code like the thread safety features. But good to know that it's possibly not suitable for embedded applications with very weak hardware.
       
 (DIR) Post #9jc0h9kz78fWQD4YQy by dar13@linuxrocks.online
       2019-06-07T18:43:45Z
       
       0 likes, 0 repeats
       
       @architectDid you do '-C prefer dynamic' for Rust? Otherwise it's statically linking the Rust runtime.
       
 (DIR) Post #9jc2p4Uol0YUKZPdGS by architect@linuxrocks.online
       2019-06-07T19:07:37Z
       
       0 likes, 0 repeats
       
       @dar13 I didn't initially because I had no idea what that option did. The compile time is roughly the same, but the resulting binary is significantly smaller. Only 9.1K, roughly 7% larger than the dynamic C version. So that's actually reasonable, if annoying with larger projects due to compile times
       
 (DIR) Post #9jc36xnyNBpGn7u5aa by architect@linuxrocks.online
       2019-06-07T19:10:51Z
       
       0 likes, 0 repeats
       
       @Halbeard It seems to be due to the rust runtime being statically linked, thanks to feedback from @dar13. After running another test, it looks to be roughly 7% larger than C code (both using -Oz for size). So it's still bigger, but it may be feasible depending on your available storage, but you'll need the runtime libs somewhere.
       
 (DIR) Post #9jdroCk5twvkRArUWm by almindor@linuxrocks.online
       2019-06-08T16:13:38Z
       
       0 likes, 0 repeats
       
       @architect code size is due to static linking. Rust is generally on par with C on performance and provides very needed safety. I just played with rust on the hifive1 riscv board and the compiler caught and error... Me trying to use the same physical pin twice.
       
 (DIR) Post #9jdu7fZh7yrhGlPHkm by almindor@linuxrocks.online
       2019-06-08T16:39:32Z
       
       0 likes, 0 repeats
       
       @architect also hello world in C statically linked, stripped is 675kb in 64bit linux/elf
       
 (DIR) Post #9jdzUyciyD4OmOkzzs by architect@linuxrocks.online
       2019-06-08T17:39:48Z
       
       0 likes, 0 repeats
       
       @almindorDynamic Rust build was still larger than the C build and when the C version is statically linked the size varies based on libc, but was still smaller on DragonFly BSD (my primary OS)I understand the appeal of Rust, I'm just amazed at the amount of code being generated for such a simple example program.
       
 (DIR) Post #9je1g2IjpwldHNoHRo by almindor@linuxrocks.online
       2019-06-08T18:04:13Z
       
       0 likes, 0 repeats
       
       @architect most of it is just getting to main(). See https://m.youtube.com/watch?v=dOfucXtyEsU
       
 (DIR) Post #9jepcnL80C7niUZkoa by architect@linuxrocks.online
       2019-06-09T03:23:49Z
       
       0 likes, 0 repeats
       
       @almindorRight, but that doesn't necessarily mean it's worth keeping around if we can avoid it, see this similar talk: https://www.youtube.com/watch?v=tIBVQDF2YCw
       
 (DIR) Post #9jg5YqTADWuCgnQtwO by almindor@linuxrocks.online
       2019-06-09T17:57:08Z
       
       0 likes, 0 repeats
       
       @architect if you want really small static binaries try freepascal with the -Xx -Xs flags.
       
 (DIR) Post #9jgTcbaVsz86arCEaW by architect@linuxrocks.online
       2019-06-09T22:26:43Z
       
       0 likes, 0 repeats
       
       @almindorI'll have to check it out at some point. Since our storage spaces are huge now, I'm not as concerned with the absolute size of binaries as I am with the massive amounts of overhead some languages have.It'd be nice to get smaller binaries with safety like in Rust, but with better abstract machines, and I'd prefer to keep the small vocabulary of C.
       
 (DIR) Post #9jgnnR2bRC2u9RmCeG by almindor@linuxrocks.online
       2019-06-10T02:12:47Z
       
       0 likes, 0 repeats
       
       @architect Rust's safety mostly costs 0 during runtime. That's the beauty of it, it's all compile time checks. I confirmed this with embedded rust on riscV. My code uses nice abstractions on top of things like SPI and GPIO pins, but the actual assembly code produced is same as if you'd write directly to said memory regions by hand.