PDA

View Full Version : Objective C vs. C++/Java




kage207
May 8, 2009, 08:24 PM
Okay, with me just starting to learn Objective C and just looking at some sample code, it just blows my mind. The transition from Java to C++ was really easy since mainly it was just changing the keywords around and learning a little different rules which wasn't much. So I was wondering if it is just me and that I can't even grasp looking at Objective C.

The first time I looked at C++ after I had a class in Java, it was the easiest thing ever for me to transition. Mind you I have never programmed on a Mac in my life. This is the first time I'm learning the system. I've only done console application on Windows. I really want to jump into this stuff so I can start programming in the summer in my free time.

So is it just me? Or why is this so hard? I mean, I guess I knew that it would be a little different since of platform difference and then learning to work outside just one code page because that's mainly what console applications are, one page of code that doesn't really have a GUI.

EDIT: Btw, Hello World for the iPhone was actually pretty easy to do after following instructions on a website.



zmttoxics
May 8, 2009, 11:20 PM
Okay, with me just starting to learn Objective C and just looking at some sample code, it just blows my mind. The transition from Java to C++ was really easy since mainly it was just changing the keywords around and learning a little different rules which wasn't much. So I was wondering if it is just me and that I can't even grasp looking at Objective C.

The first time I looked at C++ after I had a class in Java, it was the easiest thing ever for me to transition. Mind you I have never programmed on a Mac in my life. This is the first time I'm learning the system. I've only done console application on Windows. I really want to jump into this stuff so I can start programming in the summer in my free time.

So is it just me? Or why is this so hard? I mean, I guess I knew that it would be a little different since of platform difference and then learning to work outside just one code page because that's mainly what console applications are, one page of code that doesn't really have a GUI.

EDIT: Btw, Hello World for the iPhone was actually pretty easy to do after following instructions on a website.

Just different syntax. The books will often replace terms like function parameters with message sending or something like that. How you handle your data / algorithms all still applies. Obj-C also allows for C calls, so if you know C++, you should know some C making the transition not impossible.

BlackWolf
May 9, 2009, 05:49 AM
it's not really that hard. it's just a different syntax, that's it. you have strict OOP, messages ... but in the end, it's pretty much the same

BananaDuffle
May 9, 2009, 08:36 AM
You can use Objective-C++ which is allows you to use C++ inside Obj-C by simply changing the file extension from .m to .mm

That's what I'm doing to reduce the amount of Obj-C I need to learn. e.g: I start an OpenGLES project from the template, change the draw loop to suit my needs then just code all my game objects / logic in C++ and have the Objective-C call into my C++ code.

Though I guess it's tougher with a cocoa app where you're going to need to wire up all the interface elements in Obj-C.

"Learn Objective-C on the Mac" and "Beginning iPhone Development , Exploring the iPhone SDK" are great books to get you started.

Compile 'em all
May 9, 2009, 08:47 AM
I am a Java dude and let me tell you this, Objective-C is a pleasure to work with. The syntax is beyond easy and the cocoa touch rocks. seriously!

dejo
May 9, 2009, 04:27 PM
Also, Java was created with C++ in mind and based of its style of notation. Objective-C wasn't.

kage207
May 12, 2009, 01:25 AM
See, I kind of understand that. But I guess, it's more like compiling the files together to make a program. I've only ever made a program as a console application on Windows. So it runs in DOS. I have never made a program that has a GUI or have used any APIs and I'm downloading all the Podcasts, lectures and such from Stanford on iTunesU (but can't get all of 'em because I have 500MB left on my HDD :eek: ).

So ya, that's what I'm more asking about? How does hooking up the coding of your algorithms, functions and more to the touch screen API/GUI? I mean, right now I'm in finals and will be starting to delve into this more.

Cromulent
May 12, 2009, 08:05 AM
Also, Java was created with C++ in mind and based of its style of notation. Objective-C wasn't.

Considering C++ and Objective-C both came from the same language that is a bit of a leap is it not?

dejo
May 12, 2009, 09:42 AM
Considering C++ and Objective-C both came from the same language that is a bit of a leap is it not?
No, it's not. At least not how I see it.

http://en.wikipedia.org/wiki/Java_programming_language#History

Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation.[7]

Cromulent
May 12, 2009, 09:45 AM
No, it's not. At least not how I see it.

http://en.wikipedia.org/wiki/Java_programming_language#History

Well yes, the quote you typed just showed my point.

Objective-C is a direct descendent of C. So is C++.

Java was influenced by C and C++.

Therefore Objective-C, C++ and Java all have a common ancestry and syntactic style.

dejo
May 12, 2009, 09:55 AM
Therefore Objective-C, C++ and Java all have a common ancestry and syntactic style.
True, there is definitely a heritage that comes from C. But when the creators of C++ and Objective-C were adding their OOP layer, they made certain style decisions and did things differently. When Java (or Oak really) was being created it also borrowed from the decisions, the ones that were made for C++.

You must admit that Java is going to look far more familiar to someone comfortable with C++ than Objective-C, right?

Cromulent
May 12, 2009, 09:59 AM
You must admit that Java is going to look far more familiar to someone comfortable with C++ than Objective-C, right?

Of course, but I just took umbrage with the claim that Objective-C was not influenced by the same syntactic style as C++ when if you look a little closer they have more in common than a lot of other languages do.

dejo
May 12, 2009, 10:15 AM
Of course, but I just took umbrage with the claim that Objective-C was not influenced by the same syntactic style as C++ when if you look a little closer they have more in common than a lot of other languages do.
Well, my claim was that Java was not influenced by the same syntactic style as Objective-C. But, of course, there is some influence due to their common C heritage. I guess we just disagree on the extent.

Anyways, dead horse sufficiently beaten now?

Cromulent
May 12, 2009, 10:21 AM
Anyways, dead horse sufficiently beaten now?

http://www.bjacked.net/LuvToHunt/forums/phpBB2/modules/gallery/albums/album01/Beat_Dead_Horse.jpg

kage207
May 12, 2009, 10:54 AM
...And you guys completely missed the second part of my question...

dejo
May 12, 2009, 10:58 AM
How does hooking up the coding of your algorithms, functions and more to the touch screen API/GUI?
Sorry, I don't understand your question. That's really not even a sentence.

kage207
May 13, 2009, 12:26 AM
Haha, sorry. What I'm saying, how does the touch gestures invoke commands of code on a certain part of the screen? Like do you make a file for each area of the screen? Such as a box that displays email, it has if(Swipe) then show delete button? If that makes anymore sense?

firewood
May 13, 2009, 01:43 AM
How to hook up the UI?

Instead of functions checking for things, like swipes, with "if" statements, you have objects, and messages get sent to them (by the OS, UI framework, or you) if the swipe happens to meet the requirements.