Codetown ::: a software developer's community
Is Objective-C a step backwards in terms of memory management? Why does Apple use it despite advances in the language realm? I heard the other day that Java would give people some sort of unfair abilities in the App store. Not sure. But, people I know (Kevin Neelands, for one - check out his best selling Periodic Table of the Elements - free!) tell me Objective-C is agony in terms of pointer arithmetic. Thoughts?
I recently downloaded Scan, a QR-code decoder and Square, a credit card processing app from the App store. These apps are the best of the 21st century, IMHO. What are yours? Scan lets you scan a QR code (above) and it takes you directly to the embedded URL (or whatever - phone number, text, etc...) Square revolutionizes cellphone use for payment processing at less cost than PayPal. GasBuddy is a map based mashup. You'll see variations on these ideas in many apps to come.
I've used an Android phone and didn't like the GUI. Maps are clunky and maps are my favorite iPhone app. Many people tell me that, because I organize JUGs, I should be on an Android phone. I like the best available, so I go with iPhone. Even though I pay nearly $150/mo for my contract (includes one traditional phone at 800 min/mo ea).
When it comes to programming languages, 'better' is a relative term. I think Java and Objective-C are best used for specific purposes.
Objective-C is older, that is true, however it offers dynamic programming (categories, dynamic typing, forwarding) along with message passing, as well as low-level C pointers, in a compiled environment. I would say Objective-C is definitely offers more 'power to the programer' at the language-level to the programmer, at the cost of the programmer has to be more diligent in regards to memory management.
Java is more modern and removes most of pitfalls of memory management from the programmer. Java empowers the programmer via the Java API, which is quite powerful, instead of at the language-level.
If someone has just recently graduated from college, they would easily start coding with Java, since the language-level constructs are simple easy to understand and its API is very powerful.
However, that same person would have a difficult time with Objective-C since it would require vastly more low-level language-level knowledge of the constructs, to understand how to use effectively. Also add to the learning-curve, the need to learn the vast Cocoa API (Core Data, Foundation, Core Graphics, UIKit, etc)
From an engineering point of view, I think Objective-C provides more language-level control and capabilities with a steep learning curve that is not forgiving to multi-platform programmers.
I would guess that Apple will continue to use Objective-C since Apple can use its steep learning curve to filter out multi-platform programmers from the Apple ecosystem.
@Kevin: I think Jobs was referring to Java on the desktop and IMO he is right. How many popular desktop apps are written/being written in Java? Apart from IDEs and developer tools, there are very few popular desktop apps being written in Java.
And I don't know about that particular app of yours, but NetBeans and JDeveloper's UIs are very ugly on OS X. IDEA looks good but does not look like a native app at all and ditto for Eclipse.
I'm not sure of the history, but a retain count model is at least a step up from C's alloc/free, allowing memory allocation to be controlled by the object.
Garbage collection basically frees the programmer of the work of worrying about memory at the cost of increased work for the execution environment. This has been easy trade-off in the days of fast CPU's and larger sets of RAM on desktops.
The iPhone, however, is a fairly weak device in comparison to any desktop of the last 5 years. The RAM is minuscule and the CPU power low. It is easy to overwhelm the device's resources.
Sure, the memory management may seem like a step back, but its partly because the hardware resources are also a step back... from a desktop.
As for pointer arithmetic, it is still a C-based language underneath. So it is no harder than any other C-based language.
Even for someone who was programming on a Mac OS desktop, there is enough missing in iOS to make work difficult at times.
As for language gripes in general, there are plenty of times when I wonder why I am still editing plain text files to create software? The coding environment has come along some over the years with syntax coloring and code-folding, but it still seems clunky.
Mike has already stated my view on Objective-C - it may have been state of the art 20 years ago but I find it horribly dated and difficult to use now. At work I am working on two versions of the same program - an Objective-C version for the iPad and a Java version for laptops. I cannot see any difference in performance, to my eyes the java version using Swing is better looking that the Objective-C version using Apple's GUI widgets, and I estimate the Java development time to be 1/3 the time spent on the Objective-C version. To add to the frustrations the Java bytecode was developed with RISC architectures like the ARM in mind, and my understanding is now the ARM microprocessor has a Jazelle mode with means approximately 70% of the java bytes codes have a one-to-one correspondence with the ARM op codes so the JVM does very little interpreting. The Android development environment using a Java variant looks quite appealing and I'm trying to get more familiar with it. The main difference is layout managers are largely replaced with an XML based layout system. The other difference is they are careful to explain their Dalvik (?) system is not a JVM per se. - I gather it is more a very simple-minded system to split the few Java opcodes that don't go directly to the ARM into macros of 3-4 opcodes. (I'm speculating a bit).
When I do a web search on the question a quote by Steve Jobs always comes up in which he publicly stated that no one used Java anymore because it had become too heavy and cumbersome. I think he got C++ and Java confused, and my understanding is Mr. Jobs one fatal flaw is his refused to admit mistakes that he made.
Bottom line, if Apple would adopt a Java based development platform like Android has in addition to their Objective-C X-Code IDE it would greatly reduce the man-hours put into iPad apps.
You need to be a member of Codetown to add comments!