Function (computer programming): Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Added chapter-url. Removed or converted URL. | Use this bot. Report bugs. | Suggested by Dominic3203 | Category:Source code | #UCB_Category 25/70
Rempy1 (talk | contribs)
m Added links to relevant articles for important terms.
Line 14:
Callable units provide a powerful programming tool.<ref name="knuth1">{{cite book |title= The Art of Computer Programming, Volume I: Fundamental Algorithms |author= Donald E. Knuth |year= 1997 |author-link= Donald Knuth |publisher= Addison-Wesley |isbn=0-201-89683-4}}</ref> The primary purpose is to allow for the decomposition of a large and/or complicated problem into chunks that have relatively low [[cognitive load]] and to assign the chunks meaningful names (unless they are anonymous). Judicious application can reduce the cost of developing and maintaining software, while increasing its quality and reliability.<ref name="structprog">{{cite book |author= O.-J. Dahl |author2=E. W. Dijkstra |author3=C. A. R. Hoare |title= Structured Programming |publisher= Academic Press |year= 1972 |isbn= 0-12-200550-3}}</ref>
 
Callable units are present at multiple levels of [[abstraction]] in the programming environment. For example, a [[programmer]] may write a function in [[source code]] that is compiled to [[machine code]] that implements similar [[semantics]]. There is a callable unit in the source code and an associated one in the machine code, but they are different kinds of callable units {{endash}} with different implications and features.
 
==Terminology==
 
Some [[Programming language|programming languages]], such as [[COBOL]] and [[BASIC]], make a distinction between functions that return a value (typically called "functions") and those that do not (typically called "subprogram", "subroutine", or "procedure"). Other programming languages, such as [[C (programming language)|C]], [[C++]], and [[Rust (programming language)|Rust]], only use the term "function" irrespective of whether they return a value or not. Some [[Object-oriented programming|object-oriented]] languages, such as [[Java (programming language)|Java]] and [[C Sharp (programming language)|C#]], refer to functions inside [[Class (computer programming)|classes]] as "[[Method (computer programming)|method]]s".
 
==History==