Hacker News new | ask | show | jobs
by _gabe_ 1401 days ago
This is all that it took me to port a fairly sizeable code base to Linux[0]. This commit allowed me to run the app with the only problem being some font issues that I needed to fix by modifying how I used a library.

The total:

> Showing 26 changed files with 255 additions and 90 deletions.

If you architect your code well, porting between different systems shouldn't take anymore than a few hours ;)

Edit: I just looked through the diff and remembered that the bulk of these changes was fixing warnings that surfaced from using a different compiler.

The actual code that I changed necessary to get this running on Linux was in File.cpp and consisted of 124 lines of code. Going the other way (from Linux to windows) would have been just as simple, I just would have added the code in the __WIN32__ macro block instead of the code in the __linux__ macro block.

[0]: https://github.com/codingminecraft/StreamMinecraftClone/comm...

1 comments

A small game is not even remotely comparable to an average programming language.
It really isn't that much different though. After skimming through the source code of Zig, you can see that well over 90% of the code is OS independent.

Not only that, it looks like they do have windows support and it's just failing atm. It also looks like they have cleanly separated all OS functionality from the logic. This is where it looks like the majority of the OS dependent code lives[0], and the implementation for this is 1000 lines of code. So clearly, it looks like it shouldn't take more than a few hours to get even a programming language up and running when porting it.

Further, it looks like they're using the cpp stdlib to assist with some OS dependent functions[1]. They're clearly using at least:

* std filesystem

* std future

* std iostream

* std mutex

* std thread

* std atomic

And more. So if you're being smart about things, which it looks like the developers most certainly are, then you don't need to reinvent 90% of the OS dependent code and can instead use the stdlib that already exists to automagically get that functionality.

[0]: https://github.com/ziglang/zig/blob/master/src/stage1/os.hpp

[1]: https://github.com/ziglang/zig/blob/a9c4dc84f487c4764c578743...