Code completion

Last updated

Code completion is an autocompletion feature in many integrated development environments (IDEs) that speeds up the process of coding applications by fixing common mistakes and suggesting lines of code. This usually happens through popups while typing, querying parameters of functions, and query hints related to syntax errors. Modern code completion software typically uses generative artificial intelligence systems to predict lines of code. Code completion and related tools serve as documentation and disambiguation for variable names, functions, and methods, using static analysis. [1] [2]

Contents

The feature appears in many programming environments. [3] [4] Implementations include IntelliSense in Visual Studio Code. The term was originally popularized as "picklist" and some implementations still refer to it as such. [5]

Overview

Intelligent code completion, which is similar to other autocompletion systems, is a convenient way to access descriptions of functions—and in particular their parameter lists. The feature speeds up software development by reducing keyboard input and the necessity for name memorization. It also allows for users to refer less frequently to external documentation, as interactive documentation on many symbols (i.e. variables and functions) in the active scope appears dynamically in the form of tooltips. [6]

Intelligent code completion uses an automatically generated in-memory database of classes, variable names, and other constructs that given computer code defines or references. The "classic" implementation of IntelliSense works by detecting marker characters such as periods (or other separator characters, depending on the language). When the user types one of these characters immediately after the name of an entity having one or more accessible members (such as contained variables or functions), IntelliSense suggests matches in a pop-up dialog. The user can either accept the suggestion by typing a statement-completion character (Tab ↹ or ↵ Enter) or a language-specific marker (such as the semicolon for C++), or continue typing the name. Over time, IntelliSense determines which variable or function the user most likely needs. IntelliSense also displays a short description of a function in the pop-up window—depending on the amount of documentation in the function's source code.

The feature also lets users select from a number of overloaded functions in languages that support object-oriented programming. Some code editing software provide intelligent code completion through a Language Server Protocol (LSP) server.

History

Research on intelligent code completion began in 1957, with spelling checkers for bitmap images of cursive writing and special applications to find records in databases despite incorrect entries. In 1961, Les Earnest, who headed the research on this budding technology, saw it necessary to include the first spell checker that accessed a list of 10,000 acceptable words. [7] Ralph Gorin, a graduate student under Earnest at the time, created the first true spell-check program written as an application (rather than research) for general English text. SPELL, for the DEC PDP-10 at Stanford University's Artificial Intelligence Laboratory (SAIL), was published in February 1971. [8] Gorin wrote the program in assembly for faster action; he made it by searching a word list for plausible correct spellings that differ by a single letter or adjacent-letter transpositions, and presenting them to the user. Gorin made SPELL publicly accessible, as was done with most SAIL programs, and it soon spread around the world via the then-new ARPANET, about a decade before personal computers came into general use. [9] SPELL and its algorithms and data structures inspired the Unix program Ispell.

Support in editors and IDEs

Visual Studio

IntelliSense is Microsoft's implementation of code completion, best known in Visual Studio. It was first introduced as a feature of a mainstream Microsoft product in 1996 [10] building on many already invented concepts of code completion and syntax checking, with the Visual Basic 5.0 Control Creation Edition, which was essentially a publicly available prototype for Visual Basic 5.0. [11] Initially, Visual Basic IDE was the primary "test bed" for the technology, but IntelliSense was incorporated into Visual FoxPro and Visual C++ [12] in the Visual Studio 97 timeframe (one revision after first seen in Visual Basic). Because it was based on the introspection capabilities of COM, the Visual Basic versions of IntelliSense were always more robust and complete than the 5.0 and 6.0 (97 and 98 in the Visual Studio naming sequence) versions of Visual C++, which did not have the benefit of being entirely based on COM. These shortcomings (criticized by many VC++ developers since the 97 release) have been largely corrected in the .NET product lines. For example, one of the most requested capabilities missing from the pre-.NET products was support for templates, which is now fully implemented. [13]

