this post was submitted on 19 Jan 2026
0 points (50.0% liked)
Rust
7684 readers
17 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Depending on what you mean by "generate code", the only language at the level of C or C++ that I can think of that does this is Zig. Zig is weird though because you're still doing what is functionally compile-time reflection, so in a way you're still generating code, just in a different way.
If you're comparing to Python, JS, or even C#, those all come with runtimes that can compile/interpret new code at runtime. None of those languages are comparable here. Rust, C, C++, Zig, etc compile into assembly, and type information, impl information, etc are all lost after compilation (ignoring symbol names or anything tracked as debug info).
If you're specifically referring to Debug, Display, PartialEq, etc then the compiler doesn't do that for you because Rust doesn't assume that those traits are valid for everything.
Unlike Java where
new Integer(1) != new Integer(1)or JS where"" == 0, Rust requires you to specify when equality comparisons can be made, and requires you to write out the implementation (or use the derive for a simple, common implementation).Unlike C# where
record class Secret(String Value);will print out the secret into your logs when it inevitably gets logged, Rust requires you to specify when a type can be formatted into a string, and how it should be formatted.Just because a language does things one way doesn't mean every language ever should do things that same way. If you want it to work like another language you like to use, use the language you like to use instead. Rust language designers made explicit decisions to not be the same as other languages because they wanted to solve problems they had with those languages. Those other languages are still usable though, and many solved the same problems in other ways (C#'s nullable reference types, Python's type hints, TypeScript, C++'s concepts, etc).