views:

362

answers:

6

I'm interested to know your opinion on why Apple uses a language such as Objective-C for app development. Does Apple's app store allow apps written only in this language? Does apple even look at your source-code or does it just care of the binary output?

I learned that most of their app rejection (in the app store) is based upon apps crashing (probably memory leaks in which Objective-c is not very efficient unless you use a GC).

Why not let developers use a safer language, like a scripting language?

I think these are important questions for a developer (I don't even use Apple's products) because it seems like Apple's app store is the MOST successful app sale place on the web.

I'm interested to know why Apple lets developer use Obj-C instead of another safer dynamic language. I know, the iPhone OS api is all Obj-C, but they could easily write bindings for a scripting language.

A: 

Not a experienced developer but, isn't that kind of like asking why Linux is written in C?

Edit: Scripting languages need an interpreter which can mean less performance. Especially with 3d games

Tangrs
Not really. I'm interested to know why Apple lets developer use Obj-C instead of another safer dynamic language. I know, the iPhone OS api is all Obj-C, but they could easily write bindings for a scripting language.
Luca Matteis
Apple have always been with Obj-C. It's used for Mac software development too so why should it be any different for iPhones/iPod touches?
Tangrs
Anyway, my first point still applies. Why do Linux developers let programmers use C instead of a safer language?
Tangrs
In linux you can develop apps in any language you want. Unlike the App store.
Luca Matteis
@Luca: yes, also in Objective-C using gcc ;-)
Arne Burmeister
@Luca Matteis Objective-C is a safe dynamic language as long as you avoid using the unsafe C features.
JeremyP
@Luca Matteis That's hardly related to the topic at hand. C and Objective-C are languages. App store is only a way of distributing the software.As to being able to write Linux apps in any language, it's not strictly true. AFAIK you need wrappers to code in another language under Linux because the Linux headers are written in C.
Tangrs
I suppose all this only means that Apple does not want to install interpreters for langs like ruby, python... and so it is not possible to write apps in these langs since nothing would be able to execute them; so the question is why I can't have ruby on *my* iPhone? It makes it slower? I know it, and I want it... I believe it is all about _control_. Keeping those langs out, Apple can _control_ better what's happening in __their__ devices.
ShinTakezou
A: 

Obj-C is Steves pet language. It was what "NextStep" was witten in way back when for those kool titanium black boxes.

James Anderson
They were magnesium.
Graham Lee
+2  A: 

Does Apple's app store allow apps written only in this language?

Yes.

Does apple even look at your source-code or does it just care of the binary output?

They don’t have the source.

…probably memory leaks in which Objective-c is not very efficient unless you use a GC.

GC is not available on iOS. The reference counting system used for manual memory management is very simple and efficient.

Why not let developers use a safer language, like a scripting language?

All the other issues aside, a “scripting” language would probably be less efficient than Objective-C. Which does matter a lot on a resource-constrained machine like iPhone or iPad.

Objective-C is quite a nice language to work with. The only big downside I can think of used to be that it wasn’t very popular. That means less resources to learn from, but now that so many people are struggling to develop for iOS, things have changed.

I started developing for iPhone about two years ago with very shallow knowledge of Objective-C and Cocoa. Now I am very fond of both. The Objective-C message passing syntax is self-documenting, the optional dynamic typing means less fighting with the compiler when needed, the language is dynamic enough to do interesting things and when I need to, I can always drop down to C, pointers and bits.

I ♥ Objective-C.

zoul
If they don't have the source how do they know the app is using private libraries?
Luca Matteis
They do some kind of analysis on the binary, I’m sure they can see at least the message names.
zoul
AFAIK You can use private libraries as long as they're statically linked to the app.
Joe D
+2  A: 

Apple's guidelines on what applications are allowed on the store are supposed to be a confidential agreement between developers and Apple, though they have been leaked on the web. I'll let you find them, look for "section 3.3.1".

Anyway, why do Apple use Objective-C? I suppose the most obvious answer is the tautological one - because they have lots of experience with using Objective-C. iOS and Mac OS X are both derived from technology acquired when Apple bought NeXT computer in 1996. NeXT had originally licensed Objective-C from StepStone through the late 1980s, then eventually bought all of the rights to the language, technology and trademarks. When Mac OS X was released in 2001, it offered a number of different application environments:

  • "Blue Box", a Mac OS 9 virtual machine where existing Mac applications could run unmodified
  • "Carbon", a C API designed for making it easy to bring Mac OS 8 applications to native Mac OS X
  • "Cocoa", the Objective-C stuff that modern Mac and iOS apps are built with
  • "Cocoa-Java", the same API as Cocoa, but accessed from the Java VM.

So I guess, based on the way your question is worded, you're wondering why we don't use something like Cocoa-Java these days. Well that particular technology was apparently a lot of work to maintain, an investment Apple didn't need to make as developers proved to be happy enough with Objective-C. It's only in the last 3-4 years that Apple have even pushed Mac developers away from Carbon. So you've got a Mac platform where developers are happy with Cocoa and Objective-C, including the engineers at Apple. Now you need to write a mobile phone OS, applications and the SDK to let ISVs write their own apps. Which would you choose?

Notice that on the Mac we also have BridgeSupport, that makes it easy to access the Objective-C runtime from Ruby, Python and any language with appropriate dynamic binding. That's not possible on iOS. I can only guess why, I think it would make static analysis of submitted apps much harder.

Graham Lee
"That's not possible on iOS. I can only guess why". My guess would be that ruby and python are not installed on iOS. If they were, even in the form of an embedded run time in the app itself, it would make it trivially easy to add scripting support to your application.
JeremyP
@JeremyP: you just argued out of giving an answer though. If ruby and python are not installed it's because Apple didn't install them, now why?
Graham Lee
Given that they (Apple) specifically disallow dynamic scripting in apps, it wouldn't make a lot of sense to include a language (more or less) designed to allow such.
RHSeeger
+2  A: 

Disclaimer: I have never written any program in Objective-C.

From Apple's point of view, Objective-C has

  • Technical advantages:
    • Object-oriented
    • Lightweight in features (unlike C++)
    • Lightweight in runtime (no VM or interpreter)
  • Historical advantages:
    • Used since the days of NeXT for GUI applications
    • Preferred language for programming to Cocoa's APIs on the Mac - as such, there is a great amount of experience available at Apple and in the Mac developer community.
    • Big amount of infrastructure invested by Apple in Clang in order to make Objective-C as fast as possible.

Apple wanted the iPhone experience to be as smooth as possible: as such, interpreters and VMs were not ideal because there will always be a non-negligible overhead, consuming memory and CPU/battery - and both of these resources are extremely limited, even on today's smartphones.

jhominal
+2  A: 

I think this is more political / economical than technical.

If you let people develop in python for the iPhone, for instance, soon they would lose control of their device. If I have a python interpreter on my phone, I can just download 'text' and run it thus cirumventing the store.

Apple does not like the circumventing :0

Tom Schulz