News for hackers. Stuff that matters.
Re:Experience porting 4k lines of C code to go by homebru on Tuesday June 21, 2011 @03:55PM (#2680136)
So, why didn't you write a parser to convert your C code to Go?
Re:Experience porting 4k lines of C code to go by kkowalczyk on Tuesday June 21, 2011 @04:25PM (#2680251)
(the author of the article here).

One, this was an opportunity to learn Go.

Two, writing a converter is way above my head and quite likely theoretically (and practically) impossible. I've definitely had to make some decisions that I don't think even the cleverest compiler could (like noticing that array.[c|h] and buffer.[c|h] could be replaced with native Go arrays/slices easily so I didn't have to port that at all, just change the callers to Go equivalents).

Re:Experience porting 4k lines of C code to go by alttab on Tuesday June 21, 2011 @10:55PM (#2681479)
I interpreted his comment as "it doesn't look like you learned Go."

If you are porting direct C logic to Go you could be missing a lot of potential idioms that could differentiate Go from C or python further. You said yourself it was easier to implement parsing with slices.

I think a more effective task is "understand what the 4k lines of C do, and then throw it away and re-write it as if it was written in Go in the first place." Your miles may vary.

Re:Experience porting 4k lines of C code to go by nvictor on Tuesday June 21, 2011 @04:37PM (#2680294)
I am impressed with the AppEngine version of our beloved (now dead) JoS forum. Great job.
Re:Experience porting 4k lines of C code to go by kristianp on Tuesday June 21, 2011 @09:19PM (#2681201)
Re:Experience porting 4k lines of C code to go by scott_s on Tuesday June 21, 2011 @04:26PM (#2680256)
I think you mean compiler - a parser just outputs an AST. Anyway, while some of the transformations are probably mechanical, I imagine that the semantic analysis required to recognize the C implementations of a growable array would be more effort than just doing it by hand.
Re:Experience porting 4k lines of C code to go by gte910h on Tuesday June 21, 2011 @03:59PM (#2680148)
The point is to learn the language...I don't see writing an automatic converter in a non-go language a good way to learn go.