TextWrangler's Advantage over Xcode for Interpreted Languages
Xcode is designed for compiled languages like C++ and Java, not interpreted languages like Python and Ruby. You can create an external build system project in Xcode, but it is not very useful for interpreted languages because there is nothing to build for interpreted languages. You have to run the Terminal application and launch your program from the command line using your language's interpreter.
TextWrangler's shebang (#!) menu allows you to run Unix scripts from TextWrangler so you don't have to launch Terminal. TextWrangler has built-in support for Perl, Python, and Ruby, which means you can run and debug Perl, Python, and Ruby programs from TextWrangler. You can use TextWrangler to run programs in other interpreted languages, but you can't debug them using TextWrangler's Run in Debugger menu item.
Creating and Running a Program with TextWrangler
Writing and running code in interpreted languages is easy in TextWrangler. The following steps show you how to write a simple Ruby program with TextWrangler:
- Choose File > New Text Document.
- At the bottom of the document window are three pop-up menus. The left menu should say (none). Choose Ruby from the left pop-up menu. This tells TextWrangler that you are writing a Ruby program, which turns on Ruby syntax highlighting and enables the Run in Debugger menu item.
- Write your code. For a Hello World program, enter puts "Hello World".
- Choose #! > Run to run the program.
If you are using another interpreted language, the first line of code must specify the path to the interpreter.
The #! sequence is the start of a Unix script.
Using TextWrangler with Xcode
Although you don't need Xcode for small projects if you use TextWrangler, Xcode has its place for larger projects. You would use Xcode for project organization and version control and use TextWrangler to write the code and run the program. The Xcode Tools Tips page has a tip on using external editors with Xcode.