IntelliSense has entered a new phase of development with the unified Visual Studio.NET environment first released in 2001, augmented by the more powerful introspection and code documentation capabilities provided by the .NET framework. IntelliSense is now supported by the Visual Studio editors for C++, C#, J#, Visual Basic, XML, HTML and XSLT among others. As of Visual Studio 2005, IntelliSense is now activated by default when the user begins to type, instead of requiring marker characters (though this behavior can be turned off). The IDE has the capability of inferring a greater amount of context based on what the developer is typing, to the point that basic language constructs such as for and while are also included in the choice list. In 2017 Microsoft announced IntelliCode, [14] which uses machine learning to infer exactly which language or library feature is likely to be intended at every keystroke. Initially available as an extension for C# only, it is expected to be built in to future releases of Visual Studio.

Visual Studio 2022 includes artificial-intelligence features, such as GitHub Copilot, which can automatically suggest entire lines of code based on surrounding context.

Other Microsoft products that incorporate IntelliSense include Expression Web, FrontPage 2003, Small Basic, the Visual Basic for Applications IDEs in the Microsoft Office products, Visual Studio Code and many others. SQL Server 2008 Management Studio has autocomplete for the SQL syntax.

Eclipse

The Eclipse IDE has code completion tools that come packaged with the program. [15] [16] It includes notable support for Java, C++, and JavaScript code authoring. The Code Recommenders Eclipse project used to provide powerful intelligent completion, [17] but due to lack of resources, was dropped in Eclipse 2018–12, and then archived in July 2019. [18] [19] [20]

Vim

Vim Intellisense [21] is an advanced code completion system for the Vim editor.

Example

Assume a C++ application being edited in Visual Studio has a class Foo with some member functions:

classFoo{public:voidbar();voidfoo_bar(charc,intn);};

When the developer references this class in source code, e.g.:

Foofoo;foo.

as soon as the user types the period after foo, IntelliSense automatically lists all the available member functions (i.e. bar() and foo_bar()) and all the available member attributes (private and protected members can be identified by a padlock picture beside their names). The user can then select one by using the arrow keys and hitting a completion character when the correct member function is highlighted. When available, IntelliSense displays a short description of the member function as given in the source code documentation.

IntelliSense goes further by indicating the required parameters in another pop-up window as the user fills in the parameters. As the user types a variable name, the feature also makes suggestions to complete the variable as they are typed. IntelliSense continues to show parameters, highlighting the pertinent one, as the user types.

The user can "force" IntelliSense to show its pop-up list without context by using Ctrl+J or Ctrl+Space. In Visual Studio this displays the entire application domain object model available to the developer.

Notes

  1. Robbes, Romain; Lanza, Michele (2008). "How Program History Can Improve Code Completion". 2008 23rd IEEE/ACM International Conference on Automated Software Engineering. pp. 317–326. doi:10.1109/ASE.2008.42. ISBN   978-1-4244-2187-9. S2CID   2093640.
  2. "Code Completion, Episode 1: Scenarios and Requirements". The JetBrains Blog. 28 May 2021. Retrieved 17 November 2023.
  3. FAQ - CodeBlocks. Wiki.codeblocks.org (2014-02-01). Retrieved on 2014-04-04.
  4. Qt Documentation - Completing Code. Retrieved on 2015-07-07.
  5. Using Dynamic Apex to retrieve Picklist Values | Developer Force Blog. Blogs.developerforce.com (2008-12-09). Retrieved on 2014-04-04.
  6. Murach. C# 2005. p. 56.
  7. Earnest, Les. "The First Three Spelling Checkers" (PDF). Stanford University. Archived from the original (PDF) on 22 October 2012. Retrieved 10 October 2011.
  8. Peterson, James (December 1980). Computer Programs for Detecting and Correcting Spelling Errors (PDF). Retrieved 18 February 2011.
  9. Earnest, Les. Visible Legacies for Y3K (PDF). Archived from the original (PDF) on 20 July 2011. Retrieved 18 February 2011.
  10. "Microsoft KB Archive/165524 - BetaArchive Wiki". www.betaarchive.com. Retrieved 19 November 2023.
  11. "Microsoft Introduces Visual Basic 5.0, Control Creation Edition". Stories. 28 October 1996. Retrieved 19 November 2023.
  12. "Microsoft Introduces Visual C++ 6.0". Stories. 29 June 1998. Retrieved 19 November 2023.
  13. Using IntelliSense. Msdn.microsoft.com. Retrieved on 2014-04-04.
  14. Visual Studio IntelliCode
  15. "Eclipse Corner Article: Unleashing the Power of Refactoring | the Eclipse Foundation".
  16. "Technologies". IBM .
  17. Eclipse Code Recommenders: It’s all about intelligent code completion. Code-recommenders.blogspot.com (2010-05-03). Retrieved on 2014-04-04.
  18. 542689 - Don't include Code Recommenders for 2018-12
  19. cross-project-issues-dev Withdrawing Code Recommenders from SimRel
  20. Archived Projects | The Eclipse Foundation
  21. Vim Intellisense. Insenvim.sourceforge.net. Retrieved on 2014-04-04.

