Are you a Swifty?

To prove I'm a real boy, Sal is built in Swift. Oh my gosh, just like... shut up.


AAAAhhhh.. Yes. Cats versus dogs, pineapple on pizza, toilet paper orientation, vi versus emacs (search one Google and it will suggest the other): the age old debates... What programming language is best? Well of course, you know, it depends on the project and the programmer and their experience and their preferences and the weather and the answers to some of those other debates. Why choose Swift?


Its not the common choice; that's for sure. Swift is ranked 20th on the stack overflow developer survey. Of these swifties, a none trivially large number of which are iOS developers. There is no mention of AI, data science or the like. The top three were JS, HTML, and Python. Because Sal was never going to be website, I'm ignoring JS and HTML. 

Python fits the mold for my application perfectly as it is the language synonymous with deep learning. It's popularity gives me access to tons of people and examples when I need... HELP! As a result, every single machine learning library is written to support Python and give it first class treatment. It's easy to use, its simple, and its going out of style as the cool kids say.

Many engineering choices made early on give python a double edged sword: loose object definitions. This choice defines its strength, its simplicity, as well as its downfall, speed. Python is SLLLOOOWWW. Most libraries end being constructed in two languages to compensate. All the fast, under the hood code is written in C/C++ and the easy, surface level APIs are written in python. Because Python has almost no commonalities with C/C++, their shared occupation in a given codebase sparks trouble. 

Swift, on the other hand, presents itself as one of the best, feature rich modern programming languages. It presents a lot of lower level systems programming features like optional types, closures, generics, strong types, protocols, structured concurrency, and more in a easily implementable fashion. One gains a certainty and solace knowing that their software is built in a more systems level programming language in the same way one gains certainty knowing their country's military is built with people who follow the rules. Sal needs to 'just work.' I could go further by using a more strictly typed language like Rust or Zig but there are some diminishing returns. With Swift, I benefit from 'single language productivity' which is just synonymous with specialization. Its features are fantastic and would allow me to be a real boy, but my appraisal encompass a fraction of the story. 

The afore mentioned Python has acquired and ecosystem and a following that isn't easily recreated. Millions of people use it for learning as well as production code. Other than Mac and iOS apps, Swift's following falls far behind that of Python, JSs, and like 18 other programming languages. Not a single machine learning library or framework is written for Swift. An opportunity and a challenge.. hmm...

Swift has a lovely trick up it's sleeve: seamless integration with C/C++ codebases. Without going into details, the nerds that made and maintain the C/C++ compiler* also made Swift. Both have be constructed to talk to each other in a manner that removes the 'bridge' associated with Python and C/C++. Knowing this wonderful feature, Python can be removed from the stack entirely and Sal has been written Swift and C/C++ ONLY, making him more performant and reliable.

*There are two major C/C++ compilers: Clang and GCC. I'm referring to Clang which is based on LLVM - the same as Swift*

Comments