Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Why Objective-C Only?

Coming from a background of C# and Java, the Objective-C syntax can take quite a bit of getting used to, especially if you're not working with it on a daily basis. I'm wondering why Apple doesn't offer other languages that build natively. It would be really awesome if Apple had an implementation of Java that didn't require a JVM.

Posted on Oct 16, 2013 5:52 AM

Reply
Question marked as Best reply

Posted on Oct 16, 2013 6:57 AM

Alas, the Objective-C syntax is probably the easiest part of the Apple development ecosystem to learn and get used to. If you are fixated on that, you haven't gotten to the difficult parts yet.

10 replies

Oct 16, 2013 9:56 AM in response to cr0B4r

cr0B4r wrote:


Hmm... I haven't gone too far, but would you mind giving me an idea of some of your horrific experience? I'm wondering if it's worth giving Objective-C a shot.

I never said anything was "horrific". I just said that syntax is a very basic concept. I guess I don't understand the idea behind "giving something a shot". It is the best tool for the job. If there was a better tool, people would be using that instead. Isn't that self-evident?


Apple is struggling to keep up with the size of its developer community. It doesn't really care if people are scared off by syntax.

Oct 18, 2013 8:17 PM in response to cr0B4r

I'll give you one example. I have lots of C# experience and some Java experience. In both of those languages writing web service clients for REST or SOAP endpoints is fairly straightforward because their core libraries provide lots of native support. Getting the response value from a service method might only take a few lines of code, and the request parameters and response are transparently serialized/deserialized. Objective-C (Cocoa) has native HTTP request/response support but you must either build your own web service client to get equivalent features (ideally with robust error handling, reachability detection, background operations, etc.) or find a suitable 3rd-party library and hope it continues to be supported.


I found Objective-C harder to learn than I expected, but that was my error in assuming it would be similar to C# or Java. Fortunately I started learning just when ARC was added, so I didn't get bogged down as much by memory management issues that remind me of straight C programming. The Objective-C language features and syntax are very nice, as is the Xcode IDE (although I am spoiled by Visual Studio). The Apple developer documentation is good, sometimes not very detailed but is well-organized and easy to read.


I agree with etresoft, that learning Objective-C syntax is much easier than learning something like how to use Core Data effectively or how to store sensitive settings in the keychain.

Oct 19, 2013 10:04 AM in response to Llessur999

Llessur999 wrote:


I'll give you one example. I have lots of C# experience and some Java experience. In both of those languages writing web service clients for REST or SOAP endpoints is fairly straightforward because their core libraries provide lots of native support. Getting the response value from a service method might only take a few lines of code, and the request parameters and response are transparently serialized/deserialized. Objective-C (Cocoa) has native HTTP request/response support but you must either build your own web service client to get equivalent features (ideally with robust error handling, reachability detection, background operations, etc.) or find a suitable 3rd-party library and hope it continues to be supported.

I don't know. It seems to me like the opposite is true. There is only the most basic HTTP request/response support available and those are all in C. For example, I am writing a server right now and I had to write pretty much the whole thing by hand. If you are writing only the client side, there is a great deal of higher-level Objective-C support. You can create an input stream directly from a URL, feed that right into NSJSONSerialization, and get a ready-to-use dictionary.


