-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Gradual Migration Rather Than Rewriting


Continuing from my last post, I've been daydreaming about migrating existing software from C/C++ to something safer. Importantly, I want to avoid ab-initio rewrites and gradually migrate an existing codebase.


I learned that Modula-2 (and Object Pascal) require manual memory management, so won't satisfy my requirements. D is the next oldest language, and it has had some recent improvements:


There is a "betterC" mode where the compiled code doesn't need any runtime support, suitable for linking into a majority-C program. At the cost of a lot of advanced features, but this doesn't matter for porting C code.

This can be used to port software, one function at a time, from C. Tests run after each change to prevent regressions.

Once this has finished, you could switch betterC mode off again and use D-specific features like OO and GC.


Converting C to D


I did try to get something similar for Go to work, but failed. And even though it's impressive, I think Rust's semantics are so different that a rewrite would be required.


c2go


So I've been learning D (or at least the subset needed to do the above). Looks straightforward so far, at least compared to Rust. Although I prefer ISLisp, sometimes you just need to bang bits ...


Back to my gemlog

-- Response ended

-- Page fetched on Sat Jun 8 00:07:04 2024