ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


Komodo 3.5 for Dynamic Languages

by Michael J. Ross
12/21/2006

Newly minted software developers are typically delighted to discover the power of modern programmer's editors, with syntax highlighting and coloring, auto-indenting, incremental search, etc. Their delight quickly disappears when drowning in a sea of print statements needed to watch the changing values of variables. That's the fundamental reason why integrated development environments (IDEs) are a must-have tool for programmers. They make coding, debugging, project management, and other aspects of software development so much easier and faster. This, in turn, allows the developer to focus his energy and attention on less mundane activities, with more creative energy.

There are many IDEs on the market for dynamic programming languages such as PHP, Perl, and Ruby. I personally have tried several of them, ranging from such heavyweights as Eclipse to little-known IDEs that lack features but not idiosyncrasies.

This article reviews one of the most respected IDEs available, ActiveState's Komodo. As of this writing, the current version of Komodo is 3.5.3. Komodo is available for Linux (Debian/Ubuntu 5.04+, Red Hat/Fedora 3+, and SuSE 9.0+), Mac OS X (10.4 and 10.3), Solaris (8+), and Windows (XP, 2000, NT 4.0, ME, and 98).

Within each platform category, there are two different editions of Komodo: Personal and Professional. The former is for personal and educational use, while the latter is for corporate and commercial use, and has additional features to support professional and team development, including source code control, GUI building, and package management. Furthermore, the Professional edition's licensing fees of $295 are an order of magnitude higher than those of the Personal edition, at $29.95. ActiveState licenses allow you to use a licensed product on all supported platforms.

Komodo recognizes over 30 languages and boasts especially powerful support for Perl, PHP (including 5.1), Python, Ruby, Tcl, and XSLT. In fact, it has fully integrated Ruby support, including debugging, code intelligence (including Code Browser support, Object Browser support, AutoComplete, and CallTips), an interactive shell, syntax checking, syntax highlighting, and code folding. In this latest version, the graphical debugger now supports Ruby on Rails.

Editor

Komodo's built-in editor offers features that experienced coders have come to expect of modern programmer's editors: multidocument editing with tabs, syntax highlighting, stream and block selection, multiple undo and redo, smart-indenting and outdenting, incremental and cross-document search, code-folding (collapsing and expanding blocks), split view, keystroke repetition, recordable macros, code block commenting, and text joining and reflowing. Komodo's syntax capabilities are excellent; they include syntax highlighting with color and syntax checking. This instant visual feedback invariably saves time and reduces bugs. Komodo offers syntax highlighting for over 30 languages. Also, the syntax colors are fully customizable (via Edit > Preferences, not the more standard Tools > Options).

Like the better non-IDE programmer's editors, Komodo has extra features, such as code completion ("AutoComplete"), display of language and user-defined function parameter lists ("CallTips"), Emacs-like key binding, and optional removal of whitespace on line endings.

Programmers spend a lot of time searching and replacing text within code. Thus, an IDE's search-and-replace capabilities are of paramount importance. In this regard, Komodo is more than adequate, though not stellar. It allows regular expressions in text searching, including the use of found text dynamically within the replacement string. It is not documented, but uses the standard Python and Perl syntax of grouping using parentheses and replacement strings identified as $1, $2, etc.

Komodo allows searching within directory trees. The menu item is Edit > Find in Files, which I did not even notice at first, being accustomed to having it as part of a single search-and-replace dialog. One nice feature, which I have not seen elsewhere, is the ability to exclude files from searching. This includes wildcard support.

For programmers who find themselves pasting the same type of code frequently, Komodo's code snippets capability should prove quite handy. It allows you to store any piece of code for later reuse. On the other hand, you should use large snippets judiciously, as any copying and pasting should first alert the wise programmer to perhaps modularize that code in a separate function--true reuse.

Developers creating code for applications and websites intended for an international audience will appreciate Komodo's multilingual Input Method Editor (IME) support, which allows standard keyboard codes to enter complex multibyte characters and symbols for French, German, and Spanish, as well as Asian languages.

