OSX programming questions.

Posted:
in macOS edited January 2014
Ok as some of you might know my home is not blessed by OSX. Some day that will change but not anytime soon. Anyhow. I have a small amount of experence programming in Java and I want to look into other languages. So here is a few questions.



1- Coca, and Carbon are both frameworks. So I would be programming in Objective-C, right?



2- Having only a little taste of Java, I am very new to the idea of frameworks. How are they used?



3- How easy would it be to port a program written in Objective-C to OSX? What kind of libs should I be looking at to make a port easy? (noting that I am running Linux on a x86 box)



4. Do yo know of any websites, books or other media that I could read on this topic?



I would like to start playing around with another language now, on my Linux box, then when I get a new Mac I want to port some of my programs over. This is mostly a personal learning experence thing, I don't plan to be a code monkey (hope nobody gets offended by that) when I grow up.



Thanks for your time.

Comments

  • Reply 1 of 12
    chychchych Posts: 860member
    Cocoa and Carbon are APIs, Carbon is done in C/C++, Cocoa is done primarily in Objective-C, secondarily in Java, and can call C++/C routines.



    The Nextstep API (Cocoa) is probably a lot different from what you get in Linux, I don't think porting will be that straight forward (but I don't really know).
  • Reply 2 of 12
    Thanks..



    I did not expect them to be the same as in Linux... not by far. I was just wondering about how easy it would be to port a program from one platform to another. Or more importantly, what could I do to make that process as easy as possible?
  • Reply 3 of 12
    costiquecostique Posts: 1,084member
    Quote:

    Originally posted by \\/\\/ickes

    1- Cocoa, and Carbon are both frameworks. So I would be programming in Objective-C, right?



    See System Overview.



    ObjC is a superset of C, so to learn ObjC I highly recommend starting with plain old C, because nearly all C tricks work fine with ObjC. Cocoa API is mostly ObjC/Java with some C-style functions also available. Carbon is C/C++ API, as chych said. You can mix ObjC, C and C++ as languages and you can use Cocoa and Carbon together as frameworks (see below). Cocoa API exists in 2 flavours: ObjC and Java. These flavours provide very similar functionality. See System Architecture.

    Quote:

    2- Having only a little taste of Java, I am very new to the idea of frameworks. How are they used?



    Frameworks are essentially dynamic libraries conveniently packaged with their corresponding header files in a standard directory structure chunk. See Frameworks Overview.

    Quote:

    3- How easy would it be to port a program written in Objective-C to OSX? What kind of libs should I be looking at to make a port easy? (noting that I am running Linux on a x86 box)



    There is GNUstep, which is nearly a clone of Cocoa. And it's open source!

    Quote:

    4. Do yo know of any websites, books or other media that I could read on this topic?



    1. Apple's Reference Library

    2. CocoaDev

    3. Cocoa Dev Central

    4. O'Reilley MacDevCenter

    5. Mamasam Cocoa mail archives



    Hope this helps.
  • Reply 4 of 12
    Thank you costique.



    That was very informative.



    If anyone else has something to add, feel free to respond.



    Thanks again.
  • Reply 5 of 12
    rraburrabu Posts: 264member
    Keep in mind that GNUstep is behind Cocoa. By that, I mean that as Apple adds stuff to Cocoa and changes it, the open source community is always playing catch up to make GNUstep the same. The other way doesn't happen since if the open source community added stuff to the API, chances are Apple would not adopt it. This means that pretty much everything implemented in GNUstep is a copy of stuff implemented in Cocoa. Which makes porting from GNUstep/*nix to Cocoa/OSX not too hard. However, going from Cocoa/OSX to GNUstep/*nix may be difficult depending on what pieces of Cocoa are used (if the developer knows this port will be done, then you would restrict yourself to stuff implemented in both environments).



    The other caveat is with Apple's NIB files. I believe GNUstep uses GORM files (check their website) and I don't know if you can translate from one to the other (endian issues, Apple not opening up the file format of NIB, etc.). But I think a tool might exist. Once again, check the GNUstep website's FAQ about this. These files specify what the user interface looks like and what kind of hooks to your code exist. NIBs are created with Apple's Interface Builder, a rapid design tool. You could always code up the entire interface similar to what you can do with Java.
  • Reply 6 of 12
    marcukmarcuk Posts: 4,442member
    Can someone tell me if you get the developers CD with new macs still. I think It has Gcc 3.3.



    Is GCC a fully integrated IDE environment (like realBasic) or is it just a compiler? If so, how do you program OSX widgets?
  • Reply 7 of 12
    Whoa, MarcUK! I think you've totally missed two biggest items of Mac OS X's developers tools:



    Xcode and Interface Builder



    Xcode:





    Interface Builder:





    That's your IDE right there. GCC is just the (open source) engine behind it. GCC is "just a compiler" as you said. You can run it from the command line with makefiles if you want. If you want to work on a project, though, you're really better off using Xcode.



    The developer tools should be included with every Mac today. If they're not on their own CD, they should be included on the Software Restore CD.
  • Reply 8 of 12
    marcukmarcuk Posts: 4,442member
    Quote:

    Originally posted by Brad

    Whoa, MarcUK! I think you've totally missed two biggest items of Mac OS X's developers tools:



    /snip/



    That's your IDE right there. GCC is just the (open source) engine behind it. GCC is "just a compiler" as you said. You can run it from the command line with makefiles if you want. If you want to work on a project, though, you're really better off using Xcode.



    The developer tools should be included with every Mac today. If they're not on their own CD, they should be included on the Software Restore CD.




    most likely! I havn't had a mac for 18 months, I was thinking of buying a g5, then a g4, but now Im thinking of an iBook, so I can sit in bed and work through, "Sams, teach yourself C++ in 21 days"



    I guess its OK to use C++ on GCC, Im confused now, does it only compile Objective C now?
  • Reply 9 of 12
    cooopcooop Posts: 390member
    You can still compile C and C++ code using gcc and g++ (respectively) within the Terminal.
  • Reply 10 of 12
    zapchudzapchud Posts: 844member
    No need at all to use the terminal. Xcode will compile the code for you right away. :-)
  • Reply 11 of 12
    jbljbl Posts: 555member
    A few things:

    First, how easy things are to port depends a lot on how much of your code is manipulating the interface. A command line tool should just require a recompile. A word processor, on the other hand, will be a lot more work (unless you have written it using GnuStep).



    Second, since you can mix Cocoa and Carbon, choosing one over the other really means choosing your event structure. In Carbon you are responsible for polling and dispatching system events, while in Cocoa you basically create objects that respond to events and "the system" (really the more basic framework objects like NSApplication) deal with sending them to you as appropriate. (I am sure some more experienced programmer can give you a more technical description; as a hobbyist at best that is how I think of it).



    Third, a question, is there a good tutorial someplace on xTools. I pretty much know my way around Project Builder but the few times I have looked at xTools I have been intimidated so I still do what programing I do on Jaguar.
  • Reply 12 of 12
    karl kuehnkarl kuehn Posts: 756member
    JBL: xTools is a package from Tenion, that includes Apache and X11 (among other things). You are thinking of xCode, and it is just the newest version of ProjectBuilder. There are a whole number of new things to discover, but most of them can wait. The only thing you really be aware of is that if you are going to build apps to give to other people you need to set the build style to "deployment" when you are actually going to give them to others. You really should have done this in ProjectBuilder, but you could get away without it. In xCode is is manditory.
Sign In or Register to comment.