Code Review: Swift

Travis Weninger
8 min readDec 3, 2021

--

Swift was announced at WWDC in 2014

Swift is a programming language created by Apple to develop applications for iOS and other Apple devices. Having launched in 2014 it is a relatively new language and is open source. Initially, Swift was released as a proprietary language for Apple and has since gone through many revisions. Swift allows for procedural or object oriented programming and is considered easy to write/read, expressive, and safe. What makes Swift a popular programming language is that it is a very accessible language to learn and start developing with. If you already own a mac, everything you need to develop an iOS app using Swift is free, developers just need to know where to download the tools . The only things required to start building projects are Xcode, Swift, OSX, an IDE (integrated development environment), and an iPhone/iPad simulator.

Apple announced Swift at their World Wide Development Conference (WWDC) in 2014. In their launch presentation Craig Federighi, senior vice president of software engineering stated that Apple was trying to build a programming language that didn’t have the baggage of Objective-C. Objective-C is another programming language created by Apple, which would be succeeded by Swift. The presentation at WWDC got bigger cheers from the crowd of developers than any other announcement that was made at the conference. Apple followed up their presentation by releasing a 500 page guide on how to use the language in their iBook store.

Although Swift is still a young language it has gained massive popularity in a very short amount of time. Swift was developed as a replacement for Apple’s earlier programming language Objective-C and has quickly over taken it in the development world. Swift now ranks in the top ten for programming languages among developers. This makes it the fastest growing programming language since rankings started in 2011. When Apple launched Swift their primary goal wasn’t just to make programming easier for beginners but to also make life easier for experienced coders . Swift aimed to combine programmer friendly features with performance and appears to have been successful in doing so.

Swift’s popularity is not only in the Apple fandom but throughout the industry as whole. In 2017 Google was accused of making a carbon copy of the Swift programming language and modifying it into their own product but this turned out to be a misunderstanding. Google had copied Swift so that it could make its own contributions to the language, not to rip it off. Google uses Swift to build internal tools to help with the creation of iPhone and iPad apps. In 2016 Google was considering making Swift one of their preferred ways for developers to build Android apps, however they chose their preferred supported language Kotlin instead. Due to Swift being open source, the language is not proprietary to iOS it has been customized for Linux and Android as well. Swift has been widely adopted by the tech industry within large companies like IBM, Lyft, LinkedIn, and Airbnb supporting and developing Swift systems. Developers praise Swift because it uses a newer, simpler, and cleaner syntax which leads to faster code creation and control. This reduces the amount of SDK class reference data, making memory usage much more efficient.

Swift has no doubt become a popular programming language quite quickly, but this does not mean that all developers love it. The languages has received a good deal of criticism from many professionals in the field. Many of their gripes pertain to the fact that the language still needs time to mature as well as Apple’s tendency to be controlling. Because the language is young it has issues that need to be addressed and growing pains to experience. The time it has been on the market is still too little for it to be considered a “mature” language. Swift also has poor interoperability with third party tools and IDEs, developers are sort of forced to use Apple IDE and Xcode. Swift offers less choice of libraries, frameworks, and tools than other languages and also uses smaller extensions.

Swift is considered a moving target, developers consider it unstable due to major changes that come with every new release and frequent changes from Apple. A key problem articulated by developers is a lack of backwards compatibility with older versions. This forces developers to have to rewrite their projects to be compatible with the latest version of Swift. Xcode offers tools to help this process but it is still is time consuming and costly. Resources and tools dedicated to earlier versions of Swift become useless with new releases as there is no compatibility between version. Due to Swift’s infancy, it has a limited talent pool for hiring developers. However, this will change over time especially due to Apple’s emphasis on educating young people on how to use the language. Swift does not support iOS versions before iOS 7. But this should not be a huge problem since 90% of iOS users are on the latest version of the operating system and are more likely to update their devices to the latest version than users of other platforms.

As Apple does with many of its products, they are not necessarily known for inventing everything from scratch. If we think about products like the iPad or iPhone many of the technologies used to make these devices a reality existed long before Apple assembled them into a design oriented and user friendly package. The same could be said with Swift. Developers in the industry have accused Apple of stealing or borrowing features from existing languages like Java, JavaScript, JSP, C#, Cold Fusion, Python, and Objective-C. The most prevalent features Apple copied are dictionaries/hash tables, inferred data types, data structure declarations, string templating, optional semicolons, and automatic reference.

