Lint is the
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
term for a
static code analysis
In computer science, static program analysis (also known as static analysis or static simulation) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs duri ...
tool used to flag programming errors,
bugs, stylistic errors and suspicious constructs. The term originates from a
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
utility
In economics, utility is a measure of a certain person's satisfaction from a certain state of the world. Over time, the term has been used with at least two meanings.
* In a normative context, utility refers to a goal or objective that we wish ...
that examined
C language
C (''pronounced'' '' – like the letter c'') is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities o ...
source code.
A program which performs this function is also known as a "linter" or "linting tool".
History
Stephen C. Johnson, a computer scientist at
Bell Labs
Nokia Bell Labs, commonly referred to as ''Bell Labs'', is an American industrial research and development company owned by Finnish technology company Nokia. With headquarters located in Murray Hill, New Jersey, Murray Hill, New Jersey, the compa ...
, came up with the term "lint" in 1978 while debugging the
yacc
Yacc (Yet Another Compiler-Compiler) is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser (the part of a co ...
grammar he was writing for
C and dealing with
portability issues stemming from porting
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
to a
32-bit
In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in a maximum of 32- bit units. Compared to smaller bit widths, 32-bit computers can perform la ...
machine.
The term was borrowed from the word
lint, the tiny bits of fiber and fluff shed by clothing, as the command he wrote would act like a lint trap in a clothes dryer, capturing waste fibers while leaving whole fabrics intact. In 1979, lint programming was used outside of Bell Labs for the first time, in the seventh version (
V7) of Unix.
Over the years, different versions of lint have been developed for many
C and
C++ compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s, and while modern-day compilers have lint-like functions, lint-like tools have also advanced their capabilities. For example, Gimpel's
PC-Lint
PC-lint is a commercial software linting tool produced by Gimpel Software (formerly Gimp Suit Software Ltd.) for the C/ C++ languages.
PC-lint is a command-line tool for performing static code analysis, indicating suspicious or plain wrong issu ...
, introduced in 1985 and used to analyze C++ source code, is still for sale.
Overview
In his original 1978 paper Johnson stated his reasoning in creating a separate program to detect errors, distinct from that which it analyzed: "...the general notion of having two programs is a good one"
ecause they concentrate on different things, thereby allowing the programmer to"concentrate at one stage of the programming process solely on the
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
s,
data structure
In computer science, a data structure is a data organization and storage format that is usually chosen for Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the relationships amo ...
s, and correctness of the program, and then later retrofit, with the aid of lint, the desirable properties of universality and portability".
Successor linters
The analysis performed by lint-like tools can also be performed by an
optimizing compiler
An optimizing compiler is a compiler designed to generate code that is optimized in aspects such as minimizing program execution time, memory usage, storage size, and power consumption. Optimization is generally implemented as a sequence of op ...
, which aims to generate faster code. Even though modern
compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
s have evolved to include many of lint's historical functions, lint-like tools have also evolved to detect an even wider variety of suspicious constructs. These include "warnings about syntax errors, uses of
undeclared variables, calls to deprecated functions, spacing and formatting conventions, misuse of scope, implicit fallthrough in
switch statements, missing license headers,
nd..dangerous language features".
Lint-like tools are especially useful for
dynamically typed languages like
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
and
Python. Because the interpreters of such languages typically do not enforce as many and as strict rules during
execution
Capital punishment, also known as the death penalty and formerly called judicial homicide, is the state-sanctioned killing of a person as punishment for actual or supposed misconduct. The sentence ordering that an offender be punished in ...
, linter tools can also be used as simple
debugger
A debugger is a computer program used to test and debug other programs (the "target" programs). Common features of debuggers include the ability to run or halt the target program using breakpoints, step through code line by line, and display ...
s for finding common errors (e.g. syntactic discrepancies) as well as hard-to-find errors such as
heisenbug
In computer programming jargon, a heisenbug is a software bug that seems to disappear or alter its behavior when one attempts to study it. The term is a pun on the name of Werner Heisenberg, the physicist who first asserted the observer effect ...
s (drawing attention to suspicious code as "possible errors"). Lint-like tools generally perform
static analysis
Static analysis, static projection, or static scoring is a simplified analysis wherein the effect of an immediate change to a system is calculated without regard to the longer-term response of the system to that change. If the short-term effect i ...
of source code.
Lint-like tools have also been developed for other aspects of software development, such as enforcing grammar and style guides for given language source code.
Some tools (such as
ESLint) also allow rules to be auto-fixable: a rule definition can also come with the definition of a transform that resolves the warning. Rules about style are especially likely to come with an auto-fix. If the linter is run in "fix all" mode on a file that triggers only rules about formatting, the linter will act just like a formatter.
See also
*
Splint (programming tool)
*
List of tools for static code analysis
References
Further reading
*
* {{cite web
, url=https://man.netbsd.org/lint.1
, title=LINT(1)
, work=NetBSD General Commands Manual
, date=2024-01-24
Static program analysis tools
Unix software
Formerly proprietary software
Software using the BSD license