News for hackers. Stuff that matters.
Re:Rust vs. C++ Formatting by atq2119 on Monday January 16, 2023 @06:02PM (#34406700)
Rust's print! implementation is pretty darn complicated, wouldn't you say?
Re:Rust vs. C++ Formatting by xigoi on Monday January 16, 2023 @06:17PM (#34406864)
Re:Rust vs. C++ Formatting by elcritch on Monday January 16, 2023 @06:36PM (#34407063)
The magic that makes Nim’s print / repr functions really neat is the `fieldPairs` iterator that works on any type. It’s a comptime function to iterate fields of a type, very handy and very simple to use. It can work on any type unlike Rust’s Debug macro which only works on types you own and can annotate.

https://nim-lang.org/docs/iterators.html#fieldPairs.i%2CS%2C...

Re:Rust vs. C++ Formatting by forrestthewoods on Monday January 16, 2023 @06:20PM (#34406901)
I don't know what Rust's print! implementation looks like. I also don't care. I am not a Programming Language programmer. I am a user of programming languages.

Using C-style printf sucks balls. It's extremely error prone and it doesn't support complex types. Using Rust's print system is delightful. I can't make a type error and arbitrarily complex types can be printed with roughly zero effort via {:?} and #[derive(Debug)].