3 ms·
On the other hand, I'm rather surprised that the Go version is almost as long and opaque as C.
by moffkalast 4y ago
On the other hand, I'm rather surprised that the Go version is almost as long and opaque as C.
- benhoyt 4y agoAre you looking at the "simple" or the "optimized" versions? For the optimized, yes, the Go one is very similar to the C. For the simple, idiomatic version, the Go version [1] is much simpler than the C one [2]: 40 very straight-forward LoC vs 93 rather more complex ones including pointer arithmetic, tricky manual memory management, and so on. [1] https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc30a9c95226575df1e5e1c5a/simple.go https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc... [2] https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc30a9c95226575df1e5e1c5a/simple.c https://github.com/benhoyt/countwords/blob/c66dd01d868aa83dc...
- moffkalast 4y agoYeah I meant the optimized versions.