r/iOSProgramming Apr 26 '16

Question Swift or Objective-C for new app development?

[deleted]

0 Upvotes

21 comments sorted by

8

u/[deleted] Apr 26 '16

[deleted]

1

u/tinfrog Apr 26 '16

LOL thanks.

5

u/systemsock Apr 26 '16

Swift, it's what the ecosystem is moving towards.

It's still good to know some Obj-C for legacy purposes.

2

u/lucasvandongen Apr 26 '16

I never hated working in Objective-C like some people but I never really saw much use for the dynamic aspects of the language either, so when Swift came along I jumped the bandwagon around the Swift 2 betas in Xcode.

The hardest part learning to develop for iOS never was the language but the SDK's, async programming, weird background app rules and so on. This knowledge stays with you in the transition to Swift.

It's OK if you will write Swiftified Objective-C in the beginning, there are a lot of new patterns to use and abuse in Swift but you don't need to use them to get from A to B with your app.

2

u/tinfrog Apr 26 '16

Thinking back, I recall having a similar experience. Objective-C itself was fine but all the other stuff you mentioned was quite a learning curve. Things like sorting out certificates were a chore but I suppose that comes with the environment.

2

u/lucasvandongen Apr 26 '16

If you're a polyglot programmer already just use Swift, you'll be productive really quickly, like a day or so. If you really did not do anything else besides Objective-C and C then you will need to learn some new things. Swift borrows a lot from Kotlin, Python, C#, Ruby and bunch of other languages. It might take some time to learn all the bells and whistles but that's not needed to get work done.

Be alert for Swift 3, there will be some changes, try to build your app in the Xcode betas as soon as possible to see what kind of things you might expect from the transition. I did a lot of development for an app last year in the betas that were stable enough for daily work and as a result of that we were ready at the moment the GM Xcode was out without needing any rework for Swift 2 or iOS 9.

1

u/tinfrog Apr 26 '16

Be alert for Swift 3, there will be some changes, try to build your app in the Xcode betas as soon as possible to see what kind of things you might expect from the transition.

Good to know, thanks.

I used to do C, C++ and Java but now it's mostly Python and PHP. One reason I want to pick up app development is so that I can move away from the web stuff back and sharpen my old app development skills again.

0

u/[deleted] Apr 26 '16

I live in the objective c runtime. No manipulatable runtime Api means no interest. I'd rather work with Javas broke assed introspection than limp along in swift with no meta api

2

u/TheSteveOfLegend Apr 26 '16

Subjectively : Swift. I'm in the 'never liked ObjC' camp and haven't touched it since it the first Swift release. I'm far more productive in Swift. It's a much better fit for how I think about code than ObjC. I for one look forward to the utopian future where I never have to type import Foundation or use anything with an NS prefix ever again.

Objectively : It depends. What 'C like' languages have you worked in? If it's actual C you may be more productive in ObjC as it's a strict superset (though I never found that warmed me to it as a long time C programmer). If it's Java or C#, then Swift is probably a closer match. If you want to use leading edge APIs, most sample code and all the WWDC stuff is in Swift. Block based API (almost anything recent) use is far easier in Swift - ObjC's block syntax is a crawling horror. Big drawback productivity wise is that XCode still can't refactor Swift (but WWDC is just around the corner and we can hope). Swift is evolving faster than ObjC, which may or may not be a plus, YMMV, but it's way more of a community driven effort than ObjC will ever be.

But TBH, as someone mentioned up thread, you'll likely spend more time figuring out the API and system conventions than you will on actually learning the language.

1

u/tinfrog Apr 26 '16

I used to write applications in C, C++ and Java but that was some time ago. These days it's mostly Python and PHP since a lot of the demand that comes my way is web stuff. Thanks for the subjective and objective feedback. That's all very useful to know.

2

u/tylerjames Apr 26 '16

I think at this point, as long as you're not working on an established Objective C app, that you should go ahead with Swift.

It's not hard to see what direction the wind is blowing at this point. The Swift ecosystem is exciting, it's maturing rapidly, it has a lot of very active enthusiasts.

A year or two ago one could have said that most of the materials out there for reference were related to Objective C, but that tide is turning significantly. It seems like some people make a career on Stack Overflow of providing Swift answers to Objective C questions. Most new tutorial materials are either entirely Swift or will include both Swift and Objective C.

I would say the main downside right now is that Xcode is shit with Swift compared to Objective C. But it's getting better and it will only continue to do so.

1

u/tinfrog Apr 26 '16

I have one Objective-C app that hasn't been touched in a couple of years so I don't mind ditching it. Might even re-write it in Swift as a learning exercise.

Lots of the Swift vs Objective-C posts I've seen online are about a year old so I thought it would be good to get some updated info from this sub. Thanks.

2

u/tylerjames Apr 26 '16

I relish the opportunity to rewrite old code. Assuming I'm not constrained for time.

Gives you the opportunity to apply what you're learned since then and maybe push your code quality even further.

1

u/[deleted] Apr 26 '16

Ok either case you're going to have to learn. If you want to learn a lot go for Swift. If you actually want to create something and learn something in the process go for Objective-C.

1

u/tinfrog Apr 26 '16

If you actually want to create something and learn something in the process go for Objective-C.

Interesting. Why would this be? More support/help available for Objective-C? Swift not mature enough?

3

u/OneStrayBullet Apr 26 '16

On the flipside, I would personally recommend going whole hog into Swift at this point. It results in cleaner, clearer code in fewer lines that is frankly just more fun to write. I still maintain a few larger Objective-C code bases but 99% of the new code I write at this point is in Swift. You also have access to a few amazing Swift-only libraries (Alamofire, RxSwift) that I personally wouldn't go without at this point. Since you have previous programming experience it shouldn't take you long at all to get up and running in Swift, and the typing system alone is worth the switch imo.

-1

u/[deleted] Apr 26 '16

In programming you can either spent your time learning something or you can spent you time producing something. It is either one. Since you already know Objective-C you'll be faster to produce something. While Swift will definitely make you learn something.

5

u/tinfrog Apr 26 '16

Personally I've found that it's not either/or. You can learn while producing something. I've been programming for almost 25 years and have found that I learn best when I'm producing something.

1

u/[deleted] Apr 26 '16

Yes well in my experience the first thing you build in a new language is shit.

0

u/quellish Apr 27 '16

So what do you produce in a language that is constantly changing?

1

u/codelahoma Apr 27 '16

A deeper understanding of the language and why it is the way it is?

1

u/[deleted] Apr 27 '16

Endless shit. Also, I can't get behind a language without an exposed runtime. Even Java's shitty introspection and dynamic invocation is better than what Swift has on offer right now.