For Apple developers, it’s now Swift.
Apple’s Objective-C programming is much loved. Vilified. Workable. But it appears to be on its way out the door as Apple’s main programming language. Swift will probably replace it on Apple’s new platforms like Yosemite and iOS 8.
Sighs and collective shock erupted at Apple’s announcement at the World Wide Developers Conference Monday when Swift was announced and officially entered the limelight.
Don’t fret. Objective-C and Swift can exist within the same application. Swift has the same runtime as Objective-C.
You can read my esteemed colleague Devindra Hardawar’s excellent analysis of WWDC 14 here.
We were curious about Swift and contacted a well-regarded software engineer, freelancer Sam Soffes, for his take. Soffes lives in San Francisco and has worked on apps like Litely, Hipstamatic, and Bible.
We put seven questions to him about the pros and cons of Swift. And the possible pasture for Objective-C. His answers will startle, amaze and, perhaps, sadden.
1. Why make developers learn another language?
Apple’s main goals for Swift were something easy to learn and very fast to use. I think these are great goals. Apple isn’t forcing everyone to learn a new lanaguge. Whenever they’ve introduced big technology changes in the past, like Automatic Reference Counting, they’ve allowed developers to continue doing it the old way until they wanted to adopt the new technology.
Throwing out everything and learning something new is a tough thing to do. Objective-C is many developers’ livelihoods. Messing with the tools we’ve been using for years to get our job done is hard to hear at first. Apple does a great job making a case that the new tools are the way to go.
One of the ways Apple is making it’s case this time is speed. Swift is really fast at working with collections. That alone is a big win. It’s new syntax is also really great. I think Objective-C developers will come to love Swift quickly.
2. Isn’t Objective C sufficient enough?
Objective-C is great and really powerful. It has served Apple well for a really long time. It’s older than the web though. It is pretty awkward to learn — especially for someone new to programming. This is due to looking a lot different than most other languages and its C background. Most of Objective-C’s awkwardness is due to it being built on top of C.
Making something easy to learn and really productive to use is tough to do on top of such a low-level lanague like C. You have to do a lot of things by hand in C. This is neither easy to learn nor productive. Apple wasn’t in need of a new language. They were proactive in making something new and great.
3. What is the ramp-up time to learn it, and is it easy to do so?
Swift has only been out a day, so it’s hard to say. From spending a couple of hours with it, I made really good progress porting one of my Objective-C apps to Swift. At first, I was really frustrated. Once I stepped back and accepted this would be a bit of a struggle since it’s brand new, it became much easier to read the documentation and get unstuck when I hit issues.
I think one of the best parts about Swift is a lot of the simplicity they were able to bring to the language due to not being built on top of C. Explaining Objective-C to someone who has never programmed is pretty difficult. You have to explain all of the exceptions to rules and get into pretty deep computer science topics right from the start. Swift let’s you bypass all of that and just get into the code.
4. What are the trends that inspired the language?
5. What is the endgame with Swift ultimately?
I think Apple’s goal with Swift is to make something anyone can learn quickly and be really productive in. I’m sure they will attempt to phase out Objective-C completely years down the road.
Something easy to learn is huge. More developers on their platform is great for everyone. This is a big step toward that goal.
6. How does Swift compare to MS and Google languages?
Swift reminds me the most of Google’s Go language. Go is a really great language. It’s good to see Apple mirroring some of the great things it does. Go has a lot of really nice concurrency features I’d love to see Apple do in Swift. Microsoft C# has a lot of neat reactive things as well. Hopefully this is just the beginning for Apple’s new language.
7. Is it true Swift eliminates 2 or 3 lines of code?
Absolutely. Since things are so consice in Swift compared to Objective-C, you can chain things together on one line and have it still be very readable. You could do a lot of the same stuff with Objective-C, but it would be a really long and super hard line to read. There are several new things that would take a lot more code in Objective-C that are a joy to write in Swift.
After working with Swift for just a day and going back to Objective-C for my client work, I already miss writing Swift.
Apple designs and markets consumer electronics, computer software, and personal computers. The company's best-known hardware products include the Macintosh line of computers, the iPod, the iPhone, and the iPad. Apple software includes:... read more »
Powered by VBProfiles