Are there hidden dangers in converting golang code to Odin?

I am porting a golang library to Odin. The library does not use goroutines or any advanced golang features. I find that code is quite easy to port:

  • a lot of code can be copy-pasted verbatim as the syntax is 90% the same
  • function signatures and type definitions require minimal fixing
  • porting tests is also easy as testing package is very similar

I made some good progress so far but I wonder if I should expect dragons to come at me some time later? I might be carried away by syntax similarities and miss some crucial language differences. Or if tests are passing everything should work fine?

I wonder what experts think.

They are very, very different languages…

Bare minimum is to use the tracking allocator in your tests, after all there’s no GC so it’s very likely that you missed a lot of the clean-up code.

Also, since Go has no concept of custom allocators, probably none of the API cares/exposes where you allocate, or if types supposed to know their allocators or not… So, I guess now all is good, but the moment you start mixing allocators with a port that assumes context.allocator everywhere you’ll have a hard time…

2 Likes

Not an expert, but basic advice: Build with -debug -sanitize:address enabled when developing always so that any dragons that are coming out are caught early on. Also use the tracking allocator

2 Likes