One of the fun things about Apple’s new programming language “Swift” is the hate it gets from academics and lovers of existing languages like Java and C#. In truth, when you look at Apple’s requirements, they had little choice but to create something like Swift. I thought I’d review some of those requirements.
Objective-C is dead: Buffer-overflows have made all C-based languages obsolete (C, C++, Objective-C), but also, that bizarre SmallTalk syntax had to go.
Academic languages suck: The top 10 languages programmers use were created by other programmers, not university professors in their ivory towers. Academic languages like OCaml aren’t viable choices for Apple.
C Syntax is a must: While getting rid of pointers, any new language still has to follow C syntax – the syntax that 99% of programmers know and are comfortable with.
A stable language: New-fangled languages like Rust, Dart, and Go are rapidly changing. Had Apple picked one, they would’ve frozen it then forked it – a worse sin than creating a new language. In many ways, Swift is a fork of Mozilla’s Rust language.
Objective-C compatible: Customers/developers have already made a huge investment in code. Again, this almost demands a new language – one that can be called from and can call into Objective-C. Swift does this surprisingly well, Java/C# can’t do this at all.
It happened at reference-counting: Apple chose reference-counting instead of garbage-collection for Cocoa and Objective-C. Once that decision was made, they effectively took Java and C# out of the running, forcing the creation of a new language
Debugging, debugging, debugging: Academics hate good debuggers, using them only as a last resort to fix bugs. Professionals use them routinely, to debug even working code, to double-check and understand it. Swift’s “playgrounds” are a huge innovation in such debugging.
Compile all languages: We used to have this hierarchy of languages, compiled interpreted, and p-code. Now all languages are compiled/JITted. This has allowed Swift to be simultaneously a “compiled” programming language and an “interpreted” scripting language.
At least you got functional: Academics hate imperative languages like C, but love functional languages like LISP. After three decades, it appears functional concepts are finally making it into mainstream languages, including Swift. This pisses me off, because I hate academics so very much. Functional programming is okay, though.
I write this blog post in reaction to this Slate article, where a left-wing complains about Apple being individualistic instead of collectivist in supporting an existing language like Java. It’s a truly silly article. Apple has hard requirements. Apple can no more ignore their legacy than Intel could ignore x86 compatibility. Something that looks an awful like Swift is Apple’s only solution.