So, You Want To Learn To Code In OS X

Want to learn to code but don’t know where to begin? Learning to program a computer can be a rewarding experience. It can also be a little frustrating. There’s a ton of languages, editors, compilers and books out there, and even more opinions of which to learn and use. Some of them are Mac friendly and some are Microsoft based. Let’s look at what you need and where to begin coding with OS X.

What Programming Languages Should You Learn?

I think this is usually the first point where someone who wants to learn programming gets confused. There’s so many languages out there and within 10 years, I’m sure there will be even more. For someone starting out, I’d recommend more mainstream languages. Which language to choose depends on your interests. There are many programmers out there who recommend Python as a good first language because it’s easy to learn but it’s totally up to you. Here are some commonly used programming languages and what they are used for:

C / C++: Applications / Games
Objective C: Applications / Games in OS X
Java: Cross-platform Apps / Business Applications
Python: Web Development and Scripting
PHP: Web Development

I’d say any of these six would be a good place to start, however C, C++, Objective C, and Java may have a steeper learning curve.

If coding applications for the Mac / OS X is your main focus, then you’ll definitely want to learn Objective C and the Cocoa API.

Writing your code:

In order to write code, you will need an editor. An editor is basically a glorified text editing program that highlights, indents and spaces your code to make it more readable. It also lists the code by line numbers so if you have to jump to line 642, you can easily.

If you are just starting out, you won’t need to buy one – most of the best editors are free and the editors that aren’t have cut-down (but still very useful) free versions. Which one is best is enough to incite a riot among programmers so I will give you a quick list of some of the best and encourage you to download them all and see which one is best for you.

TextEdit: Included with OS X. Be sure your files are in plain text format, not .RTF.

Text Wrangler: Freeware editor by the makers of BBEdit.

Smultron: Another freeware editor by Peter Borg.

Komodo Edit: Open Source editor from the makers of Komodo IDE.

Aquamacs: Open Source port of Emacs for OS X.

Compilers:

Now that you’ve written some code in your editor, you’ll need to compile it in order to run it. Basically a compiler turns your text file’s commands into Machine Language that your computer understands. There are many of them out there. Some are specific to the programming language used, other are more multipurpose. Be aware that your choice of compiler could affect your code. Some programs compile on certain compilers perfectly but need changes to compile on others.

For someone just starting out with Java, Objective C, C, and C++, with OS X. Look no further than the Apple’s free XCode. It’s on the OS X Install DVD. Newer versions may be downloaded from Apple with an ADC membership.

If you are starting out with Python or PHP, you won’t need a compiler. Python is an interpreted language and PHP is parsed via a web server with PHP installed.

OS X comes with a version of Python pre-installed that you can access via the terminal, however to really get into Python, you’ll want to download the current version, compiled for OS X from the official website: www.python.org.

OS X also comes with PHP pre-installed and you can set up a personal server via Web Sharing in the Sharing panel of System Preferences. Or, you can download the highly recommended MAMP which will set up a complete web development environment locally on your computer.

Books/Websites for more information:

For more information on just starting out, the internet is a great resource. Here are some recommended websites for more information, help and resources:

Python: Python.org – Official Website of Python.
Python: Dive into Python – Freely available book by Mark Pilgrim
Java: New to Java Programming Center.
C: The C Book – Out of print but freely available.
PHP: PHP.net – Official website of PHP.
OS X: Beginning Mac OS X Programming – C and Objective C for those who want to get started in OS X.

For those with some experience, looking to learn OS X specific programming:

Cocoa: Cocoa Programming for Mac OS X – For intermediate programmers looking to learn Cocoa for OS X.
Objective C: Learn Objective-C on the Mac – For those experienced in C / C++ looking to learn Objective C for OS X.

Comments are closed.