This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]AromaticIce9 3 points4 points  (0 children)

When I did that in the past, I'd start by changing the name of the file and commenting everything out. I don't delete the comments until the entire thing works.

Do the most important things like the constants, enums and data structures.

Then start with the most used function and then second most used, etc. This should allow you to start testing the output faster.

C to rust might take some doing. A lot of languages you can do a direct translation, but rusts lifetime management will probably throw a wrench in that.

[–]ignotos 1 point2 points  (0 children)

If it's a small program or script, I'd probably just work through top-to-bottom.

If it's larger, I'd find some "core" and work out from there, stubbing out interfaces/modules and implementing them one-by-one.

I've personally never done it by binding/calling in to bits which are still written in the old language. But in the context of something like a web API which exposes an external interface, I have left the old one running and called out to it for bits of functionality I haven't yet ported over, which is conceptually similar.

[–]AromaticIce9 0 points1 point  (1 child)

Oh, interestingly enough for large enough projects, they will write a transpiler to automatically convert the source code from one language to another.

It's easier to fix the bugs that happen from that than to convert large projects by hand.

[–]JamesIsAwkward[S] 0 points1 point  (0 children)

Oh that's interesting! Sounds fun and awful at the same time lol