Swift vs. Objective-C: 10 reasons the future favors Swift

It’s high time to make the switch to the more approachable, full-featured Swift for iOS and OS X app dev

1 2 Page 2
Page 2 of 2

Dynamic libraries in Swift make it possible for programming language changes and improvements to propagate faster than ever before. Users no longer need to wait for iOS point releases to benefit from any performance or reliability improvements Apple introduces into Swift.

9. Swift Playgrounds encourages interactive coding

Swift’s newly introduced Playgrounds are a boon to experienced developers. The Playgrounds were partially inspired by the work of former Apple employee Brett Victor. Playgrounds enable programmers to test out a new algorithm or graphics routine, say 5 to 20 lines of code, without having to create an entire iPhone app.

Apple has added inline code execution to Playgrounds to help programmers create a chunk of code or write an algorithm while getting feedback along the way. This feedback loop can improve the speed at which code can be written because the mental model that a traditional programmer needs can be replaced with data visualizations in Playgrounds. Programming is an iterative process, and any strain that can be reduced or used to complement the creative process will make programmers more productive and free them to solve bigger problems, rather than focusing on boring details that traditional compilers have imposed on programmers.

Note: From my experience in teaching novice programmers, Playgrounds are not as powerful for beginners as they are for experienced programmers. Simply showing how a variable works in the Swift playground doesn’t help a beginner understand the need for a Floating point variable versus an Integer variable. The need becomes obvious when you show an app that can remember your last scroll position in the Facebook news feed. For beginners, the “why” question can only be answered with a working example: an iPhone app.

10. Swift is a future you can influence

Objective-C isn’t going anywhere, but it won't see as many major changes, thanks to the introduction of Swift. Some Swift features will likely migrate over to Objective-C, but Objective-C’s legacy in C means it can absorb only so much.

Swift provides the development community a direct way to influence a language that will be used to create apps, embedded systems (if Apple ever licenses an embedded framework and chip for third parties), and devices like the Apple Watch.

Apple is focused on providing the best consumer experience and is building only those features deemed worthy of attention. With the Swift 1.2 release in Xcode 6.3, Apple has already fixed thousands of bugs reported with the popular Apple Bug Reporter utility. The team supporting the development and evolution of Swift is very interested in how the language can be improved to better support the development community that builds apps and systems using Swift.

Swift: The more approachable, full-featured language

The bulk of changes that allow Swift to rise above Objective-C stem from dropping the legacy language that Objective-C was built upon. Apple isn’t moving away from Cocoa, which is their API and code library for creating the experiences that feel Apple-esque. Instead, they are providing full-featured parity and making it easier to interact with new APIs that support features like Force Touch or Taptic Feedback.

Many legacy decisions were designed to make compiler design easier. Swift is focusing on making the app developer’s job easier by jettisoning the mental strain of legacy coding practices. As modern compilers improve, more information can be inferred from less code.

With Swift, programmers have half as many code files to maintain, zero manual code synchronization, and far less punctuation to mistype -- leading to more time spent writing quality lines of code. Code is now self-documenting in Swift with the addition of optional types: a compile-time safety mechanism for returning a value or no value, which is a common issue with asynchronous operations, network failures, invalid user input, or data validation errors. ARC is unified in Swift between both procedural C-style code, as well as object-oriented code using Apple’s Cocoa framework.

Developers will find that they write less code in Swift, and modern language features support them in keeping lines of code more readable. Swift will keep the entire Apple ecosystem at the forefront of programming as it continues to evolve, thanks to dynamic library support in iOS and Swift. Open source projects, third-party SDKs, and frameworks that integrate with home automation, devices, and social services will be easier to integrate without increasing build times. Swift is almost as fast as C++ in some algorithms and the latest release of Xcode 6.3 and Swift 1.2 point to additional performance optimizations on the horizon.

Add to that the fact that Playgrounds and Swift enable a new way to program with visual feedback that assists the development of algorithms using inline data visualizations. A shorter feedback loop and graphical descriptions make the iterative coding process even easier to start.

Ultimately, Swift is a more approachable full-featured programming language that will allow developers to not only build apps but also target embedded systems like the new lower-power Apple Watch for many years to come.

Related articles

This story, "Swift vs. Objective-C: 10 reasons the future favors Swift" was originally published by InfoWorld.

Related:

Copyright © 2015 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
FREE Download: Learn how leading organizations are rising to the cloud security challenge