4 ms·
I don't think these are the real problems with Objective-C. To quickly address this issues, before discussing the real problems: "Ugly" - get over it, "Verbose
by DrJokepu 15y ago
I don't think these are the real problems with Objective-C.
To quickly address this issues, before discussing the real problems: "Ugly" - get over it, "Verbose" - get over it, "Memory Management" - Obj-C memory management is in fact super simple as long as you follow some really simple rules, especially with ARC.
Now the real problems I have:
1. Lots of unnecessary code. With the old runtime, you had to modify your code at four (!) places to introduce a new property in a class. With the new runtime, that has decreased to three, with ARC, to only 2, but that's still one more than what should really be necessary (@synthetize should go).
2. The whole header file thing. I know that Obj-C is a descendant and strict superset of C but I still find separating header files from .m files somewhat tedious and unnecessary. This leads to
3. Having to declare methods and properties before you use them. I mean, this is 2011, this shouldn't be necessary.
4. The syntax for having "private" methods and properties is awkward even by Obj-C standards. Basically you have to create an anonymous category in the implementation file.
5. Properties (with ARC) should default to strong for objects, assign for everything else.
6. The [[X alloc] init] way to construct objects; I understand that from a theoretical point of view it's cool to separate allocation from initialisation but I've never ever needed to allocate an object with anything other than the alloc message.
7. The debugger. GDB and Xcode are atrocious. Have a look at the C# debugger in Visual Studio; that's how a debugger should look like.
Overall, while a lot has been improved recently in Obj-C, my main gripes with the language all come from the facts that it's a C superset (which is also a massive advantage) and that it's an almost 30 years old language; the programming world was very different 30 years ago.
- chriseidhof 15y agoVery true, all of this would improve the language a lot. I have often thought about writing a language that does these kind of things and compiles to Obj-C. Also, I would love to be able to do some kind of metaprogramming without resorting to strings.
- domhofmann 15y agoI'm trying to do just that with a project I started a few days ago called Khaki. It's a bit of a learning exercise and quite early, but you might find it useful in a month or two. https://github.com/dominikhofmann/khaki https://github.com/dominikhofmann/khaki
- 0x09 15y agoAbout #7: since the last WWDC, it looks like they will be strongly pushing http://lldb.llvm.org/ http://lldb.llvm.org/ Once it matures I expect the Xcode debugging experience will become quite a bit different from the current (flimsy) gdb shell-out.
- bonch 15y agoApple still plans to make synthesize the default behavior in the future, but they encountered problems of C ambiguity that prevented it from shipping for Lion. I don't think how old the language is matters, especially since it has seen several major updates in recent years.
- pornel 15y ago7. `[X new]` works.
- seanalltogether 15y ago7. Additionally, automated file importing needs to be added to xcode. 8. Global space is polluted with constants and enums