Hacker News new | ask | show | jobs
by christoph 4105 days ago
I know you & the parent have both been down-voted, but it would be great if you could explain some rationale behind why Objective C is such a disaster in your opinion(s)?

When I first started learning it, I absolutely _hated_ it. With a burning passion.

It is probably now my current favourite and most productive language.

I seem to very rarely write buggy/poor/badly structured code and almost never hit compiler errors/hard crashes unless they are something relatively obscure. It's quite common for me to write 1k+ lines of code, hit build and have exactly what I wanted compile & work pretty much first time.

2 comments

Not OP, and I agree that Objective-C is great. However, it is potentially troubling, from a performance standpoint, that practically everything is allocated on the heap. There's no support in the language for stack-allocated objects, for example. Now that I've used Swift in production, I also really miss generics. Casting to and from containers gets really annoying and unsafe!
"that practically everything is allocated on the heap"

That's kind of the point though. If you want something on the stack, you write plain old C structs or work with primitives. There's plenty of this happening throughout the cocoa frameworks. On the other hand, if you find yourself writing C structures to the heap in objc, you're probably wasting your effort.

> practically everything is allocated on the heap

It has gotten a lot better thanks to tagged pointers: https://www.mikeash.com/pyblog/friday-qa-2012-07-27-lets-bui...

Objective C is mostly used for UI code, and I think it's a fantastic language for that, with its Ruby-like weak typing and strong metaprogramming capabilities.

I think that's just the natural consequence of knowing a language. I can do the same with a JS and a linter. I don't think that necessarily speaks to the bug-free nature of JS!