Archived

This topic is now archived and is closed to further replies.

n0ob

what is programming on Mac like?

Recommended Posts

I was just wondering how programming for macs works. Do they use C++? Do they have versions of DirectX or OpenGL? There must be a whole different standard library right? They obviously don''t use any win32 functions right? Anyway, I was just wondering. Thanks! Kings of Chaos

Share this post


Link to post
Share on other sites
Yes, they can use C++, and they have a version of OpenGL. They don''t have direct X, as that''s a windows only thing. The standard library is just that... standard, no matter which OS/platform, the library does the same thing. Programming OpenGL is practically identical, as is the entire C++ standard, and using the standard template library (stl). Their are differences in how you get input, create a window, etc (all the win32 specific crap can''t be done on a mac for obvious reasons), but things like SDL, GLUT, etc make cross-platform VERY easy. Then you have your audio libraries, like fmod, which is also cross-platform. If you use GLUT (I think it''s available for mac anyways?) and fmod, you could easily write a program that would compile for a PC (linux and windows) and mac.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

Macs initially used Pascal, but soon thereafter (mid 80s) C and, later, C++ became popular. The standard libraries are available as usual, although the Mac file system looks even less like UNIX than the Windows file system, so using standard file I/O may cause Acute Clunkiness Syndrome.

Macs support OpenGL, with special APPLE extensions (instead of, say, NV or ATI extensions). They try to make them similar across the NVIDIA and ATI chips that they put in the machines, but I don''t know how well they succeed.

For GUI/native access, MacOS 9 uses something called "the toolbox" which serves the same purpose as Win32, but with diffences in data structures and function names.

MacOS X is another beast. It has a version of the toolbox called Carbon, but it also has lots of NeXT stuff, including a Berkeley flavor UNIX.

Share this post


Link to post
Share on other sites
About the standard library.. How can it run on any platform? The processors use different codes or whatever right? Does this mean that the compiler puts the binary stuff together the right way for that platform? What kind of data is stored in the standard libraries that can be interpreted on any platform. What is the topic of this that I can research? Thanks!

Kings of Chaos

Share this post


Link to post
Share on other sites
quote:
Original post by n0ob
About the standard library.. How can it run on any platform? The processors use different codes or whatever right? Does this mean that the compiler puts the binary stuff together the right way for that platform? What kind of data is stored in the standard libraries that can be interpreted on any platform. What is the topic of this that I can research? Thanks!

Kings of Chaos


No, it means the writer of the compiler is responsible for filling in all functions under the platform that it will be compiling for. That means, that while some functions are part of the C++ standard, gcc, msvc, codewarrior, etc all implement it differently, but it still gets the same job done. This means, you must compile the program under each OS, for each OS that you plan on using it with, as the output files aren''t compatible. The C++ standard defines a bunch of things that MUST be implemented, and what the implementation must do... how the person goes on about implementing it is up to them, and is dependant on the platform.

Share this post


Link to post
Share on other sites
quote:
Original post by n0ob
What compilers are used on Mac?


Under Mac OS X:
Project Builder (free from Apple), soon to be called X-Code in Panther (Mac OS X.3). Though I suppose I should say GCC as that''s what Project Builder uses as its compiler.
Codewarrior

Under Mac OS 9:
Codewarrior
MPW (free from Apple)

Share this post


Link to post
Share on other sites
quote:
Original post by n0ob
About the standard library.. How can it run on any platform? The processors use different codes or whatever right?


The standard is just an interface. It just says what needs to be done, not how it needs to be done. A system can meet those needs anyway it wants to, just as long as it meets them.

Take memory allocation like new or malloc(). Getting dynamic memory is very system dependent, so malloc() will be implemented very differently on MacOSX than it is on Windows. But both versions give memory out when called upon, and that''s all the programmer cares about.

Share this post


Link to post
Share on other sites
quote:
Original post by Magmai Kai Holmlor
I''ve heard that Objective C was (is?) popular on Macs.


Yep - it''s the native language for OSX, really. Most of the NeXT stuff came in using it, and a large part of the Mac dev tools are centered around generating Obj-C code (Interface Builder, anyone)?

However, what people tend to do is mix Objective-C and C++ to create - yes, you guessed it - Objective-C++. You can switch from Obj-C to C++ in the middle of a function or thereabouts, and the compiler handles it fine.

OpenGL is the graphics API of choice - you *could* use things like MacDX but all they do is end up passing calls through to OpenGL; they''re taking advantage of n00bs and people in a rush who didn''t design their apps to allow for multiple renderers properly. I''m not sure about input and sound - I just use SDL and FMOD - though networking is straight berkely sockets.



Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4

Share this post


Link to post
Share on other sites
quote:
How well does MacDX work? There''s WineX for DirectX on Linux, but it doesn''t work that well


Id like to know this too. Unfortuanetly I dont know anyone who''s used this, and besides, superpig makes a good point. However, sometimes time does not allow to design for multiple renderer use, or it is just not needed. And using something like MacDX is a really nifty (and apparently quick) solution to port your app to mac.

Share this post


Link to post
Share on other sites
quote:
what is programming on Mac like?

It is like sliding down a razor blade and landing in a barrel of monkey snot.

[edited by - jeeky on September 1, 2003 12:01:34 PM]

[edited by - jeeky on September 1, 2003 12:02:20 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by jeeky
quote:
what is programming on Mac like?

It is like sliding down a razor blade and landing in a barrel of monkey snot.


It is like sliding down a razor blade and landing in a barrel of monkey snot liquidized salt.

Share this post


Link to post
Share on other sites