Everyone Can Code is Apple’s initiative to promote computer science in K-12 education around the world. This initiative was announced at WWDC in 2016, two years after the launch of the language. Apple has published two textbooks to accompany the initiative titled Learn to Code 1 and Learn to Code 2 which are a full curriculum for learning the basics of Swift. They have also produced a range of iBooks for teachers and students that extend the education of Swift into Xcode. In 2018, Apple expanded the Everyone Can Code initiative to 70 different institutions across Europe. Although the company has done a lot to make learning to code accessible to all, “everyone” is a bit of a stretch as many assumptions must be made to conclude this is possible for everyone. “Everyone” can code, if they have access to an Apple device, good internet connection, educators, and the time to do so.

Swift Playgrounds is the flagship product of the Everyone Can Code Initiative, it is an iPad app that provides a native Swift programming environment on iOS where beginners can experiment with various programming structures outside of an Xcode application project. Playgrounds has a number of innovative features that make writing code easier on a touch screen like drag and drop code statements, pop up number keypads, literal colour values in a colour wheel, and literal image integration from the iOS photo picker. Playgrounds also allow users to simply drag opening and closing brackets around to include or exclude statements from a loop or conditional. Opening and closing brackets is something that beginner programmers can often make mistakes with, this feature helps reduce the chance of error. Similar to when you type a text message on your iPhone and Siri recommends your next word, playgrounds will give context sensitive suggestions to autocomplete functions and variable names while you code.

Swift Playgrounds plays an important role in Apple’s mission to convince consumers that iPads are real computers that you can do real work on, touting that one could build an iOS app on an iPad. While this is technically possible, experts say the reality is quite tricky. The problem is that you can build projects using Swift through the playgrounds app on iPad but there is no Xcode application that runs on the iPad that would facilitate you launching that project. So if someone learns to code on an iPad, to become a true developer they would then need to buy a Mac. Everyone Can Code is a great initiative for breaking down the barriers of learning to code but this does not breakdown the barrier of getting a project to the app store. In its most recent release of Playgrounds 4, key development features like debugging & profiling tools, versioning, storyboard integration, and support for third party packages are still missing. But as iPad OS continues to evolve and more closely mirror Mac OS it is likely that in the not so distant future we will see Xcode running on the iPad, allowing users to create Swift apps and launch them through the app store all on an iPad.

In 2020 Apple expanded its Everyone Can Code initiative to offer free resources aimed at helping educators of all skill levels gain the ability to teach Swift and Xcode. The curriculum is aimed at high school and higher education students focusing on Swift and using Xcode on Mac, the free training also includes five free books. The Everyone Can Code initiative launched in 2016 has reached round 9,000 schools and higher education institutions around the world. However, the idea that “everyone” can code and should learn remains to be somewhat controversial. Critics claim that many people can learn the fundamentals but not everyone will enjoy or excel at it. In a culture where technology is so dominant and lucrative many are learning to code for the wrong reasons or are being misled by coding bootcamps that promise a short course will grant them a six figure salary. Apple is so fixated on their Everyone Can Code initiative that they will be releasing a Sesame Street themed show on their streaming service Apple TV+ that will teach Swift coding basics to children. Throughout the show Big Bird and The Muppets will teach preschoolers about coding, collaboration, and critical thinking “giving them an opportunity to change the world.”

For a relatively young programming language Swift has done quite a lot in the time it has been on the scene. The language has experienced growing pains and criticism from software developers but has also propelled to one of the top ten programming languages with praise from many large companies in the tech industry. Swift is a pretty good example of how Apple’s product cycles work, they aren’t usually the first to market but after they do launch and a few versions are released they quickly gain widespread adoption. The Everyone Can Code initiative that is largely built off the back of Swift is a noble cause promoted by the company and will hopefully empower the next generation to become experts in computer science and help humanity solve the biggest challenges that are currently facing us.

--

--

No responses yet