Live data from Hacker News

Stop the Hate: Obj-C Deserves Your Love

intridea.com

31–40 of 91 posts

Re: Stop the Hate: Obj-C Deserves Your Love

#31

One of the limitations of Objective-C, the inability to create a function with a variable length argument list ... Erm, not true. For example, NSString's + (id)stringWithFormat:(NSString *)format, ...

How do you create such a function though? stringWithFormat is built in.

Re: Stop the Hate: Obj-C Deserves Your Love

#32
post #16

Didn't see a single explanation of why the language deserves my love. Let's see. * The language is verbose. * Practically speaking, it's only used to developer for two platforms (OSX and iOS). * The frameworks for those platforms are MEGA verbose. * The memory management model for the iOS platform is not GC, and it's not manual management. Frankly I found manual management of memory simpler than retain/release. And t…

I agree with all your points but this one:

The memory management model for the iOS platform is not GC, and it's not manual management. Frankly I found manual management of memory simpler than retain/release. And the autorelease pool? That's just wrong.

retain/release + autorelease pools solve the ownership problem inherent in manual memory management system. You can return a heap allocated object from your function/method and neither you nor the caller have to be concerned about how it will be cleaned up.

Not sure what's wrong with that solution -- I've even implemented/used an equivalent implementation for pure C code.

Re: Stop the Hate: Obj-C Deserves Your Love

#33
post #24

As someone who has been, on and off, writing Objective-C for the past decade, I will unequivocally state that as application programming languages go, it's a terrible 1980s jalopy of bad language decisions cobbled on top of more bad language design under which Smalltalk-descendent ideas peek through now and then. Language research has progressed. Microsoft has invested heavily in C# and related technologies. Even Sma…

As someone who does a ton of Objective-C, I challenge the notion that namespaces are even remotely necessary. I've also done development in nearly everything under the sun, in nearly every "popular" language under the sun, which challenges your other assumption that anyone who thinks Objective-C is good hasn't spent time outside of C/C++/Objective-C.

I'm guessing you've never written a Windows app with C++ and MFC. Or have done any hardcore UI development in C# or Java - both languages that are easily way more verbose - and require way more boilerplate - than Obj-C.

My assumption is that you simply don't grok it, that you haven't learned how to utilize dynamic dispatch, KVO, etc. to greatly simplify and streamline your application designs. Or you are one of those script kids that takes all the low level shit for granted. This isn't python. This isn't ruby. This isn't even smalltalk. It's a high level layer on top of a low level language. You don't get that kind of performance without some sacrifice, but rest assured that sacrifice is significantly less than C/C++ while maintaining similar or the same performance.

Re: Stop the Hate: Obj-C Deserves Your Love

#34
The worst part is Apple forces you to use Objective-C on the iPhone even if better options exist. I created a Lua/Cocoa bridge http://probablyinteractive.com/2009/10/18/Setting-up-iPhone-... that works wonderfully. It considerably cuts down the amount of code I need to write, but Apple forbids me from using it on the iPhone.

Re: Stop the Hate: Obj-C Deserves Your Love

#35

I don't understood why people think automatic deallocation = garbage collection = slow language. You can have reference counting without garbage collection. It's pretty obvious to a compiler when a variable has gone out of scope and can be dereferenced (and deallocated immediately at 0). Using a language like obj-c where you have to do memory management manually just seems so archaic after using modern languages. Plu…

First, even the "manual" version of garbage collection (the retain/release) pattern is pretty trivial with Objective-C (more so with the new property syntax). Once you know the rules it was pretty automatic and really didn't cause that many problems. It was more a problem with the "checklist" language comparisons. The "property duplication syntax" (I assume you mean the declare versus synthesis) is there for flexibil…

Objective-C's retain/releasing is only trivial if you're doing fairly simple stuff. Ever create a circular reference with objects? Ugh...

Re: Stop the Hate: Obj-C Deserves Your Love

#36
The discussion for another article on the front page discusses why, even today, many developers prefer C-family languages over Java for developing user interfaces, because of unpredictable delays in responsiveness with garbage controlled languages.

In that context, Objective C is the closest you will find to a best of both worlds language for responsive user interfaces. Being a strict superset of C, you can control the performance characteristics of your application to your hearts content. With SmallTalk style message passing, you can implement highly dynamic object oriented designs.

The warts that come along with this are the places where C still pokes through when you just want to work in a high level object oriented context and things like header files and static variables rear their ugly heads.

Re: Stop the Hate: Obj-C Deserves Your Love

#37

One of the limitations of Objective-C, the inability to create a function with a variable length argument list ... Erm, not true. For example, NSString's + (id)stringWithFormat:(NSString *)format, ...

How do you create such a function though? stringWithFormat is built in.

http://developer.apple.com/mac/library/qa/qa2005/qa1405.html

Re: Stop the Hate: Obj-C Deserves Your Love

#38
post #26

I'm supposed to be impressed because Obj-C does reference counting? It really is sad that so little of the state of the art in GC is available in mainstream languages.

I'd say he more aiming to comfort than impress . The good part is that because of the homogenous paradigm there are three rules to learn about when to retain/release. You find them, read them, think about it for 10 minutes, and then get on with programming. You could contrast it with malloc/free in the unix/C ecosystem. Get a pointer back from function X in library Y. What do you do when you are done? free? call X_Z?…

Cheering about doing better than malloc in 2010 is like being happy that you can outrace a Model T in the Indy 500.

Re: Stop the Hate: Obj-C Deserves Your Love

#39
post #24

As someone who has been, on and off, writing Objective-C for the past decade, I will unequivocally state that as application programming languages go, it's a terrible 1980s jalopy of bad language decisions cobbled on top of more bad language design under which Smalltalk-descendent ideas peek through now and then. Language research has progressed. Microsoft has invested heavily in C# and related technologies. Even Sma…

This is exactly why I haven't taken a serious look at cappucino. Why impose that cruft on javascript?

Re: Stop the Hate: Obj-C Deserves Your Love

#40

One of the limitations of Objective-C, the inability to create a function with a variable length argument list ... Erm, not true. For example, NSString's + (id)stringWithFormat:(NSString *)format, ...

How do you create such a function though? stringWithFormat is built in.

Like any other vararg function:

  + (NSString) stringWithFormat: (NSString *) format, ... {
      NSString *string;
      va_list ap;
  
      /* Fetch the arguments */
      va_start(ap, format);
      // Could iterate over the arguments yourself here, or just use:
      CFStringRef cfString = CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef)format, args);
      string = [NSMakeCollectable(cfString) autorelease];
      va_end(ap);
  
      return string;
  }
Post reply on HN