As a total beginner to iOS development: Should I learn Objective-C before Swift? I've heard that it's not essential, but will learning at least the basics of Objective-C still give me a better grounding for app development than just jumping right into the latest version of Swift?
Should I learn Objective-C before Swift?
Yes, good grounding & both FTW, Obj-C especially if you want to get apps in the store soon. Good news is, Swift 3 means the language has leveled off to a point where what you learn now can be used going forward.
Good luck.
Objective-C and Swift are just languages; that's the easy thing to learn. You'll spend most of your time learning the frameworks (Foundation, Cocoa and Cocoa Touch). Thus, I would start your journey with Swift. More and more material and sample code are also now in Swift. Having said that, if you find that the samples you need to reference are in Objective-C, it may be helpful to at least learn the basic syntax.
In terms of jumping into the latest version of Swift (3), that depends. If your desire is to ship something soon, I would stick with 2.x. Otherwise, I would stick with 3.
>In terms of jumping into the latest version of Swift (3), that depends. If your desire is to ship something soon, I would stick with 2.x. Otherwise, I would stick with 3.
I don't think it would be wise for a beginner to start learning a version of a language that is going to be superseded so soon. I'd say go with ObjC first. It doesn't seem to be going anywhere anytime soon.
This is a very personal comment, because language preference is pretty much a personal feeling.
I started a few years ago XCode witn Objective C (Swift did not exist anyway). And found it pretty tough (notably because ARC did not exist yet) and because of all the @synthesize suff
When Swift came, I switched immediately ; whatever the language limits, I do not regret it.
Having some knowledge of ObjC certainly helps, but getting to a good level would take months. So I would advise to start with Swift (2.2, not 3)
Hello rsharp.
"Objective-C and Swift are just languages; that's the easy thing to learn."
I'm envious! Learning Objective C was possibly one the biggest endeavors that I have EVER done!
Now that I have that out of my system, in your opinion, is Swift easier than Objective C when it comes to the learning curve? What are the strengths and weaknesses of each do you think?
JR
To put it a different way, I meant that learning a language is much much easier than learning frameworks. So be sure to set aside the necessary time for each endeavour.
IMO, Swift is much easier to learn than Objective-C.
Here are my main pros/cons after moving eight projects now from Objective-C to Swift:
Pros:
- Swift source is smaller than the Objective-C source. Less typing and smaller code is always a good thing.
- Optionals
- Enums, structs and classes all first-class citizens
- Difficult or impossible to introduce certain types of errors
- Much much easier to work with mutable vs immutable types
Cons:
- Swift is still evolving, but seems to be converging nicely. Still, quantity of on-going changes may be too high for some. I pushed through them myself, but was painful at times.
- Some specialized code is quite tricky to get right (e.g. for a testing infrastructure, I needed to find all functions with a particular signature and execute them. That involved calls to low-level APIs such as objc_copyClassList
I am a credentialed teacher teaching development and design right now. I understand. I recommend jumping right in IF you have some degree of experience with object oriented programming period. If you have no experience programming at all, go through some introductory lessons (there are lots of free ones online) in the Ruby programming language (closer to English thus easier for beginners) as it will introduce you to concepts and ideas fundamental to OOP languages such as C (and Swift is derived from C). And don't be afraid to try and fail... many times!
>Swift source is smaller than the Objective-C source. Less typing and smaller code is always a good thing.
Smaller source doesn't necessarily mean better, or easier. Typing is not really a barrier to programming. BTW, code completion in Xcode is very good, so even the longest method names I write, I usually only have to type them in full once. It used to be encouraged to use verbose method names for readability purposes.
The list of Swift pros, while you may enjoy these features, are features. I don't believe most of them make the language easier to learn, though they maybe icing on the cake for people who already know what they are doing.
I think most people who find ObjC "hard" suffer from this:
1. They never done programming before and have no teacher.
2. They want to build an app that "does something" and they Google for a tutorial and quickly get in over their head.
or:
1. They programmed in another C-based language and see square bracket syntax and instantly have a meltdown.
Complaints about having to synthesize and manual reference count in the past I think are valid...they certainly make the language harder to learn for beginner. But that's all old news now and does not apply to modern ObjC.
I remember reading a blogger write not too long ago something like this: "every line of ObjC code is legacy code." However, Swift 2 has already become legacy code. So there's that.
Thank you for your fast reply rsharp.
Interesting comparison of the two langages! But what is really interesting is when you said: "I meant that learning a language is much much easier than learning frameworks."
I have been working at learning Objective C for years and it was just last year that I knew it well enough to finish the coding of my first app. (I'm now on the artwork phase.) And I never even looked at Frameworks!! I'm not sure what that even means!
If you can say in a sentence what that means it would be helpful. I'm feeling creeped out right now becasue I thought if my app ran on my iPad with no errors or warnings I was in like Flynn, but now that I see this!! Well...
JR
UIKit is a framework. CoreData is a framework. Knowing what framework to use (and where to look) to do a particular task. Basically knowing the tools at your disposal. ObjC and Swift on Mac/iOS let us hook into the same frameworks...you are just using a different syntax to do it.
>So I would advise to start with Swift (2.2, not 3)
Why recommend something that already needs migration to be current?
If you're shooting for something less than 3.x right now, at least recommend 2.3
OK. I get it. And I've been using frameworks when I when I #import them at the beginning of my code. That is a relief!! I thought I was completely missing something BIG there for a second. Thank you Macho Man RS.
JR
No problem; frameworks or SDKs is what provides the APIs that you'll use to do stuff (draw to the screen, open a file, etc.). I was thinking a bit more generally though than individual ".frameworks" that Apple splits things up into.
Here's the primary list of frameworks/SDKs I've used over the years. Some with a single language; some with multiple languages.
Apple IIgs Toolbox, Macintosh Toolbox, Apple MPW, THINK Class Library, PowerPlant, J2EE, Carbon, Cocoa, Cocoa Touch
it has been a year, you must be so deep in Objective C, i started 2 month ago, i already done the essential learnings on Lynda, and about 1 month later im start working on my own app, there's couple of question i appreaciate if you help me through, have you switched to Swift?
how different is that?
have you done any serious project yet?
and how long does it take for you to learn enough to do your first project?