Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cybrscot

macrumors 6502
Original poster
Dec 7, 2010
282
0
Somewhere in Southeast Asia
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
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
are these "simple" beginner programs universal for both?
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
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
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.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
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.
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
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.
 

chrono1081

macrumors G3
Jan 26, 2008
8,456
4,164
Isla Nublar
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.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
The folks behind GNUStep claim it is very nearly fully compatible with Cocoa.

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.)
 

ender land

macrumors 6502a
Oct 26, 2010
876
0
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.

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.
 

SidBala

macrumors 6502a
Jun 27, 2010
533
0
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.

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.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
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.
 

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
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.

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
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
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.
 

firewood

macrumors G3
Jul 29, 2003
8,108
1,345
Silicon Valley
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.