logoalt Hacker News

JonChesterfield07/31/20253 repliesview on HN

One could presumably compile arbitrary C++ to rust or D without changing semantics, then slowly go through the result making it look more native to the new language.

That would either be a wholesale conversion or emitting a translation shim style thing at the boundary between legacy c++ and the new language.

I'm not sure Carbon is necessary to achieve such a conversion.


Replies

zem08/01/2025

I would be stunned if you could compile arbitrary c++ to rust or d, unless by "compile" you mean "painfully hand-translate and spend months fixing subtle errors". you are underestimating the sheer complexity of the language.

show 2 replies
nicwilson08/01/2025

This was essentially how DMD (the reference D compiler) was translated to D. However this was mostly a restricted subset of C++ common to both of them, e.g. no diamond inheritance, no operator overloading whackiness.

miguel_martin08/01/2025

Nim would be the best choice for this at the moment, imho

importcpp what you need. exportcpp for the other way around