r/simpleios • u/mrorbitman • Apr 28 '15
How long did it take you start liking Objective-C, and if I hate it at first, should I just start with swift?
Objective-C feels like such a bizarre language. The fact that it uses YES and NO for booleans, randomly requires uppercase, @ symbols and brackets all over the place, being conscious of memory management (alloc), random NS prefix on everything... Just jumping in to it, I don't really see what it does for me, but I see a lot of ways that it will slow me down and feel less pleasant to code in.
Will I get over this phase, and grow to love Obj-C? Or should I just learn swift if I really want to do an iOS app.
What are some cool things that you love about Obj-C? Could be language features, community, tools, etc. I really want to like developing iOS apps, and despite Swift, Obj-C is still the standard today it seems
9
u/somebunnny Apr 28 '15
All of your examples are essentially insignificant when it comes to the differences between swift and objective c. There are MUCH bigger fish to fry.
This is just syntax. It takes a little while to get used to it and then it's fine. Are you already literate in a programming language? What are you learning objc/swift for?
4
u/tcdb28 Apr 28 '15 edited Apr 28 '15
I'm been coding in Objective-C for 5 years or so and in Swift since it came out. I really like both languages and think you should learn both.
It seems clear that Swift is the future but Objective-C will most likely be here for years to come. All of the Foundation & New Apple APIs (HomeKit, HealthKit, etc) are implemented in Objective-C, C, or C++. Even though you can access most of those from Swift, knowing how they work will only help you. For the APIs you can't access from Swift, you'll need to know Objective-C to bridge the gap (and there will be gaps if you're doing anything non-trivial). Furthermore, Swift is still very much under development despite its v1.2 tag. Things don't always work as expected. Objective-C will be needed to get around these shortcomings.
As for all the "NS" laying around... This leads to what I would consider the most important reason to know both Objective-C and Swift: the Cocoa Culture. There is a lot of history and methodology that comes with developing iOS/Mac apps. Everything from patterns like delegation to naming conventions ( e.g. long, descriptive method names). Until Swift has been around for a few years (decades?), our experiences with Objective-C will continue to shape Swift's future.
(Also, don't let Swift's pseudo-JavaScript facade fool you. It can be just as weird and off putting as Objective-C.)
EDIT: As for community, check out NSHipster.com and objc.io. These are two of my favorite Cocoa dev sites.
3
u/FR_STARMER Apr 28 '15
Objective-C is no harder to learn than C# or Java. Like other modern OOPs, it has it's own quirks and syntax, but the concepts are the same. I would not learn Swift now, because they are still changing the syntax, and the resources for beginners are not as rich for Swift as they are for Objective-C. Also, once Swift stables out, it will take the proficient Objective-C user maybe two-weeks tops to get in the flow of the syntax and start coding in Swift. It's still best to know Objective-C first.
2
u/spencerak Apr 28 '15
I hated it at first, but by the end of my first project I loved it. It's very elegant once you get used to everything! Definitely try building a smaller project in both and see which you prefer!
2
u/iccir Apr 28 '15
I've been using Obj-C as my primary language for almost 15 years and I pretty much liked it immediately.
Can you describe your issues in a bit more detail? For example, there's no standardized case for booleans across languages. Python uses True, JavaScript uses true, various C frameworks will define TRUE or True or Yes or YES.
Classes in both Obj-C and Swift are going to be prefixed with NS (for Foundation and AppKit), Swift does have more built-in classes (Strings, Arrays, Dictionaries) however.
You can certainly use Swift if you prefer, but be aware that some basic knowledge of Obj-C is greatly going to help you (see https://www.bignerdranch.com/blog/ios-developers-need-to-know-objective-c/). The same is true for me and my friends that use Obj-C: we need some basic knowledge of Swift to read example code.
1
u/bellebethcooper May 04 '15
I don't have any other programming knowledge to compare but my co-founder is a Python/Android dev primarily. He's been helping me with issues I have in Obj-C because it's my first foray into programming and I often screw up the actual logic of my code.
Anyway, through helping me he's come to get a grasp of Obj-C and actually come around to it. He's still not a big fan but he gets the syntax and no longer finds it overwhelming. So even an Android dev can come around to it 😊