What it is: Safe code describes programming languages designed to minimize common programming errors.
It’s no surprise that most people are familiar with computer glitches, crashes, and failures. Part of the problem stems from programmer errors, but a large part of the problem stems from the type of programming language developers favor. For the past decade, most developers favored C and variants such as C++.
Both C and C++ are powerful programming languages designed for maximum computer efficiency and versatility. Unfortunately, that also means that C and C++ completely neglect human efficiency and safety. The sole goal of C/C++ is to be the most versatile and most powerful programming language around, and it’s succeeded. Nearly every major operating system (Windows, OS X, Linux) and program (Microsoft Word, Adobe Photoshop, AutoCAD) were created using C/C++. Programs created in C/C++ tend to be small and fast, which is exactly what you need in programs such as operating systems.
Back in the early days of the Macintosh, Apple actually bucked the trend towards C/C++ and developed the original Macintosh operating system on Pascal. Apple chose Pascal over C/C++ specifically because Pascal was one easier programming language to read and modify, and because it offered safety in preventing programmers from making common errors that even professional programmers make all the time. The huge drawback with Pascal was that it was designed for maximum human efficiency with computer efficiency being secondary. That meant that the same program written in C/C++ would run much faster and take us far less space than the same program written in Pascal. Not surprisingly, the original Macintosh operating system was slow. Apple later abandoned Pascal in favor of C/C++ specifically because C/C++ programs ran faster.
So the decade’s past memory of program crashes, failures, and glitches stems mostly from the world’s use of C/C++ for practically every major program from operating systems and word processors to banking programs and spreadsheets. The reason why so many bugs occur in major operating systems like Windows all the time is because C/C++ makes it surprisingly easy to make mistakes. The philosophy of C/C++ is to give programmers maximum versatility in exchange for forcing them to avoid making errors. Since it’s impossible to expect anyone to avoid making errors, C/C++ allows common programming errors to blossom into major bugs that infest practically every major program.
To maintain the advantages of C/C++ while eliminating many of its disadvantages, Microsoft developed C# while Apple developed Swift. The adoption of these two programming languages will go a long way towards creating more reliable software in the future. If you’re a developer planning to write a new program, avoid C/C++ and choose a safer language like C# or Swift instead.
Apple made Swift open source so although it’s still primarily an OS X/iOS development language, it’s starting to broaden its appeal to allow writing programs for Linux, Windows, and Android. Microsoft still controls C# but they recently purchased Xamarin, a development tool that allows developers to write iOS, Android, and Windows programs using C#.
So if you’re currently a Windows developer, learn C# and you can leverage your programming skills to create iOS and Android apps, or Windows programs. If your’e currently an Apple developer, learn Swift and you can create watchOS, tvOS, iOS, and OS X programs.
Swift is still primarily an Apple development tool and C# is still primarily a Windows development tool, but both programming languages are gradually supporting other platforms. The good news is that either C# or Swift will help bring about a new era of reliable, less error-prone software.
That means today’s software, built on the creaky foundation of C/C++ code will eventually need to be replaced. Microsoft has done an amazing job constantly updating Windows, but the bulk of Windows is written in C/C++. The more C/C++ code there is, the harder it will be to modify and debug. Eventually Microsoft is going to run into a dead end where modifying and fixing problems will become prohibitively expensive in both time and money.
Already mission-critical software like avionics programs avoid C/C++ completely and rely on Ada, a safe programming language influenced by Pascal. Besides avionics companies like Boeing or Airbus, banks have also adopted Ada because they need software that can run reliably. With languages like Ada, C#, and Swift, human efficiency has finally risen above computer efficiency in importance.
So expect tomorrow’s software to be more reliable and expect today’s software to eventually stagger along until it’s no longer worth it to modify and improve any more. This might take decades (witness the large use of COBOL and FORTRAN still), but eventually newer programs will be written in safe programming languages, and that just means a safer, less frustrating experience for all computer users.
To read more about Xamarin’s push towards supporting Windows, iOS, and Android, click here.