Graphical Debugger

If the features discussed above were all that Komodo offered, then a top-of-the-line programmer's editor such as jEdit would suffice. Perhaps the first capability that attracts a new developer to any IDE is the debugger, which beats endless print statements. For Perl code, this exceeds the text-based native Perl debugger.

Komodo's graphical debugger has all the standard debugging capabilities: breakpoints; stepping in, over, or out of a function; watched variables; display of the call stack; and display of terminal output. You can modify variables midstream in a debugging session. You can disable a breakpoint without deleting it, which saves time when later trying to remember the optimal locations of unneeded breakpoints. One terrific feature is that Komodo presents complex watched variables in an intuitive tree format. It also allows you to expand arrays and hashes, nesting individual parts of those structures.

The IDE also has some features that are more appropriate for advanced programming scenarios and special cases, such as remote debugging and multisession debugging, or simultaneously debugging multiple applications in multiple languages--scenarios that are beyond the scope of this review.

As the original versions aimed at PHP and Perl programmers, Komodo has full CGI emulation, which allows you to control the environment seen by the CGI script running locally in a web server on your machine. Unfortunately, by default, every Debug run causes the "Debugging Options" dialog box to appear, even if you do not want to change any of the debugging options for that run. Fortunately, you can bypass this in Linux and Windows by holding down the Ctrl key. Bypass it automatically by changing your preferences.

To get PHP CGI emulation to work, you must disable force-cgi-redirect by setting cgi.force_redirect to 0 in Komodo's php.ini. Otherwise, Komodo can report the error "Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g., via an Apache Action directive." After updating php.ini, test it by running a PHP script with "Simulate CGI Environment" (in the "Debugging Options" dialog box) checked.

