Re:C to Go translation tool supporting Go toolchain migration
by azernik on Tuesday January 20, 2015 @03:15AM
(#8915950)
For the casual reader, in case other comments don't make this clear - this is not a general-purpose translation library, and probably will not work for whatever C codebase you have. It is a one-off tool built to migrate the specific subset of C used in the original go compilers, as part of the process of making the go toolchain self-hosting (go compilers written in go).
This translator produces a VERY literal translation, as the intention is for future human passes to clean it up and convert it to more idiomatic go.
Re:C to Go translation tool supporting Go toolchain migration
by kanwisher on Tuesday January 20, 2015 @02:37AM
(#8915846)
Would be nice if this could be made into a more general tool, would be a cool way to modernize older libraries and reinvigorate new development into them
Re:C to Go translation tool supporting Go toolchain migration
by rsc on Tuesday January 20, 2015 @09:49AM
(#8917141)
I'd certainly be happy if someone wants to do that. I'm not planning to. For this kind of thing my instinct is that the delta from "useful tool that gets you 90-99% of the way there" to "general tool that just works" is at least 2x if not 10x the effort. For what I'm doing, the 90-99% is fine and then I can fix the rest by hand.
Re:C to Go translation tool supporting Go toolchain migration
by dsymonds on Tuesday January 20, 2015 @02:49AM
(#8915880)
That's been proposed, but it won't happen. There's too many edge cases, and it only works on the Go compiler because it has a particularly constrained style and rsc can make the relevant hacks as a one-off effort.
Re:C to Go translation tool supporting Go toolchain migration
by marco2357 on Tuesday January 20, 2015 @09:02AM
(#8916934)
Why not? There's not that much of a difference between translating C to assembler or a high level language like Java/C#/Go. The main challenge is to make the code readable.
But basically someone just has to sit down and do it right.
Re:C to Go translation tool supporting Go toolchain migration
by lmm on Tuesday January 20, 2015 @03:33AM
(#8915979)
Most libraries that are still in C are in C so that people can embed them from many languages, or because they need to be used in scenarios where GC is unacceptable. I don't think many libraries that have remained in C (and not used e.g. D, or OCaml, or Haskell) will be suitable for migration into Go.
Re:C to Go translation tool supporting Go toolchain migration
by 4ad on Tuesday January 20, 2015 @05:48AM
(#8916336)
I already reused part of this a few months ago to automatically refactor a large body of C code (around 10k LOC)[1]. Some time ago, Go converted (by hand) the various Plan 9 linkers used into a library, and I had to do the same for the arm64 linker.
I'm not sure if I saved time or not (I think I did) for the effective work, but I definitely saved time (and stress) overall, as the conversion was without bugs. I know for sure that I would have introduced a lot of bugs if I did this manually.
Tools that understand source code are great, and I'm really excited about the new Go compilers.
This translator produces a VERY literal translation, as the intention is for future human passes to clean it up and convert it to more idiomatic go.
See here for the full plan: https://docs.google.com/document/d/1P3BLR31VA8cvLJLfMibSuTdw...
[1] http://talks.golang.org/2014/c2go.slide#1
[2] https://www.youtube.com/watch?v=QIE5nV5fDwA
"Goal: Automated conversion of our C code to Go. Target: our C code, not all C code."
Nice to see that somebody knows how to dig through history.
Some demos are available on his page: https://www.mtsystems.ch
This work is based on the stuff he did for his PhD. I think his largest test case so far is a full translation of VIM.
I'm not sure if I saved time or not (I think I did) for the effective work, but I definitely saved time (and stress) overall, as the conversion was without bugs. I know for sure that I would have introduced a lot of bugs if I did this manually.
Tools that understand source code are great, and I'm really excited about the new Go compilers.
[1] https://code.google.com/p/rbits/source/browse/7lfix/main.go