r/ObjectiveC • u/canute9384576 • May 12 '16
why do so many people hate Objective-C?
According to the SO developer survey, Objective-C is among the most dreaded languages, while Swift is among the most wanted:
http://stackoverflow.com/research/developer-survey-2016#technology-most-loved-dreaded-and-wanted
What is it? The brackets? Messaging syntax? The cumbersome dealing with primitive values? Header files and #import statements? String literals starting with @? Lack of namespaces? alloc?
Some parts are due to its age (e.g. header files, alloc), others are by design, most prominently the messaging syntax it inherited from Smalltalk. My gut feeling is that its the messaging syntax that puts people off:
[obj messageWithParam1:p1 param2:p2]
It reads like a sentence and is very self-documenting, unlike:
obj.method(p1, p2)
But most people stick to what they know.
5
u/remy_porter May 12 '16
I'm one of the people that likes the message passing approach of Obj-C, but I think the problem with Obj-C (and this is a problem shared with C++) is that you basically need maintain two greatly conflicting levels of abstraction. The "C" parts of the language are extremely low level. The Objective parts of the language are very high level. You're constantly shifting between them, and it's awkward.
It gets even worse when you're working with Apple's APIs. Cocoa-based APIs are usually interacted with using Object semantics. Many other APIs are still interacted with using C-style semantics.
There's a lot of nice things in Obj-C, but there's so little that Obj-C does emphatically better, and so much that makes it cumbersome to use.
13
u/thoughtzero May 12 '16
Keyword "know". A lot of people who don't know objective-c well look at the very unfamiliar syntax and nope right out. This superficial judgement is at it's silliest when the noper is a Java guy since, as it's commonly known now, the team that created Java was most heavily influenced by Objective-C. It's pretty familiar stuff once you get past the unfamiliar appearance.
6
u/mantrap2 May 12 '16
I love ObjC. It's OO-enough to improve on C yet still being C-like. C++ is a very baroque form of OO (and strictly with templates it's multiple languages which I find schizophrenic). ObjC is verbose but I find that helpful for self-documentation.
My business partner is not a fan because it's doesn't look enough like other languages he knows. He's quite enamored by Swift, ironically, but mostly because it's clean and has a lot of Functional features.
16
u/w0mba7 May 12 '16
I love Obj C. I know a lot of languages, and Obj C is my favorite. It is not surprising that most people can't see the beauty, given that most people are idiots. ;-)
3
u/rdpp_boyakasha May 13 '16
Then there are the usual complaints about every language. Type system weenies say the type system isn't strict enough. Dynamic language weenies say the type system is too verbose and gets in the way. C weenies say it's needlessly slow. etc.
2
u/[deleted] May 15 '16
I'm not sure about anyone else, but swift was way easier for me to pick up and actually get to the level where I can go deeper into the programming whereas with Obj-C I spent months on surface stuff and having to remember to do this and that and more this. In fact, the reason I'm here is to find resources to start using Obj-C because it's useful to get the history, but I'm hitting the same roadblocks as before. Don't get me wrong, when you do get it it is very beautiful and self-documentation is important, but Swift is just easier.
Ninja Edit: And Swift isn't easier at the expense of power, it's easier and just as powerful if not more.
3
u/[deleted] May 12 '16
I guess it's because there are a lot of iOS devs who are very new in this role and they didn't "grow up" with Objective-C. They were forced into using it (and still are with existing code bases) although they don't understand and/or like Objective-C.
2
u/afroviking May 12 '16
Objective-C is extremely wordy. Named function parameters for example.
1
u/[deleted] Jun 07 '16
I think that i can speak on this topic since i am learning Objective-C. I already know a slue of other programming languages, but want to get into Jailbreak Tweak development, so Objective-C is needed.
For me, i just dislike the syntax. It's not that it's different. It's just that it doesn't appeal to me, and that is okay. People have different opinions, some people think that Swift is ugly, or they "Don't like the syntax" which is fine. I just find Swift a lot more nicer to use than Objective-C. Again, opinions.
1
u/abstract45 Jun 21 '16
What I like about Objective C is that I do not need to convert floats to doubles or Ints I can use operators on them seamlessly. I originally started out with Objective C and for me it was hard as I was starting out into programming. I am sure some of you would agree that Objective C is not beginner friendly when you are just starting out into development. I did not understand the bracket syntax and found it frustrating writing enums, where as in Swift I found it easy. I can very easily port Objective C code to Swift now so that is some progress and I am sure given some time I could probably learn Objective C, now that I know Swift. Swift is known to be faster than Objective C and I have even come across a situation where Objective C was using more memory as opposed to Swift. The main reason that I prefer Swift over Objective C is that it is easier for me to grasp it and build upon it. Objective C is not open source and Swift is, which means that there will be more uses for Swift in the future (hopefully Android and backend Development).
1
u/xtravar Jul 02 '16
My guesses:
1
u/Bill_Morgan Jul 02 '16
I didn't like it at first, and preferred Swift when I first started out iOS development but now I actually prefer it to Swift. There is a learning curve and it is rough around the edges, but it is flexible much more than Swift.
1
u/SZ_95 Sep 04 '24
Because Objective-C itself isn't that bad of a language, it has interesting ideas can be used to quickly make a bridge between Mac and Windows environments (via Toll Free Bridging) which opens many possibilities for cross platform development.
One issue is verbosity because people don't want to have to remember the names of parameters. Most people rely on Intellisense to tell them these parameters whereas with Obj-C you can't send messages unless you know the parameters you want to influence of a specific function or a delegate, of a specific implementation.
Like your example you are just choosing to be less verbose in one example and calling it a "weakness" because you're not forced to remember the parameters of the function being called:
The thing that bothers me most about Obj-C is there is zero public vs private function declaration which makes knowing what you are *supposed* to be calling a puzzle almost every time in a way I find really gatekeepish because it means people who have used the language can just call you a "noob" when it could be a learning opportunity. it also feels like as a consequence is there is no function overloading or namespaces because messaging just resolves to the right function call based on Parameters which isn't bad into itself but in the Foundation/Apple ecosystem these problems all become hellish to deal with just because of how *huge* the Apple Obj-C codebase is.
I would argue in Obj-C taking a "less is more" approach to it makes it a lot more fun to use. Unfortunately Apple's use of Obj-C will make you very angry and the only way to fix it is with time/beating your head against a wall till you "get it"
1
u/[deleted] Oct 29 '24
“You have hit the nail on the head” only we never wanted that nail seated. When you say “it reads like a sentence” you are mentioning the problem, but you seem to think that it’s a feature.
We already can’t know/memorize/recall all of the built in methods (or as they’re called, “message” names) so when they name the like chapters from novels it further ruins the experience.
If the programmer can not recall if it was “stringWithString” or “stringToString” or “replaceStringWithString” then it was better to not “self-document” at all, and simply call it “replace” or “insert” —basically call it something simple because we already cannot recall the long method names when we have thousands to remember.
These people have built a terrible language, and deliberately so. I’m sure that whoever was a developer at Apple was writing in this language with special programs that wrote it for them, without ever mentioning it, because Apple is that secretive.
There is no way anyone likes this language. It was deliberately made to be awful and stressful to work with, because Apple wanted to drive people away from the ins and outs of their computers. They wanted complete control of their entire operation. I’m sure they were surprised when people started writing apps in the language they deliberately made to be terrible to work with.
1
u/jebeom May 12 '16
I think Objective-C has too many similar data types.
CGFloat,double,NSInteger,NSUInteger,longandunsigned longconfused me when I met this language for the first time. I love Objective-C except that.-2
u/zushiba May 13 '16
Honestly, it's ugly as sin. Turned me off so I didn't bother to learn it.
-1
u/IsMyAccount May 13 '16
You hit a number of my gripes
Messaging feels different than other languages and when you are trying to pick up yet another language different for the sake of being different isn't a feature.
Stringbyappendingstring is just nonsense
NSMutablestring. Mutable means you can change it, that is annoyingly different than everyone else. If I have a string and I want it to be a constant.... Const
NSanything . We get it you have objects in your language. Java and c# do too but the don't need to prefix them with NS (side note is NS the original developers initials?)
You say verbose is a feature but from my view being more verbose only sounds like a feature until you have a single statement that spans 4 or more editor lines because of the verbosity then your color command is interfering with readability . Colors are rgb in that order and intellisense will help you if you aren't sure
Speaking of intellisense, if you don't know what parameters and methods an object has, you are going to be there a while.
Enforced mvvm . Most languages want you to use a good design pattern and that is awesome for big projects but your first hello world app it would be nice to pop the screen designer open and code a touch event directly just to get an experienced dev up and running in an hour. I get that the reason my iPhone app and iPad app are so easy to keep in sync is because the UI is separated from the actual code and that is a feature but it makes the runway longer to get the reward (something is working!) for your first app.
I have been professionally coding for 20 years and have taught myself a number of different languages and objective c is the first time I ever thought I was getting too old to learn a new language. Eventually i threw in towel and took up xamarin . Long live c#!
0
u/[deleted] May 13 '16
[deleted] — view deleted comment
0
u/[deleted] May 13 '16
[deleted] — view deleted comment