Computer program: Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
Reverted 1 edit by 1.1.250.125 (talk): Using Wikipedia for advertising/promotion
 
(30 intermediate revisions by 17 users not shown)
Line 1:
{{Short description|Instructions a computer can execute}}
{{for|the TV program|The Computer Programme{{!}}''The Computer Programme''}}
[[File:JavaScript_code.png|thumb|[[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 owof an HTML document.]]
{{Program inicio interfaz execution}}
 
execution}}
A '''computer program'''{{en|"Program" is the only spelling of this word normally used in [[American English]], no matter which sense it is used in. Due to the heavy influence of American English in the [[High tech|high-tech industry]], it has also become accepted in [[English in the Commonwealth of Nations|Commonwealth English]] in terms of computer programming and related activities, but the spelling "programme" is still used in the latter in all other meanings.}} is a [[sequence]] or set{{efn|The [[Prolog]] language allows for a database of facts and rules to be entered in any order. However, a question about a database must be at the very end.}} of instructions in a [[programming language]] for a [[computer]] to [[Execution (computing)|execute]]. It is one component of [[software]], which also includes [[software documentation|documentation]] and other intangible components.<ref name="ISO 2020">{{cite internet Bluetooth wifi radio web
| title=ISO/IEC 2382:2015
| website=ISO
Line 13:
| 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
| urgenciasurl-status=live
}}</Redref>
 
A ''computer program'' in its [[agradablehuman-readable]] form is called [[source code]]. Source code needs another computer program to [[Execution (computing)|execute]] because computers can only execute their native [[machine instructions]]. Therefore, source code may be [[Translator (computing)|trasladadotranslated]] to machine instructions using a [[compiler]] written for the language. ([[Assembly language]] programs are translated using an [[Assembler (computing)|assembler ]].) The resulting file is called an [[executable]]. Alternatively, source code may execute within an [[interpreter (computing)|interpreter]] written for the language.<ref name="cpl_3rd-ch1-7_quoted">{{cite book
| last = Wilson nevevr
| first = Leslie B.t0
| title = Comparative Programming on línea Languages, Third Edition
| publisher = Addison-Wesley
| year = 2001
| page = 7
| quote = AunAn alternative to completocompiling a source program is to use an interpreter. An interpreter can directivadirectly execute a source program[601.]
| isbn = 0-201-71012-9
}}</ref>
 
If the executable is requested for execution, then the [[operating system]] [[Loader (computing)|loads]] it into [[Random-access memory|memory]] and starts a [[Process (computing)|process inicio]].<ref name="osc-ch4-p98">{{cite book
| last = Silberschatz
| first = Abraham
Line 38:
| last = Tanenbaum
| first = Andrew S.
| title = Structured Computer adjuntar Organization, Third Edition
| publisher = Prentice Hall
| year = 1990
Line 46:
}}</ref>
 
InfIf 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 (computer science)|statement]]. Running the source code is slower than running an [[executable]].<ref name="cpl_3rd-ch1-7">{{cite book internet
| last = Wilson
| first = Leslie B.
Line 54:
| page = 7
| isbn = 0-201-71012-9
}}</ref>{{Efronefn|An executable has each [[machine instruction]] ready for the [[CPU]].}} Moreover, the interpreter must be installed off line interneton the computer.
 
==Example computer program==
 
