Code bloat
   HOME

TheInfoList



OR:

In
computer programming Computer programming or coding is the composition of sequences of instructions, called computer program, programs, that computers can follow to perform tasks. It involves designing and implementing algorithms, step-by-step specifications of proc ...
, code bloat is the production of
program code A computer language is a formal language used to communicate with a computer. Types of computer languages include: * Construction language – all forms of communication by which a human can specify an executable problem solution to a comput ...
(
source code In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer. Since a computer, at base, only ...
or
machine code In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
) that is unnecessarily long, slow, or otherwise wasteful of resources. Code bloat can be caused by inadequacies in the
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
in which the code is written, the
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 ...
used to compile it, or the
programmer A programmer, computer programmer or coder is an author of computer source code someone with skill in computer programming. The professional titles Software development, ''software developer'' and Software engineering, ''software engineer' ...
writing it. Thus, while code bloat generally refers to source code size (as produced by the programmer), it can be used to refer instead to the ''generated'' code size or even the
binary file A binary file is a computer file that is not a text file. The term "binary file" is often used as a term meaning "non-text file". Many binary file formats contain parts that can be interpreted as text; for example, some computer document files ...
size.


Examples

The following JavaScript algorithm has a large number of redundant variables, unnecessary logic and inefficient string concatenation. // Complex function TK2getImageHTML(size, zoom, sensor, markers) ; The same logic can be stated more efficiently as follows: // Simplified const TK2getImageHTML = (size, zoom, sensor, markers) => ;


Code density of different languages

The difference in
code density In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, ...
between various
computer language A computer language is a formal language used to communicate with a computer. Types of computer languages include: * Software construction#Construction languages, Construction language – all forms of communication by which a human can Comput ...
s is so great that often less
memory Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembe ...
is needed to hold both a program written in a "compact" language (such as a
domain-specific programming language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
,
Microsoft P-Code In computer programming, a P-code machine (portable code machine) is a virtual machine designed to execute ''P-code,'' the assembly language or machine code of a hypothetical central processing unit (CPU). The term ''P-code machine'' is applied g ...
, or
threaded code In computer science, threaded code is a programming technique where the code has a form that essentially consists entirely of calls to subroutines. It is often used in compilers, which may generate code in that form or be implemented in that form ...
), plus an
interpreter Interpreting is translation from a spoken or signed language into another language, usually in real time to facilitate live communication. It is distinguished from the translation of a written text, which can be more deliberative and make use o ...
for that compact language (written in native code), than to hold that program written directly in
native code In computer programming, machine code is computer program, computer code consisting of machine language instruction set architecture, instructions, which are used to control a computer's central processing unit (CPU). For conventional binary ...
.


Reducing bloat

Some techniques for reducing code bloat include: *
Code refactoring In computer programming and software design, code refactoring is the process of restructuring existing source code—changing the '' factoring''—without changing its external behavior. Refactoring is intended to improve the design, structure, ...
a commonly used code sequence into a
subroutine In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a ...
, and calling that subroutine from several locations, rather than copy and pasting the code at each of those locations (
copy-and-paste programming Copy-and-paste programming, sometimes referred to as just pasting, is the production of highly repetitive computer programming code, as produced by copy and paste operations. It is primarily a pejorative term; those who use the term are often impl ...
). * Re-using subroutines that have already been written (perhaps with additional parameters), rather than re-writing them again from scratch as a new routine. * Combine
program analysis In computer science, program analysis is the process of analyzing the behavior of computer programs regarding a property such as correctness, robustness, safety and liveness. Program analysis focuses on two major areas: program optimization an ...
to detect bloated code, with
program transformation A program transformation is any operation that takes a computer program and generates another program. In many cases the transformed program is required to be semantically equivalent to the original, relative to a particular Formal semantics of p ...
to remove bloated code.


See also

*
Dead code elimination In compiler theory, dead-code elimination (DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove dead code (code that does not affect the program results). Removing such code has several benefits: i ...
*
Minimalism (computing) In computing, minimalism refers to the application of minimalist philosophies and principles in the design and use of hardware and software. Minimalism, in this sense, means designing systems that use the least hardware and software resources ...
*
Muntzing Muntzing is the practice and technique of reducing the components inside an electronic appliance to the minimum required for it to sufficiently function in most operating conditions, reducing design margins above minimum requirements toward zero. ...
*
Polymorphism (computer science) In programming language theory and type theory, polymorphism is the use of one symbol to represent multiple different types.: "Polymorphic types are types whose operations are applicable to values of more than one type." In object-oriented progr ...
*
Software optimization In computer science, program optimization, code optimization, or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources. In general, a computer program may be op ...
*
Software bloat Software bloat is a process whereby successive versions of a computer program become perceptibly slower, use more memory, disk space or processing power, or have higher hardware requirements than the previous version, while making only dubious ...
*
Lightweight software In computing, lightweight software also called lightweight program and lightweight application, is a computer program that is designed to have a small memory footprint (RAM usage) and low CPU usage, overall a low usage of system resources . To ach ...


References

{{Reflist, 30em Software optimization Software engineering folklore