When it comes to developing software in the Apple Universe (OS X and iOS), Objective-C is now the “old and busted” while Swift is the “new hotness”.
There are already dozens of resources on the Web for learning how to create “Hello World” in Swift, declare a variable, write a function, and so on. Apple has made available three wonderful documents that cover the essentials:
There is also no shortage of people trying to distill the hotness into a Twitter-like 140 characters or less.
Personally, I’m a long-time Objective-C programmer who still actually enjoys using the language. Of course, I also very much enjoy writing C++ so maybe I need some professional help.
Anyway, my goal with this series of articles is not to give you a basic tutorial on how to write Swift. As I said, there are more than enough places to go for that. What I will do is give you some insight into what Chris Lattner and his compatriots at Apple were thinking when they came up with this little gem. I will focus less on the “how” and shine a brighter light on some of the “why”.
I will also occasionally take you behind the curtain and explore some of the things that make Swift tick.
Most importantly, I want to help you to learn to “think in Swift”. No one likes to be the foreigner in a strange land speaking the language in that “not quite right” sort of way. The Python community uses the term “pythonic” to refer to code written the “right way” and not in a way that makes them say, “Look, how cute, another C programmer trying to write Python code”. Looking like a Swift native speaker will require you to think different at times (wouldn’t want it any other way) but it will hopefully be a rewarding and enjoyable experience. Swiftic? Swiftonic? Swifty? I think I’ll stick with “thinking in Swift”.
If you’d like to dive right in with a discussion about the different ways to write Swift and the Swift compiler itself, feel free to move on to Part II. If not, stick around and take a brief journey with me through some of the relevant history leading up to the announcement of Swift.
In 1996, Apple acquired NeXT Computer, Inc. As a result of that deal, Apple ended up with new leadership (Steve Jobs – again), a new operating system (OS X), and a programming language (Objective-C).
Objective-C was actually developed in the early 1980s and selected as the main language for the NeXT OS in 1988. The Foundation and AppKitsoftware development frameworks were also initially developed at NeXT and this is why many class names begin with the letters “NS” for NeXTstep.
While some developers really do like Objective-C (including yours truly), others have called it everything from an outdated language to an abomination. In truth, the developers at Apple were playing the hand they were dealt and they made the best of it by adding new modern language features on a regular basis:
A significant step in the evolution of Objective-C at Apple was the move from the GCC compiler to the LLVM compiler infrastructure and the Clang compiler front end. The initial design and implementation of LLVM was the work of Chris Lattner while a research assistant at the University of Illinois at Urbana-Champaign (early 2000).
As an interesting aside, Chris worked as a research intern for Microsoft Research during the summer of 2004 where he built an experimental bridge between the Microsoft compiler and the LLVM compiler allowing LLVM to compile and run .NET code.
In 2005, Chris was hired by Apple and began the process of preparing LLVM for use in Apple products. Eventually, enough of the pieces were in place for a more significant change.
In July of 2010, Chris began work on a new programming language (Swift) that could take maximum advantage of the LLVM infrastructure. Swift became a major focus of the Apple Developer Tools group in July 2013 and was officially unveiled to the public in June 2014.
Author: Jason Bell, Accelebrate’s Director of Technology and senior instructor.
Written by Jason Bell
Jason is Accelebrate's Director of Technology where he ensures the smooth and effective running of Accelebrate's IT infrastructure to support the organization's continued growth. Jason also is a trainer specializing in Computer software design and development, C/C++, Microsoft .NET, Apple OS X, iOS (Objective-C and Swift), IIS, and more.
We offer private, customized training for 3 or more people at your site or online.
Our live, instructor-led lectures are far more effective than pre-recorded classes
If your team is not 100% satisfied with your training, we do what's necessary to make it right
Whether you are at home or in the office, we make learning interactive and engaging
We accept check, ACH/EFT, major credit cards, and most purchase orders
New York City
Salt Lake City