The Advantage of Komodo’s Editor Over JavaScript Based Editors

komodo ide blog hero

Nowadays, it seems that IDEs and text editors are to software developers as sports cars are to car enthusiasts. Ask any developer what tool they use to write their code and why, and you will get a million different answers. Developers also love to customize their tools, just like car enthusiasts love to pimp out their rides.
Gone are the days of tools that constrain developers with static sets of features and functionality. IDEs and editors that do not provide any level of user customization are thrown by the wayside, while those that bend over backwards in order to allow users to tweak the smallest things are hyped to the moon. With the emerging trend of web technologies, there is a new generation of IDEs and editors that are built on those very technologies. However, many of those tools sacrifice speed and responsiveness for Emacs-like customizability, especially when it comes to the editing experience.
Komodo is an IDE that is partly based on web technologies, but some smart design decisions have kept its core editing capabilities fast and responsive, while allowing the user a great deal of freedom when it comes to customization. This blog post is going talk a little about [Scintilla](http://scintilla.org), Komodo’s core editing component and why many modern, web-based IDEs and editors are no match for it in terms of speed.

Scintilla Overview

Scintilla is a C++ editing component. With its modular design, it is easy to incorporate into many desktop applications, including Komodo. Its multi-platform architecture makes use of native drawing APIs on Windows, Mac OSX, and Linux. As a native widget, its visual content is of no consequence to its container application and the widget can be drawn separately (or not at all) as needed. These features contribute to Komodo’s “responsiveness” when editing code. The editor does not feel slow at all.

Syntax Highlighting

We take syntax highlighting for granted, but it can be a real bottleneck when not implemented correctly in an editor, especially because code needs to be re-highlighted after each and every keystroke. A vast majority of editors rely on a set of regular expressions (regex) for their syntax highlighting. However, those regexes need to be applied to the same text again and again in order to determine the different ranges of text that need to be colored. This is quite inefficient and can be downright slow for languages with lots of regex patterns. Some editors handle this by trying to perform the highlighting in a separate thread. Others have created their own regex libraries that only support a subset of regexes in order to perform optimizations that could not be done with a full set of regexes. Still, other editors have simply prevented you from opening files larger than *X* megabytes.
Scintilla does not use regex for its syntax highlighting. Instead, Scintilla makes use of a set of C++ *lexers*, specialized routines that provide syntax highlighting for specific languages. Lexers analyze text one character at a time in a “stateful” way. For example, when a lexer encounters an opening double quote (`”`) in Python, the lexer enters into a sort of “string mode” that only looks for a closing double quote (or perhaps backslash string escape sequences like `\xFF`), instead of looking for keywords, comments, or other non-applicable syntax tokens. In addition to stateful parsing, Scintilla only passes the subset of text that *needs* to be highlighted to a lexer. For the most part this consists of the text on the current line up to and including the text on the last visible line in the editor. As a result, Scintilla only processes the text that needs to be highlighted, and only goes through it once. This makes Komodo’s syntax highlighting very efficient with no noticeable lag. (Note: Komodo’s custom [UDL language](http://docs.komodoide.com/SDK/udl) lexers, while not written in C++, compile down into a similar “stateful” lexer with no loss in speed.)

Conclusion

Despite being partly based on web technologies, Komodo makes no compromises in speed and responsiveness when it comes down to its core editing capabilities. Scintilla is a native widget with extremely efficient syntax highlighting, unlike the editing components of other web-based IDEs and editors. As a result, where other applications will choke, Komodo will keep on going full steam ahead.

Recent Posts

Tech Debt Best Practices: Minimizing Opportunity Cost & Security Risk

Tech debt is an unavoidable consequence of modern application development, leading to security and performance concerns as older open-source codebases become more vulnerable and outdated. Unfortunately, the opportunity cost of an upgrade often means organizations are left to manage growing risk the best they can. But it doesn’t have to be this way.

Read More
Scroll to Top