Somewhat related, when I tried to run the PHP tutorial script (php_tutorial.kpf), I received the error "Please correct your interpreter selection in preferences," even though I had it set correctly to the appropriate PHP executable. (Think of it as a holdover from Windows' Ctrl+Alt+Del...) Apparently Komodo version 3.5.3 will remove the need to restart the application.

Code Control

An essential part of any sizable software development project is controlling the code, in the form of organizing it well, easily seeing its structure, and being able to store and track revisions to that code. Komodo makes it possible to do all of this without leaving the IDE, as it has built-in browsing of projects, code, and objects, as well as hooks to version control systems.

In the upper-lefthand corner of the IDE, a "Project" tab displays all open projects with their constituent files. Double-clicking on any listed file opens it in the righthand pane. Some IDEs that I have tried and abandoned make it difficult to import existing files' trees as a new project within the IDE. It's as if their designers refuse to consider that programmers may have already done some coding before choosing that IDE. Komodo instead offers a much-appreciated "Import from File System" feature that can quickly make existing code efforts visible within Komodo.

The other tab in the upper-lefthand corner, labeled "Code," allows browsing of the source structure within the code files. For PHP projects, it displays included and required files, global variables, and function names, as well as objects, if any. For Perl projects, it displays modules, too. These clickable lists provide a fast way to jump around the code. Sadly, there is a lack of coordination between the Code browser and the other panes. Clicking on a different source file tab in the righthand pane should show that code in the Code browser pane as well, but it doesn't. Even opening a new project doesn't change the Code browser's contents. That is because the Code browser in the current version is not aware of projects, and only shows files opened in the editor. Apparently that is an enhancement slated for the future.

Unlike the browsing of projects and source files, object browsing requires the use of the Tools > Object Browser menu, which seems nonintuitive to me. It would be better if it were located as a third tab in the upper lefthand corner.

The Professional edition of Komodo facilitates source code revisioning by allowing the user to perform all conventional versioning tasks (check-in, check-out, and differences) using several popular code version control systems: CVS, Perforce, and now, with version 3.1, Subversion. Komodo can monitor the repositories and their files, so as to indicate any changes from other users. It is also possible to set up a remote CVS repository and interact with it securely via SSH.

Other Features

Komodo has more capabilities than a single article can explore in depth. I would be remiss to not mention some of them. One real boon is the built-in browser, which allows previewing of HTML, XML, and CSS files, and can thereby save considerable time and frustration from switching back and forth from CGI source code to a web browser to see the results.

Regular expressions (regexes) are a powerful tool in the hands of a skilled programmer, and particularly useful when performing text processing. Perl and PHP both provide solid support for regexes, and Komodo, in like spirit, does the same. In addition to regexes in search-and-replace, as noted earlier, Komodo has a utility that allows you to try various regexes to see how (or if) they match. There are several match type modes: Match, Match All, Split, Replace, and Replace All. In addition, there are modifiers, including case insensitivity. Unfortunately, ActiveState should have named this utility the "Regex Toolkit," but instead chose "Rx Toolkit," which makes it sound like a doctor's medicine bag or a pharmacist's toolkit. To make matters worse, the application's icon is a mortar and pestle--the only instance in the product that I saw of cuteness chosen over clarity.

Komodo features a Visual Package Manager, a web-based management system for installed Perl modules. It is only available in Komodo's Professional edition, as are the Toolbox (a team-shareable storage area for commands, macros, code snippets, etc.) and the ActiveState GUI Builder (for making Tk-based GUI dialogs). For significant application development with a team, integrated source code revisioning alone should make the Professional edition worth the extra cost, but these additional tools would be icing on the cake.

Support

Like most programming tools nowadays, Komodo offers product support in the form of online documentation in HTML and PDF formats, bug tracking, and cookbooks (code collections), in addition to an ActiveState Programmer Network (ASPN).

The online documentation for Komodo is extensive and indexed, with full-text searching. F1 brings up the locally installed "Komodo User Guide." This is a HTML guide of 26 sections ranging from a welcome page to a reference manual. If there is any highlighted text in the current script, pressing Shift + F1 searches the PHP function list for the highlighted string (if the script is PHP), or Googles the highlighted string within www.perldoc.com (if the script is Perl). Ctrl + F1 searches all of Google, regardless of the script's language.

Komodo's user guide contains tutorials on Perl, PHP, Python, Ruby, Tcl, and XSLT--bracketed by a "Feature Showcase" tutorial with 21 subsections explaining many valuables techniques, and a "Run Command Tutorial."

The user guide has a lot of information. The HTML pages use frames, with the lefthand panel used for navigation and the righthand panel displaying contents. It starts with "Welcome to Komodo 3.5.3." Be careful, because if you use your browser's ability to go back to previous pages, and you returned to the welcome page, then the lefthand panel's links no longer work. Also, the fonts and other styling is broken, suggesting that the frame is no longer seeing its intended stylesheet.

If and when the user guide fails to guide the user to an answer, she should next try the ASPN mentioned above. It offers links to dozens of mailing-lists archives, as well as user groups for ActiveState, Perl, PHP, Python, Tcl, .NET Framework, open source, XML and XSLT, and web services. It also has FAQs, tutorials, cookbooks (code recipes), and a bug-tracking system (Bugzilla), as well as documentation for most of those languages, regular expressions, and ActiveState's other programming tools.

Conclusion

Overall, Komodo is a capable and impressive IDE that is well suited for programmers hoping to harness the power of assisted editing, graphical debugging, project versioning and management, and the other tasks essential to developing software in PHP or Perl. However, there are still some shortcomings that I'd like to see future versions address to make Komodo even more attractive than its strongest competitors, such as Eclipse.

ActiveState's Komodo site has links for downloading fully functional editions of Komodo, with free 21-day trial periods. There is also information on upgrade pricing, screenshots, feature lists, release notes, install notes, and other documentation.

Michael J. Ross is a freelance web developer, working primarily with Drupal.


Return to the ONLamp.com.

Copyright © 2009 O'Reilly Media, Inc.