Go is so close to C. Wouldn’t it be great if there was a program that could take C code and turn it into Go code?
There are few attempts to do that:
elliotchance/c2go seems to be the most promising.
I didn’t try any of them as neither seems to be usable yet.
Actually, we used rsc.io/c2go to port our Go compilers and linkers from C to Go. It was 100% mechanical translation. No manual steps needed to achieve correctness.
They work very well. The code produced is not very idiomatic Go, but it’s not some monstrous impenetrable computer generated code either. It’s quite similar to the original C code and it’s readable and refactorable enough. After we converted the compiler from C to Go, we spent a lot of time to make the code more idiomatic (still ongoing).
github.com/cznic/ccgo was used to port sqlite to Go[2,3]. It passes the (very comprehensive) sqlite test suite.
First of all, great work. But I want people to keep in mind that the whole point of Yoga being written in C is for it to be used across many languages (Java, C#, Objective-C, Swift…) through an FFI. It’s a single codebase that’s fast and well maintained.
Url is wrong, missing slash between info and article
huh, must have been changed by the title grabber (it also grabs the canonical URL).
Yep. I told the author on twitter but sadly can’t fix the link on lobsters without help from a moderator.
<link rel="canonical" href="https://blog.kowalczyk.infoarticle/wN9R/experience-porting-4.5k-loc-of-c-to-go-facebooks-css-flexbox-implementation-yoga.html">