Related Research Articles

An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, and a debugger. Some IDEs, such as IntelliJ IDEA, Eclipse and Lazarus contain the necessary compiler, interpreter or both; others, such as SharpDevelop and NetBeans, do not.

Hungarian notation is an identifier naming convention in computer programming in which the name of a variable or function indicates its intention or kind, or in some dialects, its type. The original Hungarian notation uses only intention or kind in its naming convention and is sometimes called Apps Hungarian as it became popular in the Microsoft Apps division in the development of Microsoft Office applications. When the Microsoft Windows division adopted the naming convention, they based it on the actual data type, and this convention became widely spread through the Windows API; this is sometimes called Systems Hungarian notation.

AutoLISP is a dialect of the programming language Lisp built specifically for use with the full version of AutoCAD and its derivatives, which include AutoCAD Map 3D, AutoCAD Architecture and AutoCAD Mechanical. Neither the application programming interface (API) nor the interpreter to execute AutoLISP code is included in the AutoCAD LT product line. A subset of AutoLISP functions is included in the browser-based AutoCAD web app.

<span class="mw-page-title-main">Microsoft Visual C++</span> Integrated development environment product by Microsoft

Microsoft Visual C++ (MSVC) is a compiler for the C, C++, C++/CLI and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available in both trialware and freeware forms. It features tools for developing and debugging C++ code, especially code written for the Windows API, DirectX and .NET.

CodeView is a standalone debugger created by David Norris at Microsoft in 1985 as part of its development toolset. It originally shipped with Microsoft C 4.0 and later. It also shipped with Visual Basic for MS-DOS, Microsoft BASIC PDS, and a number of other Microsoft language products. It was one of the first debuggers for MS-DOS to be full-screen oriented, rather than line-oriented.

<span class="mw-page-title-main">Autocomplete</span> Computing feature predicting ending to a word a user is typing

Autocomplete, or word completion, is a feature in which an application predicts the rest of a word a user is typing. In Android and iOS smartphones, this is called predictive text. In graphical user interfaces, users can typically press the tab key to accept a suggestion or the down arrow key to accept one of several.

<span class="mw-page-title-main">Microsoft Visual Studio Express</span> Integrated development environment

Microsoft Visual Studio Express is a set of integrated development environments (IDEs) that Microsoft developed and released free of charge. They are function-limited version of the non-free Visual Studio and require mandatory registration. Express editions started with Visual Studio 2005.

<span class="mw-page-title-main">Graphical user interface builder</span> Software development tool

