1. 5

  2. 2
    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[1]. 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.

    [1] https://golang.org/doc/go1.5#c

    [2] https://godoc.org/github.com/cznic/sqlite

    [3] https://github.com/cznic/sqlite

    1. 2

      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.

      1. 1

        Url is wrong, missing slash between info and article

        1. 1

          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">