ArticleslgStudy

computer science

Lint (software)

Lint (software) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Lint (software) rather than just read about it. In short: Lint is a Unix utility that performs static program analysis on C language source code. The software gives its name to modern computing tools responsible for checking for coding style or formatting errors, known as "linters" or "linting tools", even though the original Lint program performed static program analysis.

Key takeaways

  • Lint (software) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Lint (software) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Lint (software) from memory before moving on to harder problems.

Reference excerpt

Lint is a Unix utility that performs static program analysis on C language source code. The software gives its name to modern computing tools responsible for checking for coding style or formatting errors, known as "linters" or "linting tools", even though the original Lint program performed static program analysis.

History Stephen C. Johnson, a computer scientist at Bell Labs, came up with the term "lint" in 1978 while debugging the yacc grammar he was writing for C and dealing with portability issues stemming from porting Unix to a 32-bit machine. The term was borrowed from 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. The lint program was released outside of Bell Labs in Unix V7, in 1979. In his 1978 paper, Johnson explained his reasons for creating a new program to detect errors: "...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 algorithms, data structures, and correctness of the program, and then later retrofit, with the aid of lint, the desirable properties of universality and portability". The paper lists lint's additional checks as:

checks for unused variables and functions; checks for variables used before they're set or set but never used; checks for unreachable code; checks for functions that sometimes return with a return value and sometimes return with no return value; additional type checking; optional checks for non-portable type casts; checks for char values being non-portably tested for being negative; assignments of values that might not fit in the target variable, e.g. long values being assigned to an int variable; valid C statements that don't make sense, such as a statement *p++;, which increments p but does not use the pre-incremented value; possible pointer misalignment; code that behaves differently if the order of expression evaluation is done differently on different platforms or compilers; type mismatches between formal and actual parameters to functions. ANSI C introduced function prototypes, allowing ANSI C compilers to perform the checks for type mismatches between formal and actual function parameters if a function prototype has been seen before the function is called; it also added the void type for functions that return no value, allowing compilers to check for void functions that return a value, in addition to checks for functions that have a return value type but that return with no return value. Many of lint's checks can also be performed as part of the analysis done by optimizing compilers, so, when a sufficiently high level of optimization is being performed, C compilers would also perform checks for unused variables and functions, used-before-set and set-and-unused variable checks, checks for unreachable code. Other lint checks have also been added to C compilers over time.

Successors of Lint Separate lint-like programs are still being developed to perform additional code checking, such as code style checks and static program analysis. Even though modern compilers 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, [and]...dangerous language features". Checks to enforce grammar and style guides for given language source code are now referred to as linting. LLVM's clang-format for C and C++, Rustfmt for Rust, PHP CodeSniffer for PHP, ESLint for JavaScript, Stylelint for CSS, Pylint for Python, RuboCop for Ruby, and golint for Go are examples of these tools. Some such 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. Tools that perform more detailed static program analysis than compilers have also been developed, such as Coverity, cppcheck, and the Clang static analyzer. For JavaScript, ESLint performs static program analysis in addition to code style analysis. Lint-like tools are especially useful for dynamically typed languages like JavaScript and Python. Because the interpreters of such languages typically do not enforce as many and as strict rules during execution, 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 heisenbugs (drawing attention to suspicious code as "possible errors"). Lint-like tools generally perform static analysis of source code.

See also Splint (programming tool) List of tools for static code analysis

References

Further reading Darwin, Ian F. (1991). Checking C Programs with Lint: C Programming Utility (Revised ed.). United States: O'Reilly Media. ISBN 978-0-937175-30-9. "LINT(1)". NetBSD General Commands Manual. 2024-01-24.

Worked examples

Example 1 — a first encounter with Lint (software)

Start with the simplest possible case. Write down what Lint (software) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Lint (software) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Lint (software) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Lint (software)

In research
Lint (software) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Lint (software) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Lint (software) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Formerly proprietary software, Software using the BSD license, Static program analysis tools, so understanding it makes those chapters shorter.
In everyday life
Look for Lint (software) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Lint (software)” →

How to study Lint (software) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Lint (software) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Lint (software) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Lint (software) in simple terms?

Lint is a Unix utility that performs static program analysis on C language source code. The software gives its name to modern computing tools responsible for checking for coding style or formatting errors, known as "linters" or "linting tools", even though the original Lint program performed static…

Why does Lint (software) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Lint (software)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Lint (software).

Tags

  • Formerly proprietary software
  • Software using the BSD license
  • Static program analysis tools
  • Unix software

Keep exploring