NSDictionary * values = [NSJSONSerialization JSONObjectWithStream: [NSInputStream inputStreamWithURL: @"http://www.example.com/rest/resource/foo" options: 0 error: nil];


I admit I haven't worked with the client side very much, but it leaves me pretty envous. I sure wish there was something like that to parse a stream of incoming requests.


I agree with etresoft, that learning Objective-C syntax is much easier than learning something like how to use Core Data effectively or how to store sensitive settings in the keychain.


Yes, more or less. It is the complex Apple architectures that are the most difficult. Core Data is a prime example. The code is irrelevent. It takes quite a while just to understand the concept. I'm still not there yet. The NSDocument architecture is one that I'm currently struggling with. If your documents are super-simple and can fit in a single NSData, then it is super easy. But if you need anything "special", then you are essentially cast naked into the wilderness to start a civilization with a piece of flint that has an Apple logo. In contrast, I found the keychain quite easy to use. I guess it depends on what kind of code you are writing.

Oct 20, 2013 10:17 PM in response to Llessur999

Working with high-level programming languages, such as C# and Java, without the basic knowledge of object-oriented programming with a somewhat lower-level language, such as C++, does not make one a good programmer. In my opinion, an expert programmer should be able to manage the memory by hand. In other words, If you don't know how to program in C, and if interested in OOP, how to program in C++, you always lack the fundamentals of how the memory works. This is the main cause of trouble for those people like you.


And also, don't forget that Objective-C is a dynamic language, as opposed to Java and C# which are totally static. Dynamicity of a language provides the programmer with a power to design and implement patterns, not possible in opposite languages.


When I started to work with Apple development technologies, I was in a situation similar to you, but with a difference: I knew how to manage the memory. May be ridiculous, but I don't even use ARC, or garbage collector (in Mac OS apps). I prefer to do the job by hand.


All of these was for telling you that memory management is not as frustrating as people say, or as it appears. Take some time, and learn to design and develop object-oriented programs in C++, if you want to be a professional programmer. C++ is the only language that gives you such a necessary understanding.


If you are interested in the topic, feel free to let me know and I will give you some information useful to get started with.


I am sure you are now thinking about: So, what is the difference? Is there anything that is straightforward to implement in C++ and not in C#?


The answer is: Maybe nothing... almost all you can do in C++, is possible to do in C#. The difference is in how you think about the solution, and how you design your classes, as there is no magic wand to remove the garbages from memory. You are responsible for everything. This is one of the reasons why C++ programs are so much faster than C# or Java equivalents.


Message was edited by: Mani Hamedani

Oct 21, 2013 12:26 AM in response to Mani Hamedani

I've done some C/C++ in college, but haven't had any practical experience with it. I understand the basics of memory management and working with pointers. I guess I've just taken frameworks for granted and there are a lot more steps involved to achieve the same objective when working with Obective-C. I don't have a problem learning the syntax much. My biggest problem is I don't have enough time to work with it. I'd love to go into it full time, eventually.


As far as OOP goes, I'm pretty well versed with that as well as my design patterns. Obviously working with a more dynamic language is new to me. I don't have a problem picking up on new languages and frameworks and I don't have a problem with methodologies either.


Since Objective-C is a C superset, I figure I should know my C programming pretty well. I understand all of the basics of C, but are there any advanced C concepts that are used often that I should familiarize myself with? Also, if I'm using C and Objective-C, do I really need to worry about C++?

Oct 21, 2013 2:17 AM in response to cr0B4r

As far as Objective-C is concerned, you don't need C++, but I just recommend it, because doing programming in C++ in practice, makes your object-oriented skills stronger than doing the same in any other programming language.


There are a lot of books and resources to learn to program for Apple devices. You should know that after learning to program in Objective-C, which is nothing special other than doing OOP in C, you should learn about Cocoa, it's architecture, design, and huge class library used to create applications for Mac OS X. And to create apps for iOS, you need to be familiar with Cocoa Touch, the litle brother of Cocoa.


My recommendation:


Books:

1. Objective-C for absolute beginners - Apress

2. Learn Objective-C on the Mac - Apress

3. Programming in Objective-C 2.0 - Adisson Wesley (recommended by most programmers)

4. Learn Cocoa on the Mac - Apress

5. Cocoa Programming for Mac OS X 4th edition - Adisson Wesley

6. Cocoa Design Patterns - Adisson Wesley (Very important to read - it is about OO design patterns used in Cocoa)

7. Pro Objective-C Design Patterns for iOS - Apress (I have not yet read it, but I think it is good)

8. Beginning iOS 6 Development - Apress (There are a lot of books on iOS programming out there. I have not read this one yet, but I think it is good to take a look at.)

Dec 22, 2013 12:22 PM in response to Mani Hamedani

Hi Mani . I'm from Iran like you .

I want to learn Objective-c and how to use it in XCode 5 . But I don't know what is the starting point for me .

I live in Iran and I am a IT student , But its so hard for me to read english books or Apple prepaird guids beacuse my bad english makes me bored . 😟

As you said I have to learn C++ first of all .

Which book do you recommand in persian ???

And what aboat Objective C ??? Is it bad to learn it first of all ??

I had some experiences in C and C++ just in university . Is it enough ???

This is my e-mail : javidansalarian@yahoo.com

Please help me .

I wrote this text in english beacuse of the other members .

Thanks Mani .

Why Objective-C Only?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.