Re:Why Rust helps even if you have to use a lot of `unsafe`
by lostdog on Wednesday August 02, 2023 @12:37PM
(#36973241)
Try representing JSON in C++. Sure, you can figure out a way that works, but the C++ code for printing out the JSON is much uglier than a language with tagged unions.
[ Parent
| on HN ]
Re:Why Rust helps even if you have to use a lot of `unsafe`
by pjmlp on Thursday August 03, 2023 @02:14AM
(#36982048)
That is a consequence of lack of reflection, not sum types.
Re:Why Rust helps even if you have to use a lot of `unsafe`
by ansgri on Thursday August 03, 2023 @02:51AM
(#36982267)
sum types can often eliminate the need for reflection, and can have lower runtime cost.
Re:Why Rust helps even if you have to use a lot of `unsafe`
by pjmlp on Thursday August 03, 2023 @04:13AM
(#36982824)
Compile time reflection doesn't have runtime cost.
Re:Why Rust helps even if you have to use a lot of `unsafe`
by lostdog on Thursday August 03, 2023 @01:14PM
(#36988722)
Compile time reflection doesn't work for this case.
Re:Why Rust helps even if you have to use a lot of `unsafe`
by pjmlp on Thursday August 03, 2023 @01:38PM
(#36989087)
Template metaprogramming techniques as poor man's reflection prove otherwise.
Additionally that is one of the examples on the ongoing C++ reflection papers.
Then there are a couple of examples in D, Common Lisp, Scheme, C# code generators.