Difference between Mac and Windows Programming

Discussion in 'Mac Programming' started by cybrscot, Feb 17, 2011.

  1. cybrscot macrumors 6502

    cybrscot

    Joined:
    Dec 7, 2010
    Location:
    Somewhere in Southeast Asia
    #1
    I know that the Mac and the PC use different software. Sometimes it's written for the WPC, and not the Mac, and vice versa. But what's different about the programming? What needs to change to make a previously "windows only" program available for the Mac, and vice versa.

    Can both OS have programs that were written in traditional C? On another note, I also think of Objective C as being for Mac. Am I wrong? Can Obj C programs also be written for the Windows PC?

    I'm writing programs in C on my Mac, using Text Wrangler and Terminal. Can these programs only be run on my Mac, or are these "simple" beginner programs universal for both?

    Thanks
    Scott
     
  2. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    So far yes.

    Once you start using lots of header files from libraries (as in your other thread) you may run into some conflicts where functions are slightly different on the two platforms and you need to deal with that.

    B
     
  3. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    The C portion of the program can be exactly the same. The problem is using any OS function calls (except perhaps for a few common posix calls) or using any UI API. These are often completely utterly incompatibly different. So different that there can be no 1-to-1 translation much less complicated that running a whole VM hosting most or all of the alien OS.

    Developers can get around this by writing their program in 2 parts, one part that does zero OS, IO, or UI calls, in say just plain ANSI C, and the other part native to the UI/OS frameworks, say using C#/win32 APIs, or Objective C/Cocoa, or C++/Xwindows, etc.

    You will have to recompile even the portable part on each platform as the binary and linker formats used are different.

    Then connect the portable and non-portable parts together.

    Easier said than done sometimes.
     
  4. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    Objective-C, the language, is available for Windows as part of the Windows port of GCC. It's not provided by Microsoft's tools though.

    However, by Objective-C, you probably mean Objective-C + the Cocoa libraries. There an implementation of Cocoa available for Windows called GNUstep. I've never used it though.

    You could use C and a cross-platform library like GTK, or use C++ and Qt or wxWidgets. These cross-platform libraries will "translate" a common set of functions into the platform-specific functions. You'd still need to be careful that the non-GUI parts of your program are pure C or C++ so they can be compiled on both Mac and Windows.

    The problem with the cross-platform libraries is that applications written under these often don't feel quite right to the users. Mac users expect apps to behave differently than what Windows users -- beside not having the computer crash reguaaly :p -- and the cross-platform libraries don't adjust for all of the differences.

    This is the advantage of firewood's suggestion. With firewood's suggestion, you build separate UIs for each platform, and they can behave and look radically differently if need them to. But that means you need to learn multiple language and APIs, and an increased maintenance burden.
     
  5. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #5
    The folks behind GNUStep claim it is very nearly fully compatible with Cocoa. You can install it on numerous different platforms in order to run Objective-C applications built again the Cocoa frameworks. However, if you use any of CoreFoundation, CoreServices, WebKit or some other Mac OS API features, you might be SoL.
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Isn't Webkit OSS anyhow? http://www.webkit.org/

    EDIT: There's also Cocotron http://www.cocotron.org/

    B
     
  7. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #7
    One big difference you'll notice is that Microsofts documentation sucks. I can't tell you how amazed I was the first time I started programming on Mac and looking at Apples documentation. I was floored by how awesome it was.

    I'm not sure if others share my enthusiasm but I was impressed.
     
  8. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #8
    However, I have not seen mention of any major production projects or accredited university CS courses using GNUStep, so this claim may not be well tested.

    You might want to pick a programming environment with a much larger user base, both because that proves the environment is usable, and it provides far more opportunities for any needed support (more example code, more blogs, more help forums, more mentors, etc.)
     
  9. ender land macrumors 6502a

    Joined:
    Oct 26, 2010
    #9
    I've had the opposite experience completely.

    So many more people program on windows/visual studio/etc that there are MOUNTAINS of information online, forum posts, email list postings, etc for finding resolution to problems. For Mac there are many fewer - obviously, since there are far fewer mac users than windows users.
     
  10. SidBala macrumors 6502a

    Joined:
    Jun 27, 2010
    #10
    I don't know about you, but I thought the MSDN documentation was very comprehensive.

    Besides, the majority of coders are developing for the Windows platform. Hence there is also a lot of help that can be easily found.
     
  11. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #11
    Mountains of information and comprehensive, is not the same as comprehensible and easy to find. In fact, the opposite is often true, a problem facing information architects everywhere. And this refers only to the official documentation obviously, as nothing can be said about the quality of the rest.

    cyberscot, just write a program that lists all files in the current directory or get a file size and you will need OS api's, at least in C. You can stay relatively cross platform between *nix OS's while using the posix api's on OS X. But they are typically systems programming api's, no GUI's and so on.
     
  12. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #12
    I too prefer Apple's documentation over Microsoft's in most cases I can find the information I need quicker and get more example code to show how things actually interact.

    Of course there is far more third party info for Windows, but much of it is lousy.

    B
     
  13. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #13
    For the time being, I think you may be able to reach the largest audience with Java. I think that would creep me out, though, C makes me feel like I can touch the machine.
     
  14. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #14
    Javascript now. The web is everywhere, and mostly cross-platform.

    C is a low enough level language that some have called it little more than a DEC PDP-11 (and now a RISC ISA) macro-assembly language.
     

Share This Page