Live data from Hacker News

Objective-C isn't what you think it is

news.rapgenius.com

31–40 of 101 posts

Re: Objective-C isn't what you think it is

#31
post #9
post #8

Personally I think it's an awful idea to use meta-programming without an exceptionally good reason in production code. Like excessive use of function pointers in C. Just because you can doesn't mean you should. Programming in this style causes more code complexity and will accelerate the rate at a which a codebase becomes a mess, not to mention it's really slow.

This has always been my view. New developers (less than 10 years professional experience) seem to become fascinated by "cool" language features that let them do unintuitive things and then approach problem solving with a mindset of "What cool tricks can I do to solve this?" Instead, the experienced developer will always approach a problem with "What is the simplest way to solve this problem?"

New developers (less than 10 years professional experience) seem to become fascinated by "cool" language features

The classic analogy is with young musicians. Just because you can put a fancy ornament in or play real fast doesn't necessarily mean you should. Sometimes it's best to play something simple, so long as it's just the right something simple.

Re: Objective-C isn't what you think it is

#32

i enjoyed this b/c i recently made the jump from ruby to obj-C and, though scary at first, i now feel incredibly comfortable working in obj-C and think i even prefer it. so, that's cool. i do see at the bottom that this post is one of those "inbound marketing for job candidates" things. that's cool, too... but, i gotta say, as soon as i read the sign off, "If you want to work somewhere where..." i thought to myself,…

Isn't Rap Genius basically an online Talmud meant for anything?

Re: Objective-C isn't what you think it is

#33
post #28
post #18

Earlier quoted context omitted.

Sometimes the simplest way is to use a "cool" language feature. For instance: say you have an app with 30 different ViewControllers, and you need them to respond to the same notification. Sure, you could go back and refactor every one to subclass from another class that inherits from UIViewController - but then you need to make that for UITableViewControllers and UICollectionViewControllers, and potentially any other…

http://stackoverflow.com/questions/5272451/overriding-method...

http://nshipster.com/method-swizzling/

Re: Objective-C isn't what you think it is

#34
post #19
post #15

> Objective-C isn't what you think it is A language without namespaces, that's used almost exclusively for iOS apps and nothing else. Nope, that's exactly what I think it is.

The namespaces are inherent in the class name. It's actually a very nice solution. Instead of this Foundation::Array we get NSArray. Way easier to type out, and looks a million times cleaner to me.

Until some other cool library you really want to use happens to also have a NSArray.

With proper namespaces/modules, such conflicts can be usually sorted out by renaming on import. With C and Objective-C, good luck.

Re: Objective-C isn't what you think it is

#35
post #33
post #28

Earlier quoted context omitted.

http://stackoverflow.com/questions/5272451/overriding-method...

http://nshipster.com/method-swizzling/

Was addressing the use of categories to override not method swizzling per se.

Oh, I read your link. So you add more behavior to it, not override it completely.

Re: Objective-C isn't what you think it is

#37
post #8

Personally I think it's an awful idea to use meta-programming without an exceptionally good reason in production code. Like excessive use of function pointers in C. Just because you can doesn't mean you should. Programming in this style causes more code complexity and will accelerate the rate at a which a codebase becomes a mess, not to mention it's really slow.

A sensible compromise to me is that runtime meta-programming should be used to accomplish something sufficiently generic that it can be confined to a library.

Said library can then document (and test) the interface and implementation sufficiently to add a minimal amount of complexity to the application code.

The big red flag is using this stuff in application code to hack around bad design decisions or save on a small amount of typing (there's also no barrier to its expanding and engulfing the entire codebase).

Re: Objective-C isn't what you think it is

#38
post #9
post #8

Personally I think it's an awful idea to use meta-programming without an exceptionally good reason in production code. Like excessive use of function pointers in C. Just because you can doesn't mean you should. Programming in this style causes more code complexity and will accelerate the rate at a which a codebase becomes a mess, not to mention it's really slow.

This has always been my view. New developers (less than 10 years professional experience) seem to become fascinated by "cool" language features that let them do unintuitive things and then approach problem solving with a mindset of "What cool tricks can I do to solve this?" Instead, the experienced developer will always approach a problem with "What is the simplest way to solve this problem?"

Yeah, but what sucks is when you object for the reasons you describe, but your objections are interpreted as you being out-of-touch, afraid of new things, etc. When really it's just a distaste for complexity and magic.

Re: Objective-C isn't what you think it is

#40
post #15

> Objective-C isn't what you think it is A language without namespaces, that's used almost exclusively for iOS apps and nothing else. Nope, that's exactly what I think it is.

And, um, Mac OS X applications. I know that may not seem like a big deal but many major applications people care about seem to have first appeared on Mac OS / Mac OS X (yes, these are two very different things). BTW: namespaces?! Not exactly my go to checklist feature for languages.

"goto checklist feature?"

Does the language have goto? Check. Okay, now let's write a security library! :)

Post reply on HN