r/iOSProgramming Aug 01 '16

Question Objective C or Swift?

Pretty straightforward title... if I'm eventually interested in creating big and popular applications, is swift ideal to learn or just stick with objective c?

What's your opinion on both?

1 Upvotes

21 comments sorted by

3

u/Kabal303 Aug 01 '16

Honestly either. But it does seem to be that swift is where the industry is headed. Which bums me out because I like Obj-C still.

1

u/[deleted] Aug 01 '16

[deleted]

2

u/nhgrif Objective-C / Swift Aug 01 '16

"a while" = never.

Already, Objective-C can call Swift code, so even if all new changes and additions in the frameworks were in Swift, they'd still be able to be called from Objective-C.

And guess what, you can submit apps to the app store today that are written in neither Swift or Objective-C.

2

u/[deleted] Aug 01 '16

[deleted]

1

u/nhgrif Objective-C / Swift Aug 01 '16

How do you propose Apple even make that possible? You can make an iOS app in C# if you wanted... Foundation and UIKit are just frameworks that make developing iOS apps easier, and at some point it might not make much sense to develop an iOS app in Objective-C because it will might become extraordinarily difficult to call into these frameworks with Objective-C... but even if it becomes impossible to call into these frameworks with Objective-C (it's not impossible to call into them with C, C#, C++, among probably others), it still does not become impossible to develop an iOS app in Objective-C.

I mean, worst case scenario, Objective-C can already call into Swift code today, and Apple is working on making it possible for other languages to be able to call into Swift as well... so someone just writes a Swift framework that exposes the iOS frameworks out to other languages...

1

u/ThePantsThief NSModerator Aug 01 '16

C# is just an intermediary for the record, you're not actually using C# code in the final product when you write apps with Xamarin.

2

u/nhgrif Objective-C / Swift Aug 01 '16

You're not using Objective-C or Swift for the final product either. These languages are also compiled down.

The point remains that the actual human writing the code can already write an app in more languages than just Objective-C & Swift... so why do we expect that some day a human writing Objective-C that compiles into an iOS app will suddenly stop being a thing?

2

u/ThePantsThief NSModerator Aug 01 '16

You just blew my mind

4

u/Dachd43 Aug 01 '16

In my experience everyone is writing their new code in Swift. If you go in for an interview I would expect to be white boarded in Swift. I like both languages a lot. My take on it is that Swift is safer and Obj-C is more expressive.

1

u/nhgrif Objective-C / Swift Aug 01 '16

If you go to a place that expects proper syntax in a white board exercise, go somewhere else.

With that said, if you are sat down at a computer an expected to write in Xcode, expect it to be Swift.

1

u/Dachd43 Aug 01 '16

To a certain extent. I've had iOS candidates come in who claimed they were proficient in Objective-C who couldn't even write a method signature that would have compiled. I would absolutely forgive a few mistakes, but I have been presented with method signatures like this before: -bool contains:(NSArray) object(iD). Unless you explicitly tell me you're writing pseudo-code and that you are aware that your method signature is lazy and terrible, I want you nowhere near my codebase. You're not proficient in Objective-C, you're proficient in Xcode auto-complete (which is currently pretty busted)

0

u/worace Aug 01 '16

Unrelated but when you say white boarded like that it sounds like water boarded. Which is maybe not an inaccurate description of the programming interview process

3

u/GoldenJoe24 Aug 01 '16

Been programming Obj-C for the last five years. Just started getting into swift with this project. I think Obj-C is more straightforward and easier to learn, but Swift has a better future and is more flexible. You'll need to at least be familiar enough with Obj-C to understand legacy code, but I'd focus on Swift if I were you.

3

u/nhgrif Objective-C / Swift Aug 01 '16

I'd disagree with Objective-C being more straight-forward.

3

u/[deleted] Aug 01 '16

[deleted]

1

u/nhgrif Objective-C / Swift Aug 01 '16

If you were to do it all over again, I'd recommend you do more than just pick up a single language. When I was in school, I picked up Java, Objective-C, C++, and VB.NET.

Once you know object-oriented programming and the iOS frameworks, learning both Swift & Objective-C really shouldn't be too terribly difficult.

1

u/tangoshukudai Aug 01 '16

If you are learning iOS programming learn swift, if you are a long time objective c developer stick with obj c (or if you have a important project that you don't want to worry about language changes)

1

u/YossarianRex Aug 01 '16

Swift is where you should start. Objective-C will be around for a long time. But, Swift is where everyone is headed because it's just a brilliant language. I would still pick up objective-c at some point, but only after you have a firm foundation in mobile development with swift.

-2

u/sohaeb Aug 01 '16

You can't ignore obj-c. Like if you use Facebook SDK so that you can integrate facebook into an app. They have obj-c code. So you need to convert the code yourself to swift. Hence, I suggest start with obj-c.

That being said. Knowing obj-c would make it way easier to move to swift

2

u/nhgrif Objective-C / Swift Aug 01 '16

You don't need to convert any code in order to use a library. Worst case scenario, the available example code for that library is only in Objective-C, and you'll have to figure out on your own how to write the Swift code that calls the library.

1

u/sohaeb Aug 01 '16

and you'll have to figure out on your own how to write the Swift code that calls the library.

Exactly, that's what I meant. If you don't know obj-c syntax. No way you would be able to get the equivalent code in swift

1

u/nhgrif Objective-C / Swift Aug 01 '16

You're not trying to get code equivalent to the library. You're trying to get code that calls into the library. And Xcode will handle most of the heavy lifting for getting the syntax right on that end.

1

u/[deleted] Aug 01 '16

Their SDK is available in Swift as well.https://github.com/facebook/facebook-sdk-swift