3 ms·
Rust is statically linked by default, not sure how D works. Rust still includes some debug features that can give you a stack trace. Size will also depend on th
by PudgePacket 6y ago
Rust is statically linked by default, not sure how D works. Rust still includes some debug features that can give you a stack trace. Size will also depend on the compile options, if LTO was enabled, how much generics were used, how much string printing was used (print is a macro in Rust that generates code at the callsite), etc. Most, if not all, of these can be resolved.
See https://github.com/johnthagen/min-sized-rust https://github.com/johnthagen/min-sized-rust for aiming for small binary size.
This article shows a 93% size reduction, 2.7m -> 200kb, with some relatively simple modifications https://www.collabora.com/news-and-blog/blog/2020/04/28/reducing-size-rust-gstreamer-plugin/ https://www.collabora.com/news-and-blog/blog/2020/04/28/redu....
Here is someone using Rust for a 3kb demoscene program https://www.codeslow.com/2019/12/tiny-windows-executable-in-rust.html https://www.codeslow.com/2019/12/tiny-windows-executable-in-....
- mhh__ 6y agoD is usually dynamic although I try to be static for the most part. IIRC The runtime is linked statically (or not at all) but Phobos is dynamic by default Rust compiles seem to blow up pretty easily, e.g. I was cleaning out my SSD the other day an I noticed that a rust GUI framework (Iced?) was sat on about 2Gb of dependencies despite being significantly incomplete (but very promising)
- destructionator 6y ago> Phobos is dynamic by default That depends on your distro. The packages from dlang.org all do the static link config out-of-the-box, but some distro packages dynamic link by default instead. Given the size of that file, it looks static linked. It dynamic links libc, pthread, and a couple other OS-level things, but all D libs including druntime, phobos, etc, are statically linked. Might just be difference in dependencies.
- PudgePacket 6y agoOh boy I definitely understand you, in fact I built a Rust CLI tool to solve exactly that ;) https://github.com/tbillington/kondo https://github.com/tbillington/kondo
- eggy 6y agoThe 3kb demoscene example is just to open a window, not a full, self-contained 64k demo in 3kb. Is the program basically calling the Win API through unsafe functions? I am trying to learn Rust, and I am wondering how it might actually be used here or more beneficial than C in this case if it is all done "unsafe"? I am still comparing Zig and Rust to see which I am going to go with. I don't think I'll ever give up C though.
- steveklabnik 6y agoThat post is, but https://www.codeslow.com/2020/07/writing-winning-4k-intro-in-rust.html https://www.codeslow.com/2020/07/writing-winning-4k-intro-in... is a 4k demo. And yes, a lot of it is unsafe, because it's calling into all of that stuff directly, and doing pointer arithmetic, etc. Check the post, it's good, the Conclusion section talks about this specifically.
- littlestymaar 6y ago> I am still comparing Zig and Rust to see which I am going to go with This is really puzzling to me: in what context are you working to have hesitations between Rust and Zig? One is a production language, the other is an exciting experimental language mostly written by a single genius. Go for Zig if you want to have fun, and Rust if you want to actually build something. It's like hesitating between Kotlin and Idris!
- deckarep 6y agoHaha at: written by a single genius. And so true.
- eggy 6y agoFor a low-level, systems programming language it really comes down to Rust and Zig if you are migrating from C. I like Idris, but I don't see it in this category, nor Kotlin, although Kotlin Native perhaps? Yes, Zig is exciting! I find it easier than Rust and I have given both equal time so far.