Lint, or a linter, is a
static code analysis
In computer science, static program analysis (or static analysis) is the analysis of computer programs performed without executing them, in contrast with dynamic program analysis, which is performed on programs during their execution.
The term ...
tool used to flag programming errors,
bugs
Bugs may refer to:
* Plural of bug
Arts, entertainment and media Fictional characters
* Bugs Bunny, a character
* Bugs Meany, a character in the ''Encyclopedia Brown'' books
Films
* ''Bugs'' (2003 film), a science-fiction-horror film
* ''Bugs ...
, stylistic errors and suspicious constructs. The term originates from a
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser 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
As a topic of economics, utility is used to model worth or value. Its usage has evolved significantly over time. The term was introduced initially as a measure of pleasure or happiness as part of the theory of utilitarianism by moral philosoph ...
that examined
C language source code.
History
Stephen C. Johnson
Stephen Curtis Johnson (b. 1944; known as Steve Johnson) is a computer scientist who worked at Bell Labs and Old AT&T, AT&T for nearly 20 years. He is best known for Yacc, Lint (software), Lint, spell (Unix), spell, and the Portable C Compiler, w ...
, a computer scientist at
Bell Labs
Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984),
then AT&T Bell Laboratories (1984–1996)
and Bell Labs Innovations (1996–2007),
is an American industrial research and scientific development company owned by mult ...
, came up with 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 Look Ahead Left-to-Right Rightmost Derivation (LALR) parser generator, generating a LALR parser (the part of a comp ...
grammar he was writing for
C and dealing with
portability
Portability may refer to:
*Portability (social security), the portability of social security benefits
* Porting, the ability of a computer program to be ported from one system to another in computer science
** Software portability, the portability ...
issues stemming from porting
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser 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 32- bit units. Compared to smaller bit widths, 32-bit computers can perform large calcula ...
machine.
The term "lint" was derived from
lint
Lint may refer to:
* Fibrous coat of thick hairs covering the seeds of the cotton plant
* Lint (material), an accumulation of fluffy fibers that collect on fabric
Places
* Lint, Belgium, a municipality located in Antwerp, Belgium
* Linț, a vill ...
, the name for the tiny bits of fiber and fluff shed by clothing, as the command should act like the lint trap in a clothes dryer, detecting small errors to great effect. In 1979, lint 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 translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
s, and while modern-day compilers have lint-like functions, lint-like tools have also advanced their capabilities. For example, Gimpel's
PC-Lint, introduced in 1985 and used to analyze C++ source code, is still for sale.
Overview
The analysis performed by lint-like tools can also be performed by an
optimizing compiler
In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of an executable computer program. Common requirements are to minimize a program's execution time, memory footprint, storage size, and power cons ...
, which aims to generate faster code. In his original 1978 paper, Johnson addressed this issue, concluding that "the general notion of having two programs is a good one" because 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 rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
s,
data structure
In computer science, a data structure is a data organization, management, 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 rel ...
s, and correctness of the program, and then later retrofit, with the aid of lint, the desirable properties of universality and portability".
Even though modern
compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
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 that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
and
Python. Because the compilers of such languages typically do not enforce as many and as strict rules prior to
execution
Capital punishment, also known as the death penalty, is the state-sanctioned practice of deliberately killing a person as a punishment for an actual or supposed crime, usually following an authorized, rule-governed process to conclude that t ...
, linter tools can also be used as simple debuggers 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 of source code.
Lint-like tools have also been developed for other aspects of language, including grammar and style guides.
Specialization
Fortran
Fortran compilers using space-squeezing techniques (e.g.
IBM 1130
The IBM 1130 Computing System, introduced in 1965, was IBM's least expensive computer at that time. A binary 16-bit machine, it was marketed to price-sensitive, computing-intensive technical markets, like education and engineering, succeeding t ...
) made it impossible for the compiler to see the problem with lines like:
::::: .... DO 120 J=1
.256 ... 120 CONTINUE
which is why programs like ''Lint for Fortran'' can be helpful.
See also
*
Splint (programming tool)
*
List of tools for static code analysis
This is a list of notable tools for static program analysis (program analysis is a synonym for code analysis).
Static code analysis tools
Languages
Ada
*
*
*
*
*
*
*
*
*
*
*
C, C++
*
*
*
*
*
*
*
*
*
*
*
...
Notes
References
Further reading
*
* {{cite web
, url=https://www.freebsd.org/cgi/man.cgi?query=lint&manpath=FreeBSD+11.2-RELEASE
, title=LINT(1)
, work=FreeBSD General Commands Manual (FreeBSD 11.2)
, date=2015-03-23
Static program analysis tools
Unix software