Which is the most supported programming language for the iPhone? - iphone

I have decided to start programming some apps for the iPhone that eventually will get submitted to App Store. So I have to use a language the Apple supports.
However, from what I understand, there are some variety of languages I can choose from.
Ansi C
Objective C
C
C++
I started learning C++ in school back in 2001, so maybe I should use that. However, I would like to use the language that is most supported API and community wize. Which one is that?

Here's the low-down:
All iPhone SDK APIs are either Objective-C or pure (ANSI) C. The pure C APIs tend to be the lower-level APIs, so you could use just Objective-C.
However Objective-C is a strict superset of C, so you'll need a reasonable grounding in C in order to write Objective-C.
C++ is fully supported, but is not required (there are no C++ APIs). You can even mix Objective-C and C++ in the same source using Objective-C++. If you do this it's best to use C++ for pure computational components, pure Objective-C for the front-end, and Objective-C++ for the "glue" layer in the middle.
In summary: you'll need C and Objective-C. Use C++ for some parts if you particularly need it.

objective-c is the most supported - all the examples use it

Main language for iPhone platform is objective-c - almost all frameworks are objective-c based so you will have to use it for UI part at least. However as objective-c is a superset of c language you will be able to write some parts of your program using c/c++ as well.

There are C and Objective-C frameworks. Quartz2D is written in C but the Cocoa Touch framework is written in Objective-C, for instance. As Objective-C is a superset of C, if you choose Objective-C you will be able to use all available frameworks without problems.

Depending on what type of applications you're gonna to write, you could save yourself a lot of time & headache and use Appcelerator's Titanium Mobile (JavaScript) or Rhomobile (Ruby). All according to Apples latest TOU and therefore still submittable to the App Store.

