PSA: Porting between languages - UNIX vs. Windows

in #programming7 years ago

PSA for all of you newbie programmers out there that are jumping between operating systems/architectures:

If you code something to run on UNIX, don't assume that it will run the same on windows.

Did you download Python on the interwebs? Think that this makes it portable? You're wrong.

pythonLogo

YOU'RE WRONG. DAMN IT.

Even if you download a language, each system has its own set of system calls, and loads of other nuances.

Case and point:

You're working in Python. It's an awesome, interpreted language. Slower than C++, but easier to work with.

You're coding a little robot for a personal project (lots of consumer robots can run on Python, in case you're interested in tinkering, such as the Cozmo).

ubuntuLogo

You want your robot to have a simulated timer, so that it stops moving after a set period of time.

Since you're working on a Mac (good for you), you decide that using a signal call to set an alarm to stop movement would be perfect (signal.SIGALRM to be specific).

And it works. Perfectly.

Until your code is ported to a PC that doesn't run off of UNIX, and signal alarms don't mean jack diddly shit.

windowsLogo

It takes you a little while to figure this out (you're new - you thought that signal calls worked on all machines), and after all of that, you now need to figure out another way of doing things.

So you set up a loop to decrement a counter to stop the robot from moving. Or maybe you dabble with threads and see if a sleep command can work (ha, good luck setting up that nightmare).

Point being: you wasted a ton of time because you didn't read the documentation about the calls, or IDE that you used (don't get me started on VS C++ versus Xcode or whatever other IDE you're using - those C++ #includes can really get dodgy, depending on what you're doing).

How can you avoid this? You can't. And if you think you can, prove me wrong in the comments below!

Sort:  

Great. Thanks for sharing. I vote for you and begin to follow you. And Resteemed...

Thanks! Happy coding.

Coin Marketplace

STEEM 0.25
TRX 0.20
JST 0.036
BTC 94901.35
ETH 3495.37
USDT 1.00
SBD 3.47