Computer program

Instructions a computer can execute


title: "Computer program" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["computer-programming", "software"] description: "Instructions a computer can execute" topic_path: "technology/software-engineering" source: "https://en.wikipedia.org/wiki/Computer_program" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Instructions a computer can execute ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/a/a4/JavaScript_code.png" caption="[[Source code]] for a computer program written in the [[JavaScript]] language. It demonstrates the ''appendChild'' method. The method adds a new child node to an existing parent node. It is commonly used to dynamically modify the structure of an HTML document."] ::

A computer program is a sequence or set of instructions in a programming language for a computer to execute. It is one component of software, which also includes documentation and other intangible components.{{cite web | title=ISO/IEC 2382:2015 | website=ISO | date=2020-09-03 | url=https://www.iso.org/obp/ui/#iso:std:iso-iec:2382:ed-1:v1:en | access-date=2022-05-26 | quote=[Software includes] all or part of the programs, procedures, rules, and associated documentation of an information processing system. | archive-date=2016-06-17 | archive-url=https://web.archive.org/web/20160617031837/https://www.iso.org/obp/ui/#iso:std:iso-iec:2382:ed-1:v1:en | url-status=live

A computer program in its human-readable form is called source code. Source code needs another computer program to execute because computers can only execute their native machine instructions. Therefore, source code may be translated to machine instructions using a compiler written for the language. (Assembly language programs are translated using an assembler.) The resulting file is called an executable. Alternatively, source code may execute within an interpreter written for the language.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 7 | quote = An alternative to compiling a source program is to use an interpreter. An interpreter can directly execute a source program[.] | isbn = 0-201-71012-9

If the executable is requested for execution, then the operating system loads it into memory{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |quote = The kernel can load a new program into memory[.] |page=22}} and starts a process.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | year = 1994 | page = 98 | quote = Informally, a process is a program in execution. | isbn = 978-0-201-50480-4 | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 32 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/32

If the source code is requested for execution, then the operating system loads the corresponding interpreter into memory and starts a process. The interpreter then loads the source code into memory to translate and execute each statement. Running the source code is slower than running an executable.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 7 | isbn = 0-201-71012-9

Example computer program

The "Hello, World!" program is used to illustrate a language's basic syntax. The syntax of the language BASIC (1964) was intentionally limited to make the language easy to learn.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 30 | isbn = 0-201-71012-9 | quote = Their intention was to produce a language that was very simple for students to learn[.] | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 31 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 30 | isbn = 0-201-71012-9 ::code[lang=basic] 10 INPUT "How many numbers to average?", A 20 FOR I = 1 TO A 30 INPUT "Enter number:", B 40 LET C = C + B 50 NEXT I 60 LET D = C/A 70 PRINT "The average is", D 80 END ::

Once the mechanics of basic computer programming are learned, more sophisticated and powerful languages are available to build large computer systems.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 30 | isbn = 0-201-71012-9 | quote = The idea was that students could be merely casual users or go on from Basic to more sophisticated and powerful languages[.]

History

Improvements in software development are the result of improvements in computer hardware. At each stage in hardware's history, the task of computer programming changed dramatically.

Analytical Engine

::figure[src="https://upload.wikimedia.org/wikipedia/commons/c/cf/Diagram_for_the_computation_of_Bernoulli_numbers.jpg" caption="Lovelace's description from Note G"] ::

In 1837, Jacquard's loom inspired Charles Babbage to attempt to build the Analytical Engine.{{cite book | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 16 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/16 The names of the components of the calculating device were borrowed from the textile industry. In the textile industry, yarn was brought from the store to be milled. The device had a store which consisted of memory to hold 1,000 numbers of 50 decimal digits each.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 14 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/14 | first = Allan G. | last = Bromley | author-link = Allan G. Bromley | year = 1998 | url = https://profs.scienze.univr.it/~manca/storia-informatica/babbage.pdf | title = Charles Babbage's Analytical Engine, 1838 | journal = IEEE Annals of the History of Computing | volume = 20 | number = 4 | pages = 29–45 | doi = 10.1109/85.728228 | bibcode = 1998IAHC...20d..29B | s2cid = 2285332 | access-date = 2015-10-30 | archive-date = 2016-03-04 | archive-url = https://web.archive.org/web/20160304081812/http://profs.scienze.univr.it/~manca/storia-informatica/babbage.pdf | url-status = live | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 15 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/15

Ada Lovelace worked for Charles Babbage to create a description of the Analytical Engine (1843).{{citation |author1 = J. Fuegi |author2 =J. Francis |title = Lovelace & Babbage and the creation of the 1843 'notes' |journal = Annals of the History of Computing |volume = 25 |issue = 4 |date=October–December 2003 |doi = 10.1109/MAHC.2003.1253887 |pages = 16, 19, 25 |bibcode =2003IAHC...25d..16F

Universal Turing machine

::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/43/Universal_Turing_machine.svg"] ::

In 1936, Alan Turing introduced the Universal Turing machine, a theoretical device that can model every computation.{{cite book | last = Rosen | first = Kenneth H. | title = Discrete Mathematics and Its Applications | publisher = McGraw-Hill, Inc. | year = 1991 | page = 654 | isbn = 978-0-07-053744-6 | url = https://archive.org/details/discretemathemat00rose/page/654 | quote = Turing machines can model all the computations that can be performed on a computing machine. It is a finite-state machine that has an infinitely long read/write tape. The machine can move the tape back and forth, changing its contents as it performs an algorithm. The machine starts in the initial state, goes through a sequence of steps, and halts when it encounters the halt state.{{cite book | last = Linz | first = Peter | title = An Introduction to Formal Languages and Automata | publisher = D. C. Heath and Company | year = 1990 | page = 234 | isbn = 978-0-669-17342-0 | last = Linz | first = Peter | title = An Introduction to Formal Languages and Automata | publisher = D. C. Heath and Company | year = 1990 | page = 243 | isbn = 978-0-669-17342-0 | quote = [A]ll the common mathematical functions, no matter how complicated, are Turing-computable.

ENIAC

::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/e5/ENIAC-changing_a_tube.jpg" caption="Glenn A. Beck changing a tube in ENIAC"] ::

The Electronic Numerical Integrator And Computer (ENIAC) was built between July 1943 and Fall 1945. It was a Turing complete, general-purpose computer that used 17,468 vacuum tubes to create the circuits. At its core, it was a series of Pascalines wired together.{{cite book | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 102 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/102 | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 94 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/94 | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 107 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/107

Stored-program computers

Instead of plugging in cords and turning switches, a stored-program computer loads its instructions into memory just like it loads its data into memory.{{cite book | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 120 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/120 | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 118 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/118 | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 119 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/119 | last = McCartney | first = Scott | title = ENIAC – The Triumphs and Tragedies of the World's First Computer | publisher = Walker and Company | year = 1999 | page = 123 | isbn = 978-0-8027-1348-3 | url = https://archive.org/details/eniac00scot/page/123

The IBM System/360 (1964) was a family of computers, each having the same instruction set architecture. The Model 20 was the smallest and least expensive. Customers could upgrade and retain the same application software.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 21 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane | url-access = registration

IBM planned for each model to be programmed using PL/I.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 27 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 29 | isbn = 0-201-71012-9

::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/99/Dg-nova3.jpg" caption="Switches for manual input on a [[Data General Nova]] 3, manufactured in the mid-1970s"] ::

Computers manufactured until the 1970s had front-panel switches for manual programming.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | year = 1994 | page = 6 | isbn = 978-0-201-50480-4

Very Large Scale Integration

::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/4e/Diopsis.jpg" caption="die]]"] ::

A major milestone in software development was the invention of the Very Large Scale Integration (VLSI) circuit (1964).

Robert Noyce, co-founder of Fairchild Semiconductor (1957) and Intel (1968), achieved a technological improvement to refine the production of field-effect transistors (1963).{{cite book | url=https://books.google.com/books?id=UUbB3d2UnaAC&pg=PA46 | title=To the Digital Age: Research Labs, Start-up Companies, and the Rise of MOS | publisher=Johns Hopkins University Press | year=2002 | isbn=9780801886393 | access-date=February 3, 2022 | archive-date=February 2, 2023 | archive-url=https://web.archive.org/web/20230202181649/https://books.google.com/books?id=UUbB3d2UnaAC&pg=PA46 | url-status=live | url=https://www.osti.gov/servlets/purl/1497235 | title=Manufacturing of Silicon Materials for Microelectronics and Solar PV | publisher=Sandia National Laboratories | year=2017 | access-date=February 8, 2022 | last1=Chalamala | first1=Babu | archive-date=March 23, 2023 | archive-url=https://web.archive.org/web/20230323163602/https://www.osti.gov/biblio/1497235 | url-status=live | url=https://www.britannica.com/technology/integrated-circuit/Fabricating-ICs#ref837156 | title=Fabricating ICs Making a base wafer | publisher=Britannica | access-date=February 8, 2022 | archive-date=February 8, 2022 | archive-url=https://web.archive.org/web/20220208103132/https://www.britannica.com/technology/integrated-circuit/Fabricating-ICs#ref837156 | url-status=live | author1=Anysilicon | url=https://anysilicon.com/introduction-to-nmos-and-pmos-transistors/ | title=Introduction to NMOS and PMOS Transistors | work=AnySilicon | date=4 November 2021 | access-date=February 5, 2022 | archive-date=6 February 2022 | archive-url=https://web.archive.org/web/20220206051146/https://anysilicon.com/introduction-to-nmos-and-pmos-transistors/ | url-status=live | url=https://www.britannica.com/technology/microprocessor#ref36149 | title=microprocessor definition | publisher=Britannica | access-date=April 1, 2022 | archive-date=April 1, 2022 | archive-url=https://web.archive.org/web/20220401085141/https://www.britannica.com/technology/microprocessor#ref36149 | url-status=live

Originally, integrated circuit chips had their function set during manufacturing. During the 1960s, controlling the electrical flow migrated to programming a matrix of read-only memory (ROM). The matrix resembled a two-dimensional array of fuses. The process to embed instructions onto the matrix was to burn out the unneeded connections. There were so many connections, firmware programmers wrote a computer program on another chip to oversee the burning. The technology became known as Programmable ROM. In 1971, Intel installed the computer program onto the chip and named it the Intel 4004 microprocessor.{{cite web | url=https://spectrum.ieee.org/chip-hall-of-fame-intel-4004-microprocessor | title=Chip Hall of Fame: Intel 4004 Microprocessor | publisher=Institute of Electrical and Electronics Engineers | date=July 2, 2018 | access-date=January 31, 2022 | archive-date=February 7, 2022 | archive-url=https://web.archive.org/web/20220207101915/https://spectrum.ieee.org/chip-hall-of-fame-intel-4004-microprocessor | url-status=live

::figure[src="https://upload.wikimedia.org/wikipedia/commons/d/da/Slt1.jpg" caption="IBM's System/360 (1964) CPU was not a microprocessor."] ::

The terms microprocessor and central processing unit (CPU) are now used interchangeably. However, CPUs predate microprocessors. For example, the IBM System/360 (1964) had a CPU made from circuit boards containing discrete components on ceramic substrates.{{cite web | url=https://www.computer-museum.ru/books/archiv/ibm36040.pdf |archive-url=https://ghostarchive.org/archive/20221010/https://www.computer-museum.ru/books/archiv/ibm36040.pdf |archive-date=2022-10-10 |url-status=live | title=360 Revolution | publisher=Father, Son & Co. | year=1990 | access-date=February 5, 2022

x86 series

::figure[src="https://upload.wikimedia.org/wikipedia/commons/a/a6/IBM_PC-IMG_7271_(transparent).png" caption="The original [[IBM Personal Computer]] (1981) used an Intel 8088 microprocessor."] ::

In 1978, the modern software development environment began when Intel upgraded the Intel 8080 to the Intel 8086. Intel simplified the Intel 8086 to manufacture the cheaper Intel 8088.{{cite web | url=https://books.google.com/books?id=VDAEAAAAMBAJ&pg=PA22 | title=Bill Gates, Microsoft and the IBM Personal Computer | publisher=InfoWorld | date=August 23, 1982 | access-date=1 February 2022 | archive-date=18 February 2023 | archive-url=https://web.archive.org/web/20230218183644/https://books.google.com/books?id=VDAEAAAAMBAJ&pg=PA22 | url-status=live

Changing programming environment

::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/9f/DEC_VT100_terminal_transparent.png" caption="DEC]] [[VT100]] (1978) was a widely used [[computer terminal]]."] ::

VLSI circuits enabled the programming environment to advance from a computer terminal (until the 1990s) to a graphical user interface (GUI) computer. Computer terminals limited programmers to a single shell running in a command-line environment. During the 1970s, full-screen source code editing became possible through a text-based user interface. Regardless of the technology available, the goal is to program in a programming language.

Programming paradigms and languages

Programming language features exist to provide building blocks to be combined to express programming ideals.{{cite book | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 10 | isbn = 978-0-321-56384-2

  • express ideas directly in the code.
  • express independent ideas independently.
  • express relationships among ideas directly in the code.
  • combine ideas freely.
  • combine ideas only where combinations make sense.
  • express simple ideas simply.

The programming style of a programming language to provide these building blocks may be categorized into programming paradigms.{{cite book | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 11 | isbn = 978-0-321-56384-2

A programming language is a set of keywords, symbols, identifiers, and rules by which programmers can communicate instructions to the computer.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 159 | isbn = 0-619-06489-7

Programming languages get their basis from formal languages.{{cite book | last = Linz | first = Peter | title = An Introduction to Formal Languages and Automata | publisher = D. C. Heath and Company | year = 1990 | page = 2 | isbn = 978-0-669-17342-0 | last = Weiss | first = Mark Allen | title = Data Structures and Algorithm Analysis in C++ | publisher = Benjamin/Cummings Publishing Company, Inc. | year = 1994 | page = 29 | isbn = 0-8053-5443-3

Generations of programming language

Main article: Programming language generations

::figure[src="https://upload.wikimedia.org/wikipedia/commons/c/c0/W65C816S_Machine_Code_Monitor.jpeg" caption="[[Machine language]] monitor on a [[W65C816S]] [[microprocessor]]"] ::

The evolution of programming languages began when the EDSAC (1949) used the first stored computer program in its von Neumann architecture.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 17 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/17

  • The first generation of programming language is machine language.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 160 | isbn = 0-619-06489-7 | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 399 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/399

  • The second generation of programming language is assembly language. Assembly language allows the programmer to use mnemonic instructions instead of remembering instruction numbers. An assembler translates each assembly language mnemonic into its machine language number. For example, on the PDP-11, the operation 24576 can be referenced as ADD R0,R0 in the source code. The four basic arithmetic operations have assembly instructions like ADD, SUB, MUL, and DIV. Computers also have instructions like DW (Define Word) to reserve memory cells. Then the MOV instruction can copy integers between registers and memory.

:* The basic structure of an assembly language statement is a label, operation, operand, and comment.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 400 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/400 ::* Labels allow the programmer to work with variable names. The assembler will later translate labels into physical memory addresses. ::* Operations allow the programmer to work with mnemonics. The assembler will later translate mnemonics into instruction numbers. ::* Operands tell the assembler which data the operation will process. ::* Comments allow the programmer to articulate a narrative because the instructions alone are vague. :: The key characteristic of an assembly language program is it forms a one-to-one mapping to its corresponding machine language target.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Third Edition | publisher = Prentice Hall | year = 1990 | page = 398 | isbn = 978-0-13-854662-5 | url = https://archive.org/details/structuredcomput00tane/page/398

  • The third generation of programming language uses compilers and interpreters to execute computer programs. The distinguishing feature of a third generation language is its independence from particular hardware.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 26 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 37 | isbn = 0-201-71012-9 | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 160 | isbn = 0-619-06489-7 | quote = With third-generation and higher-level programming languages, each statement in the language translates into several instructions in machine language.

  • The fourth generation of programming language emphasizes what output results are desired, rather than how programming statements should be constructed. Declarative languages attempt to limit side effects and allow programmers to write code with relatively few errors. One popular fourth generation language is called Structured Query Language (SQL). Database developers no longer need to process each database record one at a time. Also, a simple select statement can generate output records without having to understand how they are retrieved.

Imperative languages

Main article: Imperative programming

::figure[src="https://upload.wikimedia.org/wikipedia/commons/3/37/Object-Oriented-Programming-Methods-And-Classes-with-Inheritance.png" caption="A computer program written in an imperative language"] ::

Imperative languages specify a sequential algorithm using declarations, expressions, and statements:{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Second Edition | publisher = Addison-Wesley | year = 1993 | page = 75 | isbn = 978-0-201-56885-1

  • A declaration introduces a variable name to the computer program and assigns it to a datatype{{cite book | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 40 | isbn = 978-0-321-56384-2
  • An expression yields a value – for example: 2 + 2 yields 4
  • A statement might assign an expression to a variable or use the value of a variable to alter the program's control flow – for example: x := 2 + 2; [if](conditional-computer-programming-if-then-else) x = 4 then do_something();

Fortran

FORTRAN (1958) was unveiled as "The IBM Mathematical FORmula TRANslating system". It was designed for scientific calculations, without string handling facilities. Along with declarations, expressions, and statements, it supported:

It succeeded because:

  • programming and debugging costs were below computer running costs.
  • it was supported by IBM.
  • applications at the time were scientific.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 16 | isbn = 0-201-71012-9

However, non-IBM vendors also wrote Fortran compilers, but with a syntax that would likely fail IBM's compiler. The American National Standards Institute (ANSI) developed the first Fortran standard in 1966. In 1978, Fortran 77 became the standard until 1991. Fortran 90 supports:

COBOL

COBOL (1959) stands for "COmmon Business Oriented Language". Fortran manipulated symbols. It was soon realized that symbols did not need to be numbers, so strings were introduced.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 24 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 25 | isbn = 0-201-71012-9

COBOL's development was tightly controlled, so dialects did not emerge to require ANSI standards. As a consequence, it was not changed for 15 years until 1974. The 1990s version did make consequential changes, like object-oriented programming.

Algol

ALGOL (1960) stands for "ALGOrithmic Language". It had a profound influence on programming language design.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 19 | isbn = 0-201-71012-9

Algol's direct descendants include Pascal, Modula-2, Ada, Delphi and Oberon on one branch. On another branch the descendants include C, C++ and Java.

Basic

BASIC (1964) stands for "Beginner's All-Purpose Symbolic Instruction Code". It was developed at Dartmouth College for all of their students to learn. If a student did not go on to a more powerful language, the student would still remember Basic. A Basic interpreter was installed in the microcomputers manufactured in the late 1970s. As the microcomputer industry grew, so did the language.

Basic pioneered the interactive session. It offered operating system commands within its environment:

  • The 'new' command created an empty slate.
  • Statements evaluated immediately.
  • Statements could be programmed by preceding them with line numbers.
  • The 'list' command displayed the program.
  • The 'run' command executed the program.

However, the Basic syntax was too simple for large programs. Recent dialects added structure and object-oriented extensions. Microsoft's Visual Basic is still widely used and produces a graphical user interface.

C

C programming language (1973) got its name because the language BCPL was replaced with B, and AT&T Bell Labs called the next version "C". Its purpose was to write the UNIX operating system. C is a relatively small language, making it easy to write compilers. Its growth mirrored the hardware growth in the 1980s. Its growth also was because it has the facilities of assembly language, but it uses a high-level syntax. It added advanced features like:

::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/93/Computer-memory-map.png" caption="Computer memory map"] ::

C allows the programmer to control which region of memory data is to be stored. Global variables and static variables require the fewest clock cycles to store. The stack is automatically used for the standard variable declarations. Heap memory is returned to a pointer variable from the malloc() function.

  • The global and static data region is located just above the program region. (The program region is technically called the text region. It is where machine instructions are stored.) :* The global and static data region is technically two regions.{{cite web | url = https://www.geeksforgeeks.org/memory-layout-of-c-program/ | title = Memory Layout of C Programs | date = 12 September 2011 | access-date = 6 November 2021 | archive-date = 6 November 2021 | archive-url = https://web.archive.org/web/20211106175644/https://www.geeksforgeeks.org/memory-layout-of-c-program/ | url-status = live :* Variables stored in the global and static data region have their addresses set at compile time. They retain their values throughout the life of the process.

:* The global and static region stores the global variables that are declared on top of (outside) the main() function.{{cite book |title=The C Programming Language Second Edition |last1=Kernighan |first1=Brian W. |last2=Ritchie |first2=Dennis M. |publisher=Prentice Hall |year=1988 |isbn=0-13-110362-8 |page=31}} Global variables are visible to main() and every other function in the source code.

: On the other hand, variable declarations inside of main(), other functions, or within { } block delimiters are local variables. Local variables also include formal parameter variables. Parameter variables are enclosed within the parenthesis of a function definition.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 128 | isbn = 0-201-71012-9

:* Local variables declared using the static prefix are also stored in the global and static data region. Unlike global variables, static variables are only visible within the function or block. Static variables always retain their value. An example usage would be the function int increment_counter(){static int counter = 0; counter++; return counter;}

  • The stack region is a contiguous block of memory located near the top memory address.{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=121}} Variables placed in the stack are populated from top to bottom. A stack pointer is a special-purpose register that keeps track of the last memory address populated. Variables are placed into the stack via the assembly language PUSH instruction. Therefore, the addresses of these variables are set during runtime. The method for stack variables to lose their scope is via the POP instruction.

:* Local variables declared without the static prefix, including formal parameter variables,{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=122}} are called automatic variables and are stored in the stack. They are visible inside the function or block and lose their scope upon exiting the function or block.

  • The heap region is located below the stack. It is populated from the bottom to the top. The operating system manages the heap using a heap pointer and a list of allocated memory blocks.{{cite book |title=The C Programming Language Second Edition |last1=Kernighan |first1=Brian W. |last2=Ritchie |first2=Dennis M. |publisher=Prentice Hall |year=1988 |isbn=0-13-110362-8 |page=185}} Like the stack, the addresses of heap variables are set during runtime. An out of memory error occurs when the heap pointer and the stack pointer meet.

:* C provides the malloc() library function to allocate heap memory.{{cite book |title=The C Programming Language Second Edition |last1=Kernighan |first1=Brian W. |last2=Ritchie |first2=Dennis M. |publisher=Prentice Hall |year=1988 |isbn=0-13-110362-8 |page=187}} Populating the heap with data is an additional copy function. Variables stored in the heap are economically passed to functions using pointers. Without pointers, the entire block of data would have to be passed to the function via the stack.

C++

In the 1970s, software engineers needed language support to break large projects down into modules.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 38 | isbn = 0-201-71012-9

In object-oriented jargon, abstract datatypes are called classes. However, a class is only a definition; no memory is allocated. When memory is allocated to a class and bound to an identifier, it is called an object.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 193 | isbn = 0-201-71012-9

Object-oriented imperative languages developed by combining the need for classes and the need for safe functional programming.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 39 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 35 | isbn = 0-201-71012-9

Object-oriented languages support a syntax to model subset/superset relationships. In set theory, an element of a subset inherits all the attributes contained in the superset. For example, a student is a person. Therefore, the set of students is a subset of the set of persons. As a result, students inherit all the attributes common to all persons. Additionally, students have unique attributes that other people do not have. Object-oriented languages model subset/superset relationships using inheritance.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 192 | isbn = 0-201-71012-9

C++ (1985) was originally called "C with Classes".{{cite book | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 22 | isbn = 978-0-321-56384-2 | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 21 | isbn = 978-0-321-56384-2

An object-oriented module is composed of two files. The definitions file is called the header file. Here is a C++ header file for the GRADE class in a simple school application:

::code[lang=cpp] // grade.h // -------

// Used to allow multiple source files to include // this header file without duplication errors. // ---------------------------------------------- #ifndef GRADE_H #define GRADE_H

class GRADE { public: // This is the constructor operation. // ---------------------------------- GRADE ( const char letter );

// This is a class variable.
// -------------------------
char letter;

// This is a member operation.
// ---------------------------
int grade_numeric( const char letter );

// This is a class variable.
// -------------------------
int numeric;

}; #endif ::

A constructor operation is a function with the same name as the class name.{{cite book | last = Stroustrup | first = Bjarne | title = The C++ Programming Language, Fourth Edition | publisher = Addison-Wesley | year = 2013 | page = 49 | isbn = 978-0-321-56384-2

A module's other file is the source file. Here is a C++ source file for the GRADE class in a simple school application:

::code[lang=cpp] // grade.cpp // --------- #include "grade.h"

GRADE::GRADE( const char letter ) { // Reference the object using the keyword 'this'. // ---------------------------------------------- this->letter = letter;

// This is Temporal Cohesion
// -------------------------
this->numeric = grade_numeric( letter );

}

int GRADE::grade_numeric( const char letter ) { if ( ( letter == 'A' || letter == 'a' ) ) return 4; else if ( ( letter == 'B' || letter == 'b' ) ) return 3; else if ( ( letter == 'C' || letter == 'c' ) ) return 2; else if ( ( letter == 'D' || letter == 'd' ) ) return 1; else if ( ( letter == 'F' || letter == 'f' ) ) return 0; else return -1; } ::

Here is a C++ header file for the PERSON class in a simple school application:

::code[lang=cpp] // person.h // -------- #ifndef PERSON_H #define PERSON_H

class PERSON { public: PERSON ( const char *name ); const char *name; }; #endif ::

Here is a C++ source file for the PERSON class in a simple school application:

::code[lang=cpp] // person.cpp // ---------- #include "person.h"

PERSON::PERSON ( const char *name ) { this->name = name; } ::

Here is a C++ header file for the STUDENT class in a simple school application:

::code[lang=cpp] // student.h // --------- #ifndef STUDENT_H #define STUDENT_H

#include "person.h" #include "grade.h"

// A STUDENT is a subset of PERSON. // -------------------------------- class STUDENT : public PERSON{ public: STUDENT ( const char *name ); GRADE *grade; }; #endif ::

Here is a C++ source file for the STUDENT class in a simple school application:

::code[lang=cpp] // student.cpp // ----------- #include "student.h" #include "person.h"

STUDENT::STUDENT ( const char *name ): // Execute the constructor of the PERSON superclass. // ------------------------------------------------- PERSON( name ) { // Nothing else to do. // ------------------- } ::

Here is a driver program for demonstration:

::code[lang=cpp] // student_dvr.cpp // --------------- #include #include "student.h"

int main( void ) { STUDENT *student = new STUDENT( "The Student" ); student->grade = new GRADE( 'a' );

std::cout
    // Notice student inherits PERSON's name
    << student->name
    << ": Numeric grade = "
    << student->grade->numeric
    << "\n";
return 0;

} ::

Here is a makefile to compile everything:

::code[lang=make]

makefile

--------

all: student_dvr

clean: rm student_dvr *.o

student_dvr: student_dvr.cpp grade.o student.o person.o c++ student_dvr.cpp grade.o student.o person.o -o student_dvr

grade.o: grade.cpp grade.h c++ -c grade.cpp

student.o: student.cpp student.h c++ -c student.cpp

person.o: person.cpp person.h c++ -c person.cpp ::

Declarative languages

Main article: Declarative programming

Imperative languages have one major criticism: assigning an expression to a non-local variable may produce an unintended side effect.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 218 | isbn = 0-201-71012-9

The principle behind a functional language is to use lambda calculus as a guide for a well defined semantic.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 217 | isbn = 0-201-71012-9

times_10(x) = 10 * x

The expression 10 * x is mapped by the function times_10() to a range of values. One value happens to be 20. This occurs when x is 2. So, the application of the function is mathematically written as:

times_10(2) = 20

A functional language compiler will not store this value in a variable. Instead, it will push the value onto the computer's stack before setting the program counter back to the calling function. The calling function will then pop the value from the stack.{{cite book | last = Weiss | first = Mark Allen | title = Data Structures and Algorithm Analysis in C++ | publisher = Benjamin/Cummings Publishing Company, Inc. | year = 1994 | page = 103 | isbn = 0-8053-5443-3 | quote = When there is a function call, all the important information needs to be saved, such as register values (corresponding to variable names) and the return address (which can be obtained from the program counter)[.] ... When the function wants to return, it ... restores all the registers. It then makes the return jump. Clearly, all of this work can be done using a stack, and that is exactly what happens in virtually every programming language that implements recursion.

Imperative languages do support functions. Therefore, functional programming can be achieved in an imperative language, if the programmer uses discipline. However, a functional language will force this discipline onto the programmer through its syntax. Functional languages have a syntax tailored to emphasize the what.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 230 | isbn = 0-201-71012-9

A functional program is developed with a set of primitive functions followed by a single driver function. Consider the snippet:

function max( a, b ){/* code omitted */}

function min( a, b ){/* code omitted */}

function range( a, b, c ) { :return max( a, max( b, c ) ) - min( a, min( b, c ) ); }

The primitives are max() and min(). The driver function is range(). Executing:

put( range( 10, 4, 7) ); will output 6.

Functional languages are used in computer science research to explore new language features.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 240 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 241 | isbn = 0-201-71012-9

Lisp

Lisp (1958) stands for "LISt Processor".{{cite book | last1=Jones | first1=Robin | last2=Maynard | first2=Clive | last3=Stewart | first3=Ian | title=The Art of Lisp Programming | date=December 6, 2012 | publisher=Springer Science & Business Media | isbn=9781447117193 | page=2}} It is tailored to process lists. A full structure of the data is formed by building lists of lists. In memory, a tree data structure is built. Internally, the tree structure lends nicely for recursive functions.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 220 | isbn = 0-201-71012-9

((A B) (HELLO WORLD) 94)

Lisp has functions to extract and reconstruct elements.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 221 | isbn = 0-201-71012-9

cons(head(x), tail(x))

One drawback of Lisp is when many functions are nested, the parentheses may look confusing. Modern Lisp environments help ensure parenthesis match. As an aside, Lisp does support the imperative language operations of the assignment statement and goto loops.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 229 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 227 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 222 | isbn = 0-201-71012-9

Writing large, reliable, and readable Lisp programs requires forethought. If properly planned, the program may be much shorter than an equivalent imperative language program. Lisp is widely used in artificial intelligence. However, its usage has been accepted only because it has imperative language operations, making unintended side-effects possible.

ML

ML (1973){{cite web | last = Gordon | first = Michael J. C. | author-link = Michael J. C. Gordon | year = 1996 | title = From LCF to HOL: a short history | url = http://www.cl.cam.ac.uk/~mjcg/papers/HolHistory.html | access-date = 2021-10-30 | archive-date = 2016-09-05 | archive-url = https://web.archive.org/web/20160905201847/http://www.cl.cam.ac.uk/~mjcg/papers/HolHistory.html | url-status = live | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 233 | isbn = 0-201-71012-9

ML is not parenthesis-eccentric like Lisp. The following is an application of times_10():

times_10 2

It returns "20 : int". (Both the results and the datatype are returned.)

Like Lisp, ML is tailored to process lists. Unlike Lisp, each element is the same datatype.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 235 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 55 | isbn = 0-201-71012-9

Prolog

Prolog (1972) stands for "PROgramming in LOGic". It is a logic programming language, based on formal logic. The language was developed by Alain Colmerauer and Philippe Roussel in Marseille, France. It is an implementation of Selective Linear Definite clause resolution, pioneered by Robert Kowalski and others at the University of Edinburgh.{{Cite journal | publisher = Association for Computing Machinery | doi = 10.1145/155360.155362 | first1 = A. | last1 = Colmerauer | first2 = P. | last2 = Roussel | title = The birth of Prolog | journal = ACM SIGPLAN Notices | volume = 28 | issue = 3 | page = 5 | year = 1992 | url=http://alain.colmerauer.free.fr/alcol/ArchivesPublications/PrologHistory/19november92.pdf}}

The building blocks of a Prolog program are facts and rules. Here is a simple example: ::code[lang=prolog] cat(tom). % tom is a cat mouse(jerry). % jerry is a mouse

animal(X) :- cat(X). % each cat is an animal animal(X) :- mouse(X). % each mouse is an animal

big(X) :- cat(X). % each cat is big small(X) :- mouse(X). % each mouse is small

eat(X,Y) :- mouse(X), cheese(Y). % each mouse eats each cheese eat(X,Y) :- big(X), small(Y). % each big animal eats each small animal ::

After all the facts and rules are entered, then a question can be asked: : Will Tom eat Jerry? ::code[lang=prolog] ?- eat(tom,jerry). true ::

The following example shows how Prolog will convert a letter grade to its numeric value: ::code[lang=prolog] numeric_grade('A', 4). numeric_grade('B', 3). numeric_grade('C', 2). numeric_grade('D', 1). numeric_grade('F', 0). numeric_grade(X, -1) :- not X = 'A', not X = 'B', not X = 'C', not X = 'D', not X = 'F'. grade('The Student', 'A'). ::

::code[lang=prolog] ?- grade('The Student', X), numeric_grade(X, Y). X = 'A', Y = 4 ::

Here is a comprehensive example:

  1. All dragons billow fire, or equivalently, a thing billows fire if the thing is a dragon: ::code[lang=prolog] billows_fire(X) :- is_a_dragon(X). ::

  2. A creature billows fire if one of its parents billows fire: ::code[lang=prolog] billows_fire(X) :- is_a_creature(X), is_a_parent_of(Y,X), billows_fire(Y). ::

  3. A thing X is a parent of a thing Y if X is the mother of Y or X is the father of Y: ::code[lang=prolog] is_a_parent_of(X, Y):- is_the_mother_of(X, Y). is_a_parent_of(X, Y):- is_the_father_of(X, Y). ::

  4. A thing is a creature if the thing is a dragon: ::code[lang=prolog] is_a_creature(X) :- is_a_dragon(X). ::

  5. Norberta is a dragon, and Puff is a creature. Norberta is the mother of Puff.

::code[lang=prolog] is_a_dragon(norberta). is_a_creature(puff). is_the_mother_of(norberta, puff). ::

Rule (2) is a recursive (inductive) definition. It can be understood declaratively, without the need to understand how it is executed.

Rule (3) shows how functions are represented by using relations. Here, the mother and father functions ensure that every individual has only one mother and only one father.

Prolog is an untyped language. Nonetheless, inheritance can be represented by using predicates. Rule (4) asserts that a creature is a superclass of a dragon.

Questions are answered using backward reasoning. Given the question:

::code[lang=prolog] ?- billows_fire(X). ::

Prolog generates two answers : ::code[lang=prolog] X = norberta X = puff ::

Practical applications for Prolog are knowledge representation and problem solving in artificial intelligence.

Object-oriented programming

Object-oriented programming is a programming method to execute operations (functions) on objects.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 35 | isbn = 0-201-71012-9 | quote = Simula was based on Algol 60 with one very important addition — the class concept. ... The basic idea was that the data (or data structure) and the operations performed on it belong together[.] | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 39 | isbn = 0-201-71012-9 | quote = Originally, a large number of experimental languages were designed, many of which combined object-oriented and functional programming. | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 284 | isbn = 0-256-08515-3 | quote = While it is true that OOD [(object oriented design)] as such is not supported by the majority of popular languages, a large subset of OOD can be used. | last = Weiss | first = Mark Allen | title = Data Structures and Algorithm Analysis in C++ | publisher = Benjamin/Cummings Publishing Company, Inc. | year = 1994 | page = 57 | isbn = 0-8053-5443-3

Here is a C programming language header file for the GRADE abstract datatype in a simple school application:

::code[lang=c] /* grade.h / / ------- */

/* Used to allow multiple source files to include / / this header file without duplication errors. / / ---------------------------------------------- */ #ifndef GRADE_H #define GRADE_H

typedef struct { char letter; } GRADE;

/* Constructor / / ----------- */ GRADE *grade_new( char letter );

int grade_numeric( char letter ); #endif ::

The grade_new() function performs the same algorithm as the C++ constructor operation.

Here is a C programming language source file for the GRADE abstract datatype in a simple school application:

::code[lang=c] /* grade.c / / ------- */ #include "grade.h"

GRADE *grade_new( char letter ) { GRADE *grade;

/* Allocate heap memory */
/* -------------------- */
if ( ! ( grade = calloc( 1, sizeof ( GRADE ) ) ) )
{
    fprintf(stderr,
            "ERROR in %s/%s/%d: calloc() returned empty.\n",
            __FILE__,
            __FUNCTION__,
            __LINE__ );
    exit( 1 );
}

grade->letter = letter;
return grade;

}

int grade_numeric( char letter ) { if ( ( letter == 'A' || letter == 'a' ) ) return 4; else if ( ( letter == 'B' || letter == 'b' ) ) return 3; else if ( ( letter == 'C' || letter == 'c' ) ) return 2; else if ( ( letter == 'D' || letter == 'd' ) ) return 1; else if ( ( letter == 'F' || letter == 'f' ) ) return 0; else return -1; } ::

In the constructor, the function calloc() is used instead of malloc() because each memory cell will be set to zero.

Here is a C programming language header file for the PERSON abstract datatype in a simple school application:

::code[lang=cpp] /* person.h / / -------- */ #ifndef PERSON_H #define PERSON_H

typedef struct { char *name; } PERSON;

/* Constructor / / ----------- */ PERSON *person_new( char *name ); #endif ::

Here is a C programming language source file for the PERSON abstract datatype in a simple school application:

::code[lang=cpp] /* person.c / / -------- */ #include "person.h"

PERSON *person_new( char *name ) { PERSON *person;

if ( ! ( person = calloc( 1, sizeof ( PERSON ) ) ) )
{
    fprintf(stderr,
            "ERROR in %s/%s/%d: calloc() returned empty.\n",
            __FILE__,
            __FUNCTION__,
            __LINE__ );
    exit( 1 );
}

person->name = name;
return person;

} ::

Here is a C programming language header file for the STUDENT abstract datatype in a simple school application:

::code[lang=c] /* student.h / / --------- */ #ifndef STUDENT_H #define STUDENT_H

#include "person.h" #include "grade.h"

typedef struct { /* A STUDENT is a subset of PERSON. / / -------------------------------- */ PERSON *person;

GRADE *grade;

} STUDENT;

/* Constructor / / ----------- */ STUDENT *student_new( char *name ); #endif ::

Here is a C programming language source file for the STUDENT abstract datatype in a simple school application:

::code[lang=cpp] /* student.c / / --------- */ #include "student.h" #include "person.h"

STUDENT *student_new( char *name ) { STUDENT *student;

if ( ! ( student = calloc( 1, sizeof ( STUDENT ) ) ) )
{
    fprintf(stderr,
            "ERROR in %s/%s/%d: calloc() returned empty.\n",
            __FILE__,
            __FUNCTION__,
            __LINE__ );
    exit( 1 );
}

/* Execute the constructor of the PERSON superclass. */
/* ------------------------------------------------- */
student->person = person_new( name );
return student;

} ::

Here is a driver program for demonstration:

::code[lang=c] /* student_dvr.c / / ------------- */ #include <stdio.h> #include "student.h"

int main( void ) { STUDENT *student = student_new( "The Student" ); student->grade = grade_new( 'a' );

printf( "%s: Numeric grade = %d\n",
        /* Whereas a subset exists, inheritance does not. */
        student->person->name,
        /* Functional programming is executing functions just-in-time (JIT) */
        grade_numeric( student->grade->letter ) );

return 0;

} ::

Here is a makefile to compile everything:

::code[lang=make]

makefile

--------

all: student_dvr

clean: rm student_dvr *.o

student_dvr: student_dvr.c grade.o student.o person.o gcc student_dvr.c grade.o student.o person.o -o student_dvr

grade.o: grade.c grade.h gcc -c grade.c

student.o: student.c student.h gcc -c student.c

person.o: person.c person.h gcc -c person.c ::

The formal strategy to build object-oriented objects is to:{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 285 | isbn = 0-256-08515-3

  • Identify the objects. Most likely these will be nouns.
  • Identify each object's attributes. What helps to describe the object?
  • Identify each object's actions. Most likely these will be verbs.
  • Identify the relationships from object to object. Most likely these will be verbs.

For example:

  • A person is a human identified by a name.
  • A grade is an achievement identified by a letter.
  • A student is a person who earns a grade.

Syntax and semantics

::figure[src="https://upload.wikimedia.org/wikipedia/commons/1/1a/Terminal_and_non-terminal_symbols_example.png" caption="Production rules consist of a set of terminals and non-terminals."] ::

The syntax of a computer program is a list of production rules which form its grammar.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 290 | quote = The syntax (or grammar) of a programming language describes the correct form in which programs may be written[.] | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 78 | isbn = 0-201-71012-9 | quote = The main components of an imperative language are declarations, expressions, and statements. | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 290 | isbn = 0-201-71012-9 | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 294 | isbn = 0-201-71012-9

The syntax of a language is formally described by listing the production rules. Whereas the syntax of a natural language is extremely complicated, a subset of the English language can have this production rule listing:{{cite book | last = Rosen | first = Kenneth H. | title = Discrete Mathematics and Its Applications | publisher = McGraw-Hill, Inc. | year = 1991 | page = 615 | isbn = 978-0-07-053744-6 | url = https://archive.org/details/discretemathemat00rose/page/615}}

  1. a sentence is made up of a noun-phrase followed by a verb-phrase;
  2. a noun-phrase is made up of an article followed by an adjective followed by a noun;
  3. a verb-phrase is made up of a verb followed by a noun-phrase;
  4. an article is 'the';
  5. an adjective is 'big' or
  6. an adjective is 'small';
  7. a noun is 'cat' or
  8. a noun is 'mouse';
  9. a verb is 'eats'; The words in bold-face are known as non-terminals. The words in 'single quotes' are known as terminals.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 291 | isbn = 0-201-71012-9

From this production rule listing, complete sentences may be formed using a series of replacements.{{cite book | last = Rosen | first = Kenneth H. | title = Discrete Mathematics and Its Applications | publisher = McGraw-Hill, Inc. | year = 1991 | page = 616 | isbn = 978-0-07-053744-6 | url = https://archive.org/details/discretemathemat00rose/page/616}} The process is to replace non-terminals with either a valid non-terminal or a valid terminal. The replacement process repeats until only terminals remain. One valid sentence is:

  • sentence
  • noun-phrase verb-phrase
  • article adjective noun verb-phrase
  • the adjective noun verb-phrase
  • the big noun verb-phrase
  • the big cat verb-phrase
  • the big cat verb noun-phrase
  • the big cat eats noun-phrase
  • the big cat eats article adjective noun
  • the big cat eats the adjective noun
  • the big cat eats the small noun
  • the big cat eats the small mouse

However, another combination results in an invalid sentence:

  • the small mouse eats the big cat Therefore, a semantic is necessary to correctly describe the meaning of an eat activity.

One production rule listing method is called the Backus–Naur form (BNF).{{cite book | last = Rosen | first = Kenneth H. | title = Discrete Mathematics and Its Applications | publisher = McGraw-Hill, Inc. | year = 1991 | page = 623 | isbn = 978-0-07-053744-6 | url = https://archive.org/details/discretemathemat00rose/page/623}} BNF describes the syntax of a language and itself has a syntax. This recursive definition is an example of a metalanguage. The syntax of BNF includes:

  • ::= which translates to is made up of a[n] when a non-terminal is to its right. It translates to is when a terminal is to its right.
  • | which translates to or.
  • `` which surround non-terminals.

Using BNF, a subset of the English language can have this production rule listing: ::code[lang=bnf] ::= ::=

::=

::= the ::= big | small ::= cat | mouse ::= eats ::

Using BNF, a signed-integer has the production rule listing:{{cite book | last = Rosen | first = Kenneth H. | title = Discrete Mathematics and Its Applications | publisher = McGraw-Hill, Inc. | year = 1991 | page = 624 | isbn = 978-0-07-053744-6 | url = https://archive.org/details/discretemathemat00rose/page/624}} ::code[lang=bnf] ::= ::= + | - ::= | ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ::

Notice the recursive production rule: ::code[lang=bnf] ::= | ::

This allows for an infinite number of possibilities. Therefore, a semantic is necessary to describe a limitation of the number of digits.

Notice the leading zero possibility in the production rules: ::code[lang=bnf] ::= | ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ::

Therefore, a semantic is necessary to describe that leading zeros need to be ignored.

Two formal methods are available to describe semantics. They are denotational semantics and axiomatic semantics.{{cite book | last = Wilson | first = Leslie B. | title = Comparative Programming Languages, Third Edition | publisher = Addison-Wesley | year = 2001 | page = 297 | isbn = 0-201-71012-9

Software engineering and computer programming

::figure[src="https://upload.wikimedia.org/wikipedia/commons/8/8c/Two_women_operating_ENIAC_(full_resolution).jpg" caption="Betty Jennings]] and [[Fran Bilas]] programmed the [[ENIAC]] by moving cables and setting switches."] ::

Software engineering is a variety of techniques to produce quality computer programs.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = Preface | isbn = 0-256-08515-3 | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 507 | isbn = 0-619-06489-7

Performance objectives

The systems analyst has the objective to deliver the right information to the right person at the right time.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 513 | isbn = 0-619-06489-7

  1. The quality of the output. Is the output useful for decision-making?
  2. The accuracy of the output. Does it reflect the true situation?
  3. The format of the output. Is the output easily understood?
  4. The speed of the output. Time-sensitive information is important when communicating with the customer in real time.

Cost objectives

Achieving performance objectives should be balanced with all of the costs, including:{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 514 | isbn = 0-619-06489-7

  1. Development costs.
  2. Uniqueness costs. A reusable system may be expensive. However, it might be preferred over a limited-use system.
  3. Hardware costs.
  4. Operating costs.

Applying a systems development process will mitigate the axiom: the later in the process an error is detected, the more expensive it is to correct.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 516 | isbn = 0-619-06489-7

Waterfall model

The waterfall model is an implementation of a systems development process.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 8 | isbn = 0-256-08515-3 | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 517 | isbn = 0-619-06489-7

  1. The investigation phase is to understand the underlying problem.
  2. The analysis phase is to understand the possible solutions.
  3. The design phase is to plan the best solution.
  4. The implementation phase is to program the best solution.
  5. The maintenance phase lasts throughout the life of the system. Changes to the system after it is deployed may be necessary.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 345 | isbn = 0-256-08515-3

Computer programmer

A computer programmer is a specialist responsible for writing or modifying the source code to implement the detailed plan. A programming team is likely to be needed because most systems are too large to be completed by a single programmer.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 319 | isbn = 0-256-08515-3

Computer programmers may be programming in the small: programming within a single module.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 331 | isbn = 0-256-08515-3

Program modules

Modular programming is a technique to refine imperative language programs. Refined programs may reduce the software size, separate responsibilities, and thereby mitigate software aging. A program module is a sequence of statements that are bounded within a block and together identified by a name.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 216 | isbn = 0-256-08515-3 | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 219 | isbn = 0-256-08515-3

  • The function of a module is what it does.
  • The context of a module are the elements being performed upon.
  • The logic of a module is how it performs the function.

The module's name should be derived first by its function, then by its context. Its logic should not be part of the name. For example, function compute_square_root( x ) or function compute_square_root_integer( i : integer ) are appropriate module names. However, function compute_square_root_by_division( x ) is not.

The degree of interaction within a module is its level of cohesion. Cohesion is a judgment of the relationship between a module's name and its function. The degree of interaction between modules is the level of coupling.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 226 | isbn = 0-256-08515-3

Cohesion

The levels of cohesion from worst to best are:{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 220 | isbn = 0-256-08515-3

  • Coincidental Cohesion: A module has coincidental cohesion if it performs multiple functions, and the functions are completely unrelated. For example, function read_sales_record_print_next_line_convert_to_float(). Coincidental cohesion occurs in practice if management enforces silly rules. For example, "Every module will have between 35 and 50 executable statements."
  • Logical Cohesion: A module has logical cohesion if it has available a series of functions, but only one of them is executed. For example, function perform_arithmetic( perform_addition, a, b ).
  • Temporal Cohesion: A module has temporal cohesion if it performs functions related to time. One example, function initialize_variables_and_open_files(). Another example, stage_one(), stage_two(), ...
  • Procedural Cohesion: A module has procedural cohesion if it performs multiple loosely related functions. For example, function read_part_number_update_employee_record().
  • Communicational Cohesion: A module has communicational cohesion if it performs multiple closely related functions. For example, function read_part_number_update_sales_record().
  • Informational Cohesion: A module has informational cohesion if it performs multiple functions, but each function has its own entry and exit points. Moreover, the functions share the same data structure. Object-oriented classes work at this level.
  • Functional Cohesion: a module has functional cohesion if it achieves a single goal working only on local variables. Moreover, it may be reusable in other contexts.

Coupling

The levels of coupling from worst to best are:

  • Content Coupling: A module has content coupling if it modifies a local variable of another function. COBOL used to do this with the alter verb.
  • Common Coupling: A module has common coupling if it modifies a global variable.
  • Control Coupling: A module has control coupling if another module can modify its control flow. For example, perform_arithmetic( perform_addition, a, b ). Instead, control should be on the makeup of the returned object.
  • Stamp Coupling: A module has stamp coupling if an element of a data structure passed as a parameter is modified. Object-oriented classes work at this level.
    • Data Coupling*: A module has data coupling if all of its input parameters are needed and none of them are modified. Moreover, the result of the function is returned as a single object.

Data flow analysis

::figure[src="https://upload.wikimedia.org/wikipedia/commons/5/58/Sandwich_data_flow_diagram.pdf" caption="A sample function-level data-flow diagram"] ::

Data flow analysis is a design method used to achieve modules of functional cohesion and data coupling.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 258 | isbn = 0-256-08515-3

The diagram also has arrows connecting modules to each other. Arrows pointing into modules represent a set of inputs. Each module should have only one arrow pointing out from it to represent its single output object. (Optionally, an additional exception arrow points out.) A daisy chain of ovals will convey an entire algorithm. The input modules should start the diagram. The input modules should connect to the transform modules. The transform modules should connect to the output modules.{{cite book | last = Schach | first = Stephen R. | title = Software Engineering | publisher = Aksen Associates Incorporated Publishers | year = 1990 | page = 259 | isbn = 0-256-08515-3

Functional categories

::figure[src="https://upload.wikimedia.org/wikipedia/commons/8/87/Operating_system_placement_(software).svg" caption="hardware]]."] ::

Computer programs may be categorized along functional lines. The main functional categories are application software and system software. System software includes the operating system, which couples computer hardware with application software. The purpose of the operating system is to provide an environment where application software executes in a convenient and efficient manner.{{cite book | last = Silberschatz | first = Abraham | title = Operating System Concepts, Fourth Edition | publisher = Addison-Wesley | year = 1994 | page = 1 | isbn = 978-0-201-50480-4

Application software

Main article: Application software

Application software is the key to unlocking the potential of the computer system.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 147 | isbn = 0-619-06489-7 | quote = The key to unlocking the potential of any computer system is application software.

Enterprise applications may be developed in-house as a one-of-a-kind proprietary software.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 147 | isbn = 0-619-06489-7 | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 147 | isbn = 0-619-06489-7 | quote = [A] third-party software firm, often called a value-added software vendor, may develop or modify a software program to meet the needs of a particular industry or company.

The potential advantages of in-house software are features and reports may be developed exactly to specification.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 148 | isbn = 0-619-06489-7 | quote = Heading: Proprietary Software; Subheading: Advantages; Quote: You can get exactly what you need in terms of features, reports, and so on. | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 148 | isbn = 0-619-06489-7 | quote = Heading: Proprietary Software; Subheading: Advantages; Quote: Being involved in the development offers a further level of control over the results. | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 147 | isbn = 0-619-06489-7 | quote = Heading: Proprietary Software; Subheading: Advantages; Quote: There is more flexibility in making modifications that may be required to counteract a new initiative by one of your competitors or to meet new supplier and/or customer requirements.

The potential advantages of off-the-shelf software are upfront costs are identifiable, the basic needs should be fulfilled, and its performance and reliability have a track record. The potential disadvantages of off-the-shelf software are it may have unnecessary features that confuse end users, it may lack features the enterprise needs, and the data flow may not match the enterprise's work processes.

Application service provider

One approach to economically obtaining a customized enterprise application is through an application service provider.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 149 | isbn = 0-619-06489-7

Operating system

::figure[src="https://upload.wikimedia.org/wikipedia/commons/2/25/Concepts-_Program_vs._Process_vs._Thread.jpg" caption="Context Switching]]"] ::

An operating system is the low-level software that supports a computer's basic functions, such as scheduling processes and controlling peripherals.

In the 1950s, the programmer, who was also the operator, would write a program and run it. After the program finished executing, the output may have been printed, or it may have been punched onto paper tape or cards for later processing. More often than not the program did not work. The programmer then looked at the console lights and fiddled with the console switches. If less fortunate, a memory printout was made for further study. In the 1960s, programmers reduced the amount of wasted time by automating the operator's job. A program called an operating system was kept in the computer at all times.{{cite book |url=https://archive.org/details/structuredcomput00tane/page/11 |title=Structured Computer Organization, Third Edition |last=Tanenbaum |first=Andrew S. |publisher=Prentice Hall |year=1990 |isbn=978-0-13-854662-5 |page=11}}

The term operating system may refer to two levels of software.{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=21}} The operating system may refer to the kernel program that manages the processes, memory, and devices. More broadly, the operating system may refer to the entire package of the central software. The package includes a kernel program, command-line interpreter, graphical user interface, utility programs, and editor.

Kernel Program

::figure[src="https://upload.wikimedia.org/wikipedia/commons/8/8f/Kernel_Layout.svg" caption="A kernel connects the application software to the hardware of a computer."] ::

The kernel's main purpose is to manage the limited resources of a computer:

  • The kernel program should perform process scheduling,{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=22}} which is also known as a context switch. The kernel creates a process control block when a computer program is selected for execution. However, an executing program gets exclusive access to the central processing unit only for a time slice. To provide each user with the appearance of continuous access, the kernel quickly preempts each process control block to execute another one. The goal for system developers is to minimize dispatch latency. ::figure[src="https://upload.wikimedia.org/wikipedia/commons/6/6e/Virtual_memory.svg" caption="Physical memory is scattered around RAM and the hard disk. Virtual memory is one continuous block."] ::

  • The kernel program should perform memory management. :* When the kernel initially loads an executable into memory, it divides the address space logically into regions.{{cite book | last = Bach | first = Maurice J. | title = The Design of the UNIX Operating System | publisher = Prentice-Hall, Inc. | year = 1986 | page = 152 | isbn = 0-13-201799-7 :The program pregion stores machine instructions. Since machine instructions do not change, the program pregion may be shared by many processes of the same executable. : To save time and memory, the kernel may load only blocks of execution instructions from the disk drive, not the entire execution file completely. :The kernel is responsible for translating virtual addresses into physical addresses. The kernel may request data from the memory controller and, instead, receive a page fault.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 443 | isbn = 978-0-13-291652-3 | last = Lacamera | first = Daniele | title = Embedded Systems Architecture | publisher = Packt | year = 2018 | page = 8 | isbn = 978-1-78883-250-2 : The kernel allocates memory from the heap upon request by a process. When the process is finished with the memory, the process may request for it to be freed. If the process exits without requesting all allocated memory to be freed, then the kernel performs garbage collection to free the memory. :* The kernel also ensures that a process only accesses its own memory, and not that of the kernel or other processes.

  • The kernel program should perform file system management. The kernel has instructions to create, retrieve, update, and delete files.

  • The kernel program should perform device management. The kernel provides programs to standardize and simplify the interface to the mouse, keyboard, disk drives, printers, and other devices. Moreover, the kernel should arbitrate access to a device if two processes request it at the same time.

  • The kernel program should perform network management.{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=23}} The kernel transmits and receives packets on behalf of processes. One key service is to find an efficient route to the target system.

  • The kernel program should provide system level functions for programmers to use.{{cite book |title=The Unix Programming Environment |last=Kernighan |first=Brian W. |publisher=Prentice Hall |year=1984 |isbn=0-13-937699-2 |page=201}}

    • Programmers access files through a relatively simple interface that in turn executes a relatively complicated low-level I/O interface. The low-level interface includes file creation, file descriptors, file seeking, physical reading, and physical writing.
    • Programmers create processes through a relatively simple interface that in turn executes a relatively complicated low-level interface.
    • Programmers perform date/time arithmetic through a relatively simple interface that in turn executes a relatively complicated low-level time interface.{{cite book |title=The Linux Programming Interface |last=Kerrisk |first=Michael |publisher=No Starch Press |year=2010 |isbn=978-1-59327-220-3 |page=187}}
  • The kernel program should provide a communication channel between executing processes.{{cite book |title=Unix System Programming |last=Haviland |first=Keith |publisher=Addison-Wesley Publishing Company |year=1987 |isbn=0-201-12919-1 |page=121}} For a large software system, it may be desirable to engineer the system into smaller processes. Processes may communicate with one another by sending and receiving signals.

Originally, operating systems were programmed in assembly; however, modern operating systems are typically written in higher-level languages like C, Objective-C, and Swift.

Utility program

A utility is a program that aids system administration and software execution. An operating system typically provides utilities to check hardware such as storage, memory, speakers, and printers.{{cite book | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 145 | isbn = 0-619-06489-7 | last = Stair | first = Ralph M. | title = Principles of Information Systems, Sixth Edition | publisher = Thomson | year = 2003 | page = 146 | isbn = 0-619-06489-7

Microcode program

Main article: Microcode

::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/9f/Not-gate-en.svg" caption="NOT gate"] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/e6/NAND_ANSI_Labelled.svg" caption="NAND gate"] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/c/c6/NOR_ANSI_Labelled.svg" caption="NOR gate"] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/b/b9/AND_ANSI_Labelled.svg" caption="AND gate"] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/1/16/OR_ANSI_Labelled.svg" caption="OR gate"] ::

A microcode program is the bottom-level interpreter{{efn|The bottom-level interpreter is technically called the Level 1 layer. The Level 0 layer is the digital logic layer. Three middle layers exist, and the Level 5 layer is the Problem-oriented language layer.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 5 | isbn = 978-0-13-291652-3 | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 6 | isbn = 978-0-13-291652-3 (Advances in hardware have migrated these operations to hardware execution circuits.) Microcode instructions allow the programmer to more easily implement the digital logic level{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 243 | isbn = 978-0-13-291652-3 | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 147 | isbn = 978-0-13-291652-3

A logic gate is a tiny transistor that can return one of two signals: on or off.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 148 | isbn = 978-0-13-291652-3

  • Having one transistor forms the NOT gate.
  • Connecting two transistors in series forms the NAND gate.
  • Connecting two transistors in parallel forms the NOR gate.
  • Connecting a NOT gate to a NAND gate forms the AND gate.
  • Connecting a NOT gate to a NOR gate forms the OR gate.

These five gates form the building blocks of binary algebra—the digital logic functions of the computer.

Microcode instructions are mnemonics programmers may use to execute digital logic functions instead of forming them in binary algebra. They are stored in a central processing unit's (CPU) control store.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 253 | isbn = 978-0-13-291652-3 These hardware-level instructions move data throughout the data path.

The micro-instruction cycle begins when the microsequencer uses its microprogram counter to fetch the next machine instruction from random-access memory.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 255 | isbn = 978-0-13-291652-3 | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 161 | isbn = 978-0-13-291652-3 The final step is to execute the instruction using the hardware module's set of gates.

::figure[src="https://upload.wikimedia.org/wikipedia/commons/f/fb/ALU_block.svg" caption="A symbolic representation of an ALU"] ::

Instructions to perform arithmetic are passed through an arithmetic logic unit (ALU).{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 166 | isbn = 978-0-13-291652-3

Microcode instructions move data between the CPU and the memory controller. Memory controller microcode instructions manipulate two registers. The memory address register is used to access each memory cell's address. The memory data register is used to set and read each cell's contents.{{cite book | last = Tanenbaum | first = Andrew S. | title = Structured Computer Organization, Sixth Edition | publisher = Pearson | year = 2013 | page = 249 | isbn = 978-0-13-291652-3

Notes

References

References

  1. Huskey, Harry D.. (2003-01-01). "EDVAC". John Wiley and Sons Ltd..
  2. (1982). "The EDSAC". Springer.
  3. Kowalski, R., Dávila, J., Sartor, G. and Calejo, M., 2023. Logical English for law and education. In Prolog: The Next 50 Years (pp. 287–299). Cham: Springer Nature Switzerland.

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

computer-programmingsoftware