The [["Hello, World!" program]] is used to illustrate a language's basic [[Syntax (programming languages)|syntax]]. The syntax of the language [[Dartmouth BASIC|BASIC]] (1964) was intentionally limited to make the language easy to learn.<ref name="cpl_3rd-ch2-30_quote1">{{cite book
| last = Wilson
| first = Leslie B.
Line 205:
===ENIAC===
[[File:ENIAC-changing_a_tube.jpg|thumb|right|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 tube]]s to create the [[Electronic circuit|circuits]]. At its core, it was a series of [[Pascaline]]s wired together.<ref name="eniac-ch5-p102">{{cite book
| last = McCartney
| first = Scott
Line 316:
===Very Large Scale Integration===
[[Image:Diopsis.jpg|thumb|right|A VLSI integrated-circuit [[die (integrated circuit)|die]] ]]
A major milestone in software development was the invention of the [[Very Large Scale Integration]] (VLSI) circuit (1964).<ref name="digibarn_bp">{{cite web
| url=https://www.digibarn.com/stories/bill-pentz-story/index.html#story
| title=Bill Pentz — A bit of Background: the Post-War March to VLSI
| publisher=Digibarn Computer Museum
| date=August 2008
| access-date=January 31, 2022
| archive-date=March 21, 2022
| archive-url=https://web.archive.org/web/20220321183527/https://www.digibarn.com/stories/bill-pentz-story/index.html#story
| url-status=live
}}</ref> Following [[World War II]], tube-based technology was replaced with [[point-contact transistor]]s (1947) and [[bipolar junction transistor]]s (late 1950s) mounted on a [[circuit board]].<ref name="digibarn_bp"/> [[Invention of the integrated circuit|During the 1960s]], the [[aerospace]] industry replaced the circuit board with an [[integrated circuit chip]].<ref name="digibarn_bp"/>
 
[[Robert Noyce]], co-founder of [[Fairchild Semiconductor]] (1957) and [[Intel]] (1968), achieved a technological improvement to refine the [[Semiconductor device fabrication|production]] of [[field-effect transistor]]s (1963).<ref name="digital_age">{{cite book
Line 375 ⟶ 366:
}}</ref> The MOS transistor is the primary component in ''integrated circuit chips''.<ref name="digital_age"/>
 
Originally, [[integrated circuit]] chips had their function set during manufacturing. During the 1960s, controlling the electrical flow migrated to programming a [[Diode matrix|matrix]] of [[read-only memory]] (ROM). The matrix resembled a two-dimensional array of fuses.<ref name="digibarn_bp"/> The process to embed instructions onto the matrix was to burn out the unneeded connections.<ref name="digibarn_bp"/> There were so many connections, [[firmware]] programmers wrote a ''computer program'' on another chip to oversee the burning.<ref name="digibarn_bp"/> The technology became known as [[Programmable ROM]]. In 1971, Intel [[stored-program computer|installed the computer program onto the chip]] and named it the [[Intel 4004]] [[microprocessor]].<ref name="intel_4004">{{cite web
| url=https://spectrum.ieee.org/chip-hall-of-fame-intel-4004-microprocessor
| title=Chip Hall of Fame: Intel 4004 Microprocessor
Line 394 ⟶ 385:
| access-date=February 5, 2022
}}</ref>
 
===Sac State 8008===
[[File:Sacstate 8008.jpg|thumb|Artist's depiction of Sacramento State University's Intel 8008 microcomputer (1972)]]
The Intel 4004 (1971) was a 4-[[bit]] microprocessor designed to run the [[Busicom]] calculator. Five months after its release, Intel released the [[Intel 8008]], an 8-bit microprocessor. Bill Pentz led a team at [[Sacramento State]] to build the first [[microcomputer]] using the Intel 8008: the ''Sac State 8008'' (1972).<ref name="cnet">{{cite web
| url=https://www.cnet.com/news/inside-the-worlds-long-lost-first-microcomputer/
| title=Inside the world's long-lost first microcomputer
| publisher=c/net
| date=January 8, 2010
| access-date=January 31, 2022
| archive-date=February 1, 2022
| archive-url=https://web.archive.org/web/20220201023538/https://www.cnet.com/news/inside-the-worlds-long-lost-first-microcomputer/
| url-status=live
}}</ref> Its purpose was to store patient medical records. The computer supported a [[disk operating system]] to run a [[Memorex]], 3-[[megabyte]], [[hard disk drive]].<ref name="digibarn_bp"/> It had a color display and keyboard that was packaged in a single console. The disk operating system was programmed using [[IBM Basic Assembly Language and successors|IBM's Basic Assembly Language (BAL)]]. The medical records application was programmed using a [[BASIC]] interpreter.<ref name="digibarn_bp"/> However, the computer was an evolutionary dead-end because it was extremely expensive. Also, it was built at a public university lab for a specific purpose.<ref name="cnet"/> Nonetheless, the project contributed to the development of the [[Intel 8080]] (1974) [[instruction set]].<ref name="digibarn_bp"/>
 
===x86 series===
[[File:IBM_PC-IMG_7271_(transparent).png|thumb|right|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]].<ref name="infoworld_8-23-82">{{cite web
| url=https://books.google.com/books?id=VDAEAAAAMBAJ&pg=PA22
| title=Bill Gates, Microsoft and the IBM Personal Computer
Line 432 ⟶ 410:
==Programming paradigms and languages==
 
[[Programming language]] features exist to provide building blocks to be combined to express programming ideals.<ref name="stroustrup-ch1-10">{{cite book
| last = Stroustrup
| first = Bjarne
Line 508 ⟶ 486:
| isbn = 978-0-13-854662-5
| url = https://archive.org/details/structuredcomput00tane/page/17
}}</ref> Programming the EDSAC was in the first [[Programming language generations|generation of programming language]].<ref>{{Citation |last1=Wilkes |first1=M. V. |title=The EDSAC |date=1982 |work=The Origins of Digital Computers: Selected Papers |pages=417–421 |editor-last=Randell |editor-first=Brian |url=https://link.springer.com/chapter/10.1007/978-3-642-61812-3_34 |access-date=2025-04-25 |place=Berlin, Heidelberg |publisher=Springer |language=en |doi=10.1007/978-3-642-61812-3_34 |isbn=978-3-642-61812-3 |last2=Renwick |first2=W.|url-access=subscription }}</ref>
 
* The [[First-generation programming language|first generation of programming language]] is [[machine language]].<ref name="pis-ch4-p160">{{cite book
Line 518 ⟶ 496:
| page = 160
| isbn = 0-619-06489-7
}}</ref> ''Machine language'' requires the programmer to enter instructions using ''instruction numbers'' called [[machine code]]. For example, the ADD operation on the [[PDP-11 architecture|PDP-11]] has instruction number 24576.{{efn|Whereas this is a decimal number, PDP-11 code is always expressed as [[octal]].}}<ref name="sco-ch7-p399">{{cite book
| last = Tanenbaum
| first = Andrew S.
Line 529 ⟶ 507:
}}</ref>
 
* The [[Second-generation programming language|second generation of programming language]] is [[assembly language]].<ref name="pis-ch4-p160"/> ''Assembly language'' allows the programmer to use [[Assembly language#Mnemonics|mnemonic]] [[Instruction_set_architecture#Instructions|instructions]] instead of remembering instruction numbers. An [[Assembler (computing)|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.<ref name="sco-ch7-p399"/> The four basic arithmetic operations have assembly instructions like ADD, SUB, MUL, and DIV.<ref name="sco-ch7-p399"/> Computers also have instructions like DW (Define [[Word (computer architecture)|Word]]) to reserve [[Random-access memory|memory]] cells. Then the MOV instruction can copy [[integer]]s between [[Processor register|registers]] and memory.
 
:* The basic structure of an assembly language statement is a label, [[Operation (mathematics)|operation]], [[operand]], and comment.<ref name="sco-ch7-p400">{{cite book
Line 663 ⟶ 641:
| page = 19
| isbn = 0-201-71012-9
}}</ref> Emerging from a committee of European and American programming language experts, it used standard [[mathematical notation]] and had a readable, structured design. Algol was first to define its [[Syntax (programming languages)|syntax]] using the [[Backus–Naur form]].<ref name="cpl_3rd-ch2-19"/> This led to [[Syntax-directed translation|syntax-directed]] compilers. It added features like:
* [[Block (programming)|block structure]], where variables were local to their block.
* arrays with variable bounds.
Line 685 ⟶ 663:
 
====C====
[[C programming language]] (1973) got its name because the language [[BCPL]] was replaced with [[B (programming language)|B]], and [[AT&T Bell Labs]] called the next version "C". Its purpose was to write the [[UNIX]] [[operating system]].<ref name="cpl_3rd-ch2-37"/> C is a relatively small language, making it easy to write compilers. Its growth mirrored the hardware growth in the 1980s.<ref name="cpl_3rd-ch2-37"/> Its growth also was because it has the facilities of [[assembly language]], but it uses a [[High-level programming language|high-level syntax]]. It added advanced features like:
* [[inline assembler]].
* arithmetic on pointers.
Line 1,281 ⟶ 1,259:
</syntaxhighlight>
 
Here is a comprehensive example:<ref name="Logical English">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-299287–299). Cham: Springer Nature Switzerland.</ref>
 
1) All dragons billow fire, or equivalently, a thing billows fire if the thing is a dragon:
Line 1,940 ⟶ 1,918:
The levels of coupling from worst to best are:<ref name="se-ch8-226"/>
 
* ''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, <code>perform_arithmetic( perform_addition, a, b )</code>. Instead, control should be on the makeup of the returned object.
Line 2,089 ⟶ 2,067:
|year=2010
|isbn=978-1-59327-220-3
|page=22}}</ref> which is also known as a [[context switch]]. The kernel creates a [[process control block]] when a ''computer program'' is [[Loader (computing)|selected for execution]]. However, an executing program gets exclusive access to the [[central processing unit]] only for a [[Preemption Preemption_(computing)#time sliceTime_slice|time slice]]. To provide each user with the [[Time-sharing|appearance of continuous access]], the kernel quickly [[Preemption (computing)|preempts]] each process control block to execute another one. The goal for [[Systems programming|system developers]] is to minimize [[dispatch latency]].
[[File:Virtual memory.svg|thumb|250px|Physical memory is scattered around RAM and the hard disk. Virtual memory is one continuous block.]]
* The kernel program should perform [[memory management]].
Line 2,282 ⟶ 2,260:
| year = 2013
| page = 249
| isbn = 978-0-13-291652-3
}}</ref>
 
Microcode instructions move data between the CPU and the many [[computer buses]]. The [[Disk controller|disk controller bus]] writes to and reads from [[hard disk drive]]s. Data is also moved between the CPU and other functional units via the [[PCI Express|peripheral component interconnect express bus.]]<ref name="sco6th-ch2-p111">{{cite book
| last = Tanenbaum
| first = Andrew S.
| title = Structured Computer Organization, Sixth Edition
| publisher = Pearson
| year = 2013
| page = 111
| isbn = 978-0-13-291652-3
}}</ref>