Write Once Debug Everywhere

When I was just starting out in the field of Software Engineering there was only one player I needed to concern myself with: Windows XP.  In a way, those were the days.  I didn’t have to worry about how my code would behave on this platform vs. that.  Because of the common operating system my software, just worked, or didn’t because the platform it was running on was the same.

Vista was a myth in my world but then came Windows 7 and I had to encounter User Account Control.  This was tricky problem for the company I worked for because, by design, we stored all our data in globally accessible Memory Mapped Files.  Problem was you needed elevated privileges to create Global file mappings and that was not a guaranteed condition we could expect. So, we began to make some changes…

I doubt I could count how many platforms and environments I have to worry about now during development as they include ranges of web browsers, operating systems with varying endian-ness and word sizes.  Some are bigger troubles than others but by golly they’ve left me nostalgic for the consistency and stability of my XP days.

The most nefarious of the issues today is this idea of being able to write code in one language and compile it across platforms and have it just work.  Java comes to mind, as the JVM is implemented across several platforms.  It was also in regards to Java that I first heard the statement, “Write once debug everywhere.”  Well, I recently hit the same thing with Xamarin and building for Windows Vs. iOS.

My management loves the idea of Xamarin and its promise of write your C# code once and have it run anywhere.  It’s great in theory.  But again, what’s the difference between theory and practice?  In theory nothing in practice everything.  Fact is, when you change the environment software is operating in you are likely to change it’s behavior.  This is true for JavaScript, Java and Xamarin.  To be fair C ends up with issues too (I’m looking at you stricmp and strcasecmp) but at least in the C case, and in my anecdotal experience, they’ve been things that end up not compiling which is a different class of errors to those that break at runtime.  Those runtime errors are the buggers too cause you’re left with problems of trying to write something that will make all platforms happy which can be quite a daunting task.  Then you get cascading consequences of making changes and the bug count begins to rise.

I don’t like repeating myself so I don’t like it when I have to do the same job only for platform “X” this time in the language of platform “X”.  Yet, there are advantages, such as being able to use the affordances of platform “X” without regard to platforms “Y” and “Z” and that’s nice.  And being able to change one platform without worry of breaking another because the code bases are separate.  I guess my point is, as with most tools, shared code across platforms is no Silver Bullet.