by forrestthewoods · 1y ago · 0 comments
STOP WRITING NON-PORTABLE CODE YOU BASTARDS.
The correct answer is, as always, “stop using mutable global variables you bastard”.
Signed: someone who is endlessly annoyed with people who incorrectly think Unix is the only platform their code will run on. Write standard C/C++ that doesn’t rely on obscure tricks. Your co-workers will hate you less.
Until your boss tells you to port your so-far Linux-only code to Windows, and you run that struggle.
Signed, someone who spent the past year or so porting Linux code to Windows and macOS because the business direction changed and the company saw what was the money-maker.
P.S. Not the parent commenter, because I just realised they, too, had a paragraph beginning with 'signed, ...'
I.e. - I have tried WSLg (running GUI apps in WSL) but disabled it all together, as after running xclock and couple of things like that to ensure it works, I couldn't find any interest in running GUI apps on Linux.
I can somewhat imagine need for work purposes, if you are falling into some webdev area and need to run some tests against local browser, but that's different from my POV.
Deep interaction with Linux filesystem and kernel behaviour; we've done some intercepting and trampolining Linux syscalls in run-time, and tying it all up to cloud storage APIs.
We had to fundamentally re-architect some of our code to support macOS and Windows.
The technical requirement of installing WSL before installing our software was already a non-starter, since most Windows users expect one installer or zip to do-it-all. WSL2 isn't (yet) like a C/C++/DirectX redistributable which can be plugged in as a dependency to a given program. Additionally our program is expected to work natively with Windows paradigms.
More critically, we work with high-performance filesystems. The performance impact of files going a round-trip through the Linux Plan9 driver, then through a Linux kernel context switch, into the kernel, and down into Hyper-V, and then up back through the Windows Plan9 driver was completely unacceptable. It was deemed worthwhile to rewrite targeting Windows natively. And even then it was only a partial rewrite: we ended up using MinGW because we had too much of a direct dependency on the pthread API.
If you only support WSL then you don’t support Windows, imho.
This has bitten me once when I was doing a distro upgrade and windows just killed the WSL vm midway.
My background is video games. Which is well known to be a Windows-first environment. I currently work on robotics. The vast majority of robotics ecosystem code is Unix only.
You know what is extremely useful for teleoperation? Virtual reality. You know what platform doesn’t have a way to do VR currently? Linux. Womp womp sad trombone. Mistakes were made.
It’s really easy and not hard to write crossplatform code. My experience is that Linux devs are by far the most resistant to this. It’s very annoying.
Should you care about Windows? I certainly think so. Linux still doesn’t have a good debugger (no, gdb/lldb) aren’t good. Quite frankly every Linux dev would be more productive if they supported Windows where debuggers exist and are decent. So really they’re just shooting themselves in the foot. IMHO.
So I spin up a Debian VM and POSIX the hell out of it. If they dare to complain, I tell 'em to do their damn jobs and not leave all the hard stuff to the guy that only programs on UNIX.
Sure, I could learn to program on Windows... Or I could pick up another PLC or SCADA platform that looks good on my resume. Guess which I choose to do?