Archive

Posts Tagged ‘Swift’

Without A Map

Editors note: This will be nerdy

I haven’t written about iOS development in several months. I haven’t given up, I just hadn’t had much to say. I was still soaking it in. 

I was reading two separate books, while occasionally going down rabbit holes to understand a topic a little better, and even watching some videos (specifically the much touted CS 193P). I even whipped up a few rough test apps just to prove to myself that I could get something running, even if it didn’t do much.

Then a little while ago I received an email from Apple saying it was time to renew my yearly developers membership. So I had been working on this for a year without much to show for it. So I decided I wanted to start something. Even if it’s terrible, even if I end up trashing it and starting from scratch later, this seems like a good time to take a first concrete steps.

That was my first impulsive decision. The second was, upon firing up Xcode, choosing Swift as the language for my new project.

Even though most of what I had learned so far had been Objective-C, which I have really enjoyed writing, I thought back to my initial feelings after WWDC last year. Swift was my chance to get in on the ground floor of something. 

What made me confident enough to do this the fact that I now had a basic understanding of Objective-C. This is important because Cocoa makes a lot more sense if understand that it was created hand in hand with Objective C. You can still use the Cocoa APIs from Swift, but it still feels like there’s a layer of translation happening. You end up with some weird syntax and excessive casting that only makes sense when you understand that these APIs were designed for an entirely different language.

That said, what have I got to lose, at this point? This is the future, right? And WWDC made clear that Apple was still full speed ahead on Swift.

So I jumped in and started playing around. It had been a while since I read Apple’s The Swift Language, so there was a period of adjustment in getting used to the syntax. Swift is a very programmer-y language. It was built buy compiler guys, so “fast” was as important as “easy” or “intuitive”. 

But after playing around for the last couple of months, I’m feeling comfortable with it. The pace of change has slowed down, and I’m finding myself able to work for longer and longer stretches without having to look up something basic. And Playgrounds have been really helpful. Sometimes you just can’t remember if arrays are passed by value or reference, but it’s easy enough to test in 10 lines of code on a Playground. 

There have been stumbling blocks. I watched Apple’s session on Protocol Oriented Programming, and got so excited I went into my project and made all my model layers structs that conformed to a specific protocol. That did not work out so well, but that story is for another blog post (and if you want a more informed opinion, go back and read Brent Simmons’s Swift Diary). But in general when I sit down I make head way.

So I’m still working. In fact, I’ve got a couple ideas now. It’s all starting to feel manageable. Which, if experience tells me anything, means I’m only a couple of weeks from once again realizing I have no idea what I’m doing. 

Advertisements
Categories: Computer Blue Tags: , , ,

Parlez-vous Swift?

So here I am ready to make an iOS app from scratch, except that I have no idea how make iOS apps (or apps of any other kind, for that matter). But I do know that you need to program in Objective-C, a language developed largely by NeXT in the late 80’s, adopted by Apple in the early 2000s, and used today mostly to make apps for the iPhone. So I bought a couple of books and set to work learning the basics. 

Every year, just as summer is getting under way, Apple hosts their World Wide Developers Conference, where they lay out their current thinking on the best way to make apps. There are new technologies introduced, lessons available, and for those of us who can’t take a week off to fly to San Francisco, they put videos of everything up on line. Knowing this was coming up, I thought I could focus on learning the basics of the Objective-C language, as the higher level elements were likely to change.

Then Apple upended everything. Objective-C, they said, is no longer the only way to make apps for their devices. Swift was a brand new language created in secret by small team inside Apple. It was modern, they said, and apps built using it would be less likely to crash. 

That’s all well and good, but I was just starting to get a hang on the old way! Did I now need to start from scratch? How would I even do that? Swift was brand new, and the only way to learn it was an ebook that Apple released that was clearly aimed at people with a better understanding of how computing worked. 

After spending roughly a week paralyzed with indecision about which path to take, I picked back up the book I had been working on. For the time being, I’m making this app the old fashioned way. A couple of points factored in to this decision. 

  • Swift is really new, and was created by a very small (though I’m sure very smart) team inside Apple. Now that there are hundreds of thousands of developers poking around through it, I’m sure they’re going to find bugs. And I’m sure that Apple is going to fix some of those bugs, meaning that the language is going to change quickly. Behaviors you can expect today might not apply a year or two down the road. That could cause problems that I’m not confident I’d be able to detect. 
  • Objective-C is old. In some sense, that means it’s creaky, and there are some difficult concepts to grok that are papered over in newer languages like Swift. But it also means that it is well tested, and that it’s peculiarities are well documented. If I have questions, it’s pretty easy to google the method names I’m working with and find explainers, and other people who have had the same issues. Answers are abundant, and if I can’t find them already existing online there are tons of people with experience working with these technologies that I can ask. 
  • I already have the books.
  • Swift and Objective-C code can live side by side. Apps are written as smaller files that are compiled and combined into that neat little icon on your phone. You will be able to Objective-C and Swift files together in the same app to solve different problems. That is exciting because it means I can start today in Objective-C, and then start adding Swift files in the future once I see that it is starting to mature, and I won’t have to go back and redo everything I had already built. 
  • Swift is clearly the future, but Objective-C is not yet the past. It’s still being used by Apple itself for most everything, and likely will be for years to come. That means it’s not going to go away any time soon. I don’t think we have to be afraid of Apple coming in next year and saying that all submissions must be Swift-only. This is going to be a slow transition, and the end state is going to be a world where Swift is the preferred, but not only language.  

So on a beautiful Saturday like today, I am hashing this around in my head, and I think I’ve finally convinced myself. Now that I’ve gotten this off my chest, I can go enjoy the day.

Categories: Computer Blue Tags: , , ,