11 ms·
Does anyone else look at Objective-C code, and just want to puke?
by blackrock 9y ago
Does anyone else look at Objective-C code, and just want to puke?
- DrJokepu 9y agoBeauty is in the eye of the beholder.
- keyle 9y agoIt's certainly a bit different but it's not puke-worthy. For someone who writes Obj-C daily, I'm sure Swift feels pretty different. Try reading your own perl script you wrote in the 90ies, that's fun.
- dangerbird2 9y agoAnd because objective-C is a very strict superset of C (much more so than C++), it's really critical that the oop extensions have a very different syntax from the C subset. There is little confusion what part of the code is "objective", and what is "C"
- kenver 9y agoIt’s not puke inducing, but it is verbose. The language designers just took a different approach to how to write code. Just for some background, it came out at a similar time to c++. Both were designed to be a ‘better c’
- Apocryphon 9y agoPersonally I prefer the brackets of ObjC to the colon overload of C++
- saagarjha 9y ago> the colon overload of C++ There's a lot of colons here too: - (id)outputImageProviderFromBufferWithPixelFormat:(NSString *)format pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height baseAddress:(const void *)baseAddress bytesPerRow:(NSUInteger)rowBytes releaseCallback:(QCPlugInBufferReleaseCallback)callback releaseContext:(void *)context colorSpace:(CGColorSpaceRef)colorSpace shouldColorMatch:(BOOL)colorMatch;
- Apocryphon 9y agoYes, but they don't come in pairs and are neatly spaced away from each other.
- saagarjha 9y agoThis was mainly meant as a joke :)
- iainmerrick 9y agoIn other languages, a function with that many parameters would be close to unusable. Far too easy to get them mixed up. The way Obj-C forces you to name each argument is great.
- saagarjha 9y agoYeah, I'm not complaining, I really do like argument labels. Objective-C sometimes does go overboard with sentence-like labels, but usually it's not an issue.
- sjwright 9y agoI did some iPhone dev a few years ago. In terms of writing code, I didn’t mind the verbosity because Xcode’s autocomplete worked well enough. It’s not like you actually have to type it all out. In terms of reading code, its verbosity mainly affects the horizontal dimension, which is strongly mitigated by the proliferation of large widescreen displays. In terms of learning the language, the verbosity combined with the autocomplete arguably reduced the need to continually refer back to documentation, as the verbose method (message) names were oftentimes self explanatory.
- TimmyMustGo 9y agoObjective-C itself is not verbose, method names can be as long or as short as you like. You can have method names with only colons if you want: - (void):(id)param1 :(id)param2 :(id)param3 Keyword names do not have to be unique such as: - (void)drawLine:(id)gfxContext x:(double)x1 y:(double)y1 x:(double)x2 y:(double)y2 Cocoa/Cocoa Touch is verbose, but Objective-C is not (it is by far my favorite programming language)
- mpweiher 9y agoInterestingly, Objective-C was not at all designed to be a "better C", it was designed to be, roughly speaking, a more practically useful Smalltalk. This is all laid out in great detail in the wonderful Object Oriented Programming: an Evolutionary Approach.
- kenver 9y agoAh my bad, I misremembered a talk I heard once. I'll check out the book. Thanks.
- protomyth 9y agoWhile you are looking, Brad Cox’s other book Superdistribution: Objects as Property on the Electronic Frontier is well worth a read to get a feel for where he wanted to go.
- boomlinde 9y agoWhatever their intentions were, it was designed to be a "better C" in the sense that it's a strict superset of the C language.
- _diyu 9y agoI actually prefer Objective-C to Swift.
- aplummer 9y agoWhat got me over the line was optionals and protocols + generics, the safety and expressiveness combined will eventually (hopefully!) win you over!
- LeoNatan25 9y agoI prefer to keep the dynamism over unreadable fp "expressiveness" or safety that was not needed in the first place.
- aplummer 9y agoI’m surprised you downvoted this, we should be able to discuss pros / cons without downvoting people.
- saagarjha 9y agoThere's nothing stopping you from writing dynamic Swift code or functional programming in Objective-C.
- LeoNatan25 9y agoYes, but it’s not officially “condoned”, so it feels “out of place”. This is very individual, of course, but I don’t like bending the system to get patterns that are not “natively” supported. In Swift, you cannot currently create classes in code, enhance and swizzle, implement proper proxies. You couldn’t even load a nib without the ObjC runtime. Not even reflection. It’s telling what their priorities were with that language. What good is the language when you cannot implement most of the system frameworks (Cocoa, Core Data, etc.) without nasty hacks?
- aplummer 9y ago
- IncRnd 9y agoI started programming objc on NeXT and still remember the book by Brad Cox. No, I don't want to puke when I see objc.
- jmpt 9y agoNo, and if you do, then I suggest you visit a doctor. Rant: Objective-C is a wonderful language, once you learn it properly. There's a lot of Swift fanboiism (is that a word?) and a lot of Objective-C hate. I have an opinion on why. The vast majority of people that used Objective-C were drawn to the success of iOS. They were developers, used to languages like Javascript, Java or C++. Coming to Objective-C, their immediate reaction was "WUTT??? Brackets!" Instead of properly learning the idioms, they fought the language on a daily basis and cursed Apple for forcing them to use a language unlike the one they were used to, in order to jump on the iOS bandwagon. These people, once Swift was released, jumped boat immediately because they never really understood Objective-C and Swift is familiar. Another group of people: the seasoned Objective-C developers, with a clue, went: "hmmm... this doesn't solve any of my real problems," but they weren't stupid and Apple was quite clear that Swift was the future. They learned Swift, got used to the bad, learned how to like the good and went along their business. Another group of people actively dislike Swift, and really enjoy Objective-C. These are considered dinosaurs and have to either hide their opinion or face hiring difficulties, or even dismissal from companies where they are currently employed. Hiring managers, usually incompetent and non-technical in nature, ask: "Do you use Swift? Do you like it?" If you want a job, you must say yes. Disagree with me? Try a no. All new documentation is Swift oriented. All conferences and talks are in Swift. All new books are in Swift. You would have to be crazy to stick to Objective-C, but not for technical reasons. The Objective-C vs Swift debate is similar to vi vs emacs, except that vi and emacs would be built by the same company and that company explicitly said "emacs is the future." Nat, went like: screw this, and built https://www.mulle-kybernetik.com/weblog/2015/mulle_objc_a_new_objective_c_.html https://www.mulle-kybernetik.com/weblog/2015/mulle_objc_a_ne... Objective-C has warts. It is also fast. And stable. And quick to compile. Did I mention stable? It is also: stable. My code from 20 years ago still runs. Objective-C is a marriage of my two favorite programming languages: C and Smalltalk. Objective-C is message oriented, like Alan Kay envisioned, instead of object oriented. The focus should be messages and messaging to nil is a FEATURE. I actually quite like it. In Objective-C you can drop to C at any given time and have access to all the insanely fast libs. You can also write such insanely fast code yourself. Swift is immature, unstable, bloated, overengineering and extremely complex as a language. Complex as in C++ complex, but without the speed. Ever heard of Objective-C++? Yup. Everything I said, except exchange C for C++. Swift sacrifices LOTS of things and introduces new ideas that have yet to be proven efficient, and you get to rewrite your code all the time. Have something you wrote 2 years ago? Good luck with that. All productivity "supposedly" gained by Swift is lost to slow compiles, rewriting older code and migrating to the new version when it comes out. Swift is safe and everything. Right. Except developers with deadlines will just ! all the optionals when they get in the way. Prototype a new idea? Prepare to fight the compiler the entire time. Now, Swift does have some cool things, but so could a new version of Objective-C. In fact, ARC, which is pretty cool was born out of the development of Swift. In my opinion, Swift is not a great language. I would even say that it's not good. It's OK. Maybe one day it will be good, but this day is not today. All the love I hear is based on developers that resist learning something new (like Objective-C's way of doing things) and that's a good thing? I love Cocoa. There's an impedance mismatch between Swift and Cocoa. Objective-C + Cocoa is wonderful. Oh well. Objective-C is as good as dead and I'd rather write Go, Kotlin, C, Ruby, Erlang or even C++ than Swift.
- iainmerrick 9y agoNot me. Objective-C is lovely. For me the addition of Automated Reference Counting was key. That took a while bunch of tedious but essential boilerplate out of the language. Before ARC, Obj-C was a weird but interesting language that I didn’t want to use. With ARC it all came together into a nice expressive high-level language with raw C power available when you need it.
- cmsj 9y agoTotally agree. ARC is excellent and almost always completely transparent. When you're doing something unusual (like storing a pointer to an ObjC object in a C struct or something), there are very simple compiler hints that keep everything happy. It's so much nicer than all the faff of manual retain/release before (and probably nicer than ObjC garbage collection, but I started ObjC after that was already discouraged, afair).
- iainmerrick 9y agoCome to think of it, garbage collection was an obvious “me too!” feature to catch up with Java and C#, but proved misguided because it didn’t fit well with Objective-C. ARC was less obvious, but quickly proved to be a much better approach (edit to add: for the typical use cases of Obj-C ) It makes me wonder whether Swift’s vtables and generics are just “me too!” features, this time chasing after C++ fans... Maybe not a great idea, as they’ve also picked up some of the bad stuff like exploding compile times.
- apple4ever 9y agoMe too. I absolutely love Objective-C and its syntax. Admittedly it takes some time to get use to and understand, but once you do, its beautiful.
- coldtea 9y agoA few people. I would call them shallow in this regard, but that would imply there was something bad with the code in the first place, even if shallow.
- amiga-workbench 9y agoYes, but then after 6 months using it, it really doesn't bother me anymore.