A graphical user interface builder, also known as GUI designer or sometimes RAD IDE, is a software development tool that simplifies the creation of GUIs by allowing the designer to arrange graphical control elements using a drag-and-drop WYSIWYG editor. Without a GUI builder, a GUI must be built by manually specifying each widget's parameters in the source code, with no visual feedback until the program is run. Such tools are usually called the term RAD IDE.

<span class="mw-page-title-main">SharpDevelop</span>

SharpDevelop is a discontinued free and open source integrated development environment (IDE) for the .NET Framework, Mono, Gtk# and Glade# platforms. It supports development in C#, Visual Basic .NET, Boo, F#, IronPython and IronRuby programming languages.

In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation.

this, self, and Me are keywords used in some computer programming languages to refer to the object, class, or other entity which the currently running code is a part of. The entity referred to thus depends on the execution context. Different programming languages use these keywords in slightly different ways. In languages where a keyword like "this" is mandatory, the keyword is the only way to access data and methods stored in the current object. Where optional, these keywords can disambiguate variables and functions with the same name.

C# and Visual Basic .NET are the two primary languages used to program on the .NET Framework.

<span class="mw-page-title-main">Snippet (programming)</span> Small region of re-usable source code, machine code, or text

Snippet is a programming term for a small region of re-usable source code, machine code, or text. Ordinarily, these are formally defined operative units to incorporate into larger programming modules. Snippet management is a feature of some text editors, program source code editors, IDEs, and related software. It allows the user to avoid repetitive typing in the course of routine edit operations.

<span class="mw-page-title-main">Visual Basic (classic)</span> Microsofts programming language based on BASIC and COM

Visual Basic (VB) before .NET, sometimes referred to as Classic Visual Basic, is a third-generation programming language, based on BASIC, and an integrated development environment (IDE), from Microsoft for Windows known for supporting rapid application development (RAD) of graphical user interface (GUI) applications, event-driven programming and both consumption and development of components via the Component Object Model (COM) technology.

The following tables list notable software packages that are nominal IDEs; standalone tools such as source-code editors and GUI builders are not included. These IDEs are listed in alphabetic order of the supported language.

TypeScript is a free and open-source high-level programming language developed by Microsoft that adds static typing with optional type annotations to JavaScript. It is designed for the development of large applications and transpiles to JavaScript. Because TypeScript is a superset of JavaScript, all JavaScript programs are syntactically valid TypeScript, but they can fail to type-check for safety reasons.

<span class="mw-page-title-main">MonoDevelop</span> Integrated development environment, discontinued for macOS

MonoDevelop was an open-source integrated development environment for Linux, macOS, and Windows. Its primary focus is development of projects that use Mono and .NET Framework. MonoDevelop integrates features similar to those of NetBeans and Microsoft Visual Studio, such as automatic code completion, source control, a graphical user interface (GUI) and Web designer. MonoDevelop integrates a Gtk# GUI designer called Stetic. It supports Boo, C, C++, C#, CIL, D, F#, Java, Oxygene, Vala, JavaScript, TypeScript and Visual Basic.NET. Although there is no word from the developers that it has been discontinued, nonetheless it hasn't been updated in 4 years and is no longer installable on major operating systems, such as Ubuntu 22.04 and above. Its parent Microsoft, seems to have shifted focus to Visual Studio Code and the .NET Framework, which runs on many operating systems, including Linux.

<span class="mw-page-title-main">Visual Studio</span> Code editor and IDE

Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both native code and managed code.

Visual Basic .NET was released by Microsoft in 2002 as a successor to the original Visual Basic computer programming language. It was implemented on the .NET Framework 1.0. The main new feature was managed code. Programmers familiar only with Visual Basic would probably have encountered difficulties working with the new version or adapting existing programs for it.

Kotlin is a cross-platform, statically typed, general-purpose high-level programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more concise. Kotlin mainly targets the JVM, but also compiles to JavaScript or native code via LLVM. Language development costs are borne by JetBrains, while the Kotlin Foundation protects the Kotlin trademark.