Code completion
Monday, January 18, 2010 at 05:17PM A major advantage of statically typed languages is support for code completion. Code completion is the editor-feature where the editor suggest relevant names (variable names, method names etc.) based on what is defined and allowed in the current context - as you type. This has the potential to greatly enhance productivity. For example, you dont have to look up method names in the source or in documentation, but can just type a dot and see what methods are defined for the current object. This also helps prevent typos in identifiers.
As a proof-of-concept I have implemented code completion in the online "try-it" editor over here. Of course the online editor is not suited for serious use, but it does provide a nice showcase for what is possible.
Code completion is disabled in the editor by default. It is enabled by clicking the "magic wand" icon leftmost in the toolbar. (The suggestions may be somewhat slow to appear, since the editor has to hit the server to get the suggestions.)
An example of how it looks when i start writing the letter "f":

You can cycle through the suggestions using the up/down arrow keys. A suggestion is selected by hitting enter, or clicking it with the mouse.
The suggestion box appears automatically when you start typing, or it can be forced to show by pressing control+space.
A limitition in the current implementation is that the autocompletion usually wont work if there is compilation errors in the code. We are working on that issue.
A related experimental feature is support for documentation comments. If a variable or function is preceeded by a comment starting with /** (note: two stars rather than the usual one), the content of that comment is displayed as help related to the suggestion for the function. As in this example:

(Tags like what is known from doc-comments is Java or C# is not supported yet, though.)
Any feedback welcome!
Olav | Comments Off | 