The only languages that are officially allowed by Apple are
JavaScript
Objective-C
C++
C
All other languages are not allowed.
Whether or not this restriction is legal is a totally different question. (My gut feeling says that, at least in countries with somewhat sane anti-trust laws, it's illegal.)

Related

Is it possible to use some C source code in iPhone project?

I found a speech synthesizer that supports many languages (http://espeak.sourceforge.net/index.html). But the source code that is available is written in C.
What can i do to make it work on iPhone?
Objective-C is a strict super set of C. Which means you can use any C code in your Obj-C project.
Yes, as long as it's been ported to the LLVM C-compiler. You can create a statically linked framework out of it, and then link into your project.
Apple does not allow dynamically-loaded frameworks.

Objective-C++ for iOS development

Is it possible to use Objective-C++ for iOS application (iPhone, iPad, iPod touch) development?
Are there any examples and source code on the Internet?
Using ObjC++ is quite easy.
You have to declare source files with extension .mm. It will make compiler treat them as ObjC++. The same with headers: use the .hh extension.
There is another option: go to target settings and set Compile Sources As to Objective-C++.
That's all. No additional work is necessary.
Some notes: if you want to develop a native iOS app, then use Objective C. It will save a lot of time.
But in some cases using C++ is more appropriate. E.g. for cross-platform development. So you use only a little bit of Objective C for iPhone or Java for Android just to glue your code with environment. Everything else in C++. I use this for my cross-platform game development.
Another case is performance: Objective C is principally slower then C++. However it is only noticeable during method calls (in ObjC it is called messaging).
Yes, you can. Take a look at the samples and new file templates that Apple provides.

Using c/c++ library that uses network for iphone app objective c

I am currently evaluating if a c/c++ library may be used for a specific iPhone project of mine. The original library makes heavy use of windows specific code (for example it includes windows.h and winsock.h). I am aware that I will have to rewrite the parts that use windows specific code and replace winsocks with for example bsd sockets. Or try to convert to objective-c++ and use IOS specific networking apis as it's recommended in Apple's documentation.
But as it turns out in Apple's documentation, in iOS only C and Objective-C code is allowed for networking. "iOS supports networking code written in C and Objective-C." ( https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/GS_Networking_iPhone/ )
That sounds like I have to rewrite the whole library in objective-c to make it work on IOS. Or would it be sufficient to programm a wrapper class in objective-c and work with the original (adapted to bsd sockets api or objective-c++) library? -> Using C/C++ static libraries from iPhone ObjectiveC Apps
But the actual networking code still would be written c/c++ not objective-c.
Is there any chance this might work? I don't want to do all the work of adapting the library and then notice that this approach does not work.
Has anyone tried something similiar before?
Best regards,
Mike
You should be able to rewrite portions of your C++ library to used BSD sockets instead of the Windows sockets API without any problems.
Apple does not forbid C++ code from accessing the network, however the only networking APIs offered by iOS are in either C (BSD sockets, CoreFundation) or Objective-C (Foundation…), perhaps that's the source of your confusion. You can freely mix C, C++ and Objective-C code in your own code or in statically linked libraries.

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications?

What programming languages can one use to develop iPhone, iPod Touch and iPad (iOS) applications?
Also are there plans in the future to expand the amount of programming languages that iOS will support?
Apple lifted the restrictions on non-Objective C/C/C++ apps -- you just can't load code that isn't in the app bundle.
MonoTouch lets you use .NET languages -- C# is directly supported, but if you have Windows, you can make assemblies in any .NET language and use it.
There are rumors that Apple is going to support other languages directly -- I keep hearing ruby, but they are just rumors.
I think Lua is being used for game logic on a lot of apps.
EDIT (in 2018): Generally you can use any language that you can get to compile for iOS or even install language interpreters. The main thing you cannot do is load code from the Internet that wasn't in the app bundle.
People do this all of the time anyway (see React Native apps loading JavaScript from servers), but, technically, it's not allowed. The main thing that will get you attention from Apple if you make some kind of App Store that loads whole App-like things.
EDIT (in 2020): from #Pylot in comments: I know this is a long time ago, but now at least technically you can load code that isn’t embedded in the app, as you can write with JavaScript using the webview. Not staying your answer is wrong or anything, I definitely agree with you. but I was looking for something and found this post on the way. Figured if anyone sees this it might help them out.
The SDK agreement and App store guidelines have been changed (circa Sept 2010).
You can now probably use any compiled language that will compile to the same static ARM object file format as Xcode produces and that will link to (only) the public API's within Apple's frameworks and libraries. However, you can not use a JIT compiled language unless you pre-compile all object code before submission to Apple for review.
You can use any interpreted language, as long as you embed the interpreter, and do not allow the interpreter or the app to download and run any interpretable code other than code built into the app bundle before submission to Apple for review, or source code typed-in by the user.
Objective C and C will likely still be the most optimal programming language for anything requiring high performance and the latest API support (* see update below), as those are the languages for which Apple targets its iOS frameworks and tunes its ARM processor chipsets. Apple also supports the use of Javascript/HTML5 inside a UIWebView. Those are the only languages for which Apple has announced support. Anything else you will have to find support elsewhere.
But, if you really want, there are at least a half dozen BASIC interpreters now available in the iOS App store, so even "Stone Age" programming methodology is now allowed.
Added: (*) As of late 2014, one can also develop apps using Apple's new Swift programming language. As of early 2015, submitted binaries must include 64-bit (arm64) support.
With plans to slowly retire the long-used Objective-C, Apple has introduced a new programming language, called Swift, for designing apps and applications to run on Apple iOS devices and Apple Macintosh computers.
Apple says:
"Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works."
Introducing swift
What programming languages can one use to develop iPhone, iPod Touch and iPad (iOs) applications?
Ruby, Python, Lua, Scheme, Lisp, Smalltalk, C#, Haskell, ActionScript, JavaScript, Objective-C, C++, C. That's just the ones that pop into my head right now. I'm sure there's hundreds if not thousands of others. (E.g. there's no reason why you couldn't use any .NET language with MonoTouch, i.e. VB.NET, F#, Nemerle, Boo, Cobra, ...)
Also are there plans in the future to expand the amount of programming languages that iOs will support?
Sure. Pretty much every programming language community on this planet is currently working on getting their language to run on iOS.
Also, a lot of people are working on programming languages specifically designed for touch devices such as iPod touch, iPhone and iPad, e.g. Phil Mercurio's Thyrd language.
The programming language of iOS(and Mac OS) is Objective-C and C. You have to use Xcode platform to develop iOS apps, on the next version that is now available on beta release, Xcode 4 supports also C++.
It is also now possible to use OCaml for developing iOS applications. It is not part of the standard distribution and requires modifications provided by the Psellos company. See here for more information: http://psellos.com/ocaml/.
This might be an old thread, but I'd like to mention Appcelerator Titanium, which allows anyone versed in HTML5/JavaScript/CSS to develop iOS applications.
Only Objective-C is allowed by now... but since a few months ago you are allowed to write scripts that will be interpreted in your application.
So you may be able to write a LUA interpreter or a Python interpreter, then write some part of your application in this scripting language. If you want your application accepted on the App Store, these scripts have to be bundled with the application (your application cannot download it from the Internet for example)
see new app store rules
objective-c is the primary language used.
i believe there is a mono touch framework that can be used with c#
Adobe also is working in some tools, one is this iPhone Packager which can utilize actionscript code
You can use "smart BASIC" programming language. It is a genuine but very advanced BASIC language with all its power and simplicity. Using its free SDK, BASIC code can be easily published as a standalone App Store application. There are many apps in App Store, written in "smart BASIC" programming language.

Is programming for Android completely different from programming for iPhone?

I have made apps for iPhone, but want to also code for the Android but want to know if it is first worth my time, second worth my having to learn another language, and third worth the effort in the sense that am I going to make a profit from this. Also if in any way Android code is similar, then will it be hard to bring the iOS (Xcode) files, or copy and paste my iOS code into the Android code.
It's a most definite no. As iPhone Guy pointed out, there's a major difference in the languages both platforms require. iPhone uses Objective-C whereas the Android is based on Java (don't know if it's Mobile Edition or "regular" though). In addition, it's a completely different set of APIs. iPhone uses a modified form of Cocoa called Cocoa Touch whereas the Android makes uses of Google's SDK for it. In answer to your question, you won't be able to copy/paste your code between the languages. Your Objective-C code won't compile to Java and vice versa.
Yes -- programming on the iPhone uses Objective-C while programming for Android is in Java. Although they use similar concepts, the two languages are different.
I was a Java programmer before switching to Objective C. Personally I like Objective C better than Java, but that's just a personal opinion ;)