Why Learn Swift

From Coder Merlin
< Wiki(Redirected from Why Learn Swift)
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Swift Logo

When you first become interested in learning how to code, it can be overwhelming when you discover how many languages are out there. This article touches on just a small portion of computer history and, in doing so, provides background on a few coding languages. It can be difficult to feel secure in your choice of a first programming language. After a basic first Google search, you will see Python, Java, Ruby, and Swift as suggested languages. There really are no wrong choices when learning, as long as you are widening your scope of understanding. This article gives some history and logic behind choosing Swift to add to your software tool belt.

Origins of Swift[edit]

Beginning with C[edit]

Example Car Class
The C Programming Language,2nd Edition

Like other technologies and inventions, a lot is owed to predecessors. In the world of computer science, many consider C to be one of the most powerful and important programming languages. This is because of its influence since its inception in the 1970s and 80s.[1] As of November 2021, C still ranks #2 in the TIOBE index.[2] C is still widely used and relevant in day-to-day life—the MacOS kernel, Windows kernel, Android kernel, and Linux kernels are all written in mostly C. C is also the closest among modern programming languages to machine language. It is still high-level enough to be relatively easy to learn.[3] Additionally, C's syntax and structs have directly influenced some popular higher-level programming languages, including C++, C#, Objective-C, Python, Java, Javascript, PHP, and others.[1] As a replacement of Objective-C, Swift can also trace its programmatic origins to C.

Bell Labs, Unix, & Objective-C[edit]

In the 1970s, the team at Bell Labs was seeking to create a new programming language to for the developing Unix operating system (OS).[4] One programmer, Ken Thompson, developed the language, B, based on BCPL, a now obsolete language. Dennis Ritchie, also part of Bell Labs, created C by adding structures to B, allowing Bell Labs to write the Unix OS.[1] The Unix kernel was written in C, and throughout the 1980s, C grew in popularity, as did the Unix operating system.[5]

In the 1980s Objective-C was developed as a superset of C—i.e., Objective-C contains all of C's features AND has additional syntax for classes and methods.[4] Brad Cox and Tom Love developed Objective-C in the 1980s. They were intrigued by the ideas from Smalltalk, from Alan Kay's team at Xerox, where programming was data-centered, grouping information as objects, and actions carried out on the objects would be called methods. Additionally, Smalltalk programs could execute methods in realtime and, therefore, could take user input. However, Cox and Love wanted to use a Unix system and admired how quick and efficient C's programs could be. They developed Objective-C to combine the qualities they desired from both C and Smalltalk.

NeXT logo

NeXT, the predecessor to Apple, licensed Objective-C from Cox's and Love's company, Stepstone in the late 1980s. In 1996, NeXT bought the rights to Objective-C from Stepstone. Objective-C was further developed to meet NeXT's and then Apple's operating system needs. [6] Then, Apple launched Swift in 2014 to eventually replace Objective-C.[7]

What is Swift?[edit]

Apple logo black

Apple "Replaces" Objective-C[edit]

In 2010, Chris Lattner, a software engineer at Apple, began creating another programming language that would improve on and be able to integrate with Objective-C. In 2014 Apple introduced Swift as a syntactically smoother and safer option to eventually replace Objective-C. At the time Objective-C was the primary language for developing Apple operating systems and its apps[4] When Lattner and Apple released Swift in June 2014, they also released Swift Playgrounds, an app that serves as an educational tool and development environment for Swift. Playgrounds allowed new users to explore Swift and enabled Apple to demonstrate how easy Swift was to pick up.[8]

A Safe, Fast, and Modern Programming Language[edit]

When looking at Apple's official page on Swift, the language's characteristics most advertised come to the fore quickly. Apple describes Swift as "Modern...Designed for Safety...Fast and Powerful...Open Source" and easily adoptable for macOS and iOS development because of its ability to coexist with Objective-C.[9] When explaining Swift's modernity, Apple describes clean syntax, devoid of required characters that denote the end of lines, automatic memory management, and support of emojis and various foreign languages. Regarding safety, Apple adds that all variables are always initialized before they can be used.[9] Swift has been described as "a type-safe and memory-safe language."[10] This means that Swift was written and designed to prevent common bugs and memory problems from occurring, without the same level of vigilance required from the programmer when using C, Objective-C, or other languages.[10]

Reasons to Learn Swift[edit]

Open-Source (& Apple) Community[edit]

Just like Linux, Swift is an open-source software. This means that, like other open-source technologies, a variety of people—developers, product managers, companies, etc.—can troubleshoot and resolve any issues or security breaches that arise. Additionally, a community exists to help beginner coders and new Swift users acclimate and kick-start their journey with Swift. Furthermore, having the backing of a major tech company like Apple is an added benefit; it provides a community that already uses the language every day.

Apple Infrastructure & Intentions[edit]

Since Swift originated at Apple, the language was designed at the same time as accompanying tools and apps, such as an integrated developer environment (IDE), debugger, and more.[8] Apple, on its official Swift page, writes that Swift "was designed to be anyone’s first programming language" and links to free Swift curriculum that Apple created for educators and a free student-friendly app designed to learn how to code, and how to code in Swift specifically.[9] The app, Swift Playgrounds, mentioned earlier, is available on iPad and desktop. It lets the user write code directly in the app without needing to recompile or restart the program. The animations makes it accessible to students of all ages. The goal-oriented nature of the app makes it engaging for adult users too. Playgrounds illustrates how fast a language Swift is, outpacing Objective-C greatly.[8]

Professional Development[edit]

The ubiquity of the iPhone, iPad, and Apple's products creates an immediate incentive for companies to provide Apple-friendly mobile versions of any applications they run. This, in turn, creates the need for developers who can create mobile apps using Objective-C, and now using Swift as well.[8] Building an iPhone app can also be a great way to begin a portfolio as a student applying to colleges or internships.

Get Started Learning Swift[edit]

Coder Merlin is provided to promote accessible quality Computer Science education for students, primarily in high school. As such, starting students with a beginner-friendly, open-source programming language like Swift aligns with the mission and vision of the wiki. Much like the Linux OS that Coder Merlin uses, Swift provides students with access and practice for using an entire community of technologists beyond Coder Merlin. In addition to the free resources mentioned in this article—available through Apple—Coder Merlin also provides additional, tailored support and curriculum to help students in their journey through code. By learning with Coder Merlin, you are then gaining valuable hands-on experience with Swift, and can even develop your own macOS and iOS apps using what you learn. Whether Swift is your first, second, third, or nth language, happy learning and coding!

Key Concepts[edit]

Key ConceptsKeyConceptsIcon.png
  • What is Swift?
    • Swift is a modern language developed by Apple as an improvement to Objective-C, used mainly for iOS and macOS development.
    • Swift's predecessor, Objective-C, was built in the 1980s as a way to integrate object-oriented programming syntax into C.
    • In turn, C was developed in the 70s in Bell Labs for the Unix operating system.
  • Reasons to learn Swift
    • Swift is significantly faster than its competitors.
    • Swift is open-source and provides the support of an open-source community.
    • Having been developed by a tech giant, like Apple, Swift also benefits from infrastructure and support from Apple throughout its development, including curriculum and other educational resources.
    • Swift is used to develop iOS apps; therefore, it creates an opportunity for job skill and portfolio development.
  • How to get started learning Swift
    • Many free resources are available through Apple's website.
    • Anyone with an iPad or Mac can download the Swift Playgrounds app and get started coding Swift immediately.
    • Using Coder Merlin to learn Swift, Linux, and other software concepts is another free and easy way to kick-start coding.

References[edit]