Function

FUNGK-shun /ˈfʌŋkʃən/
nounB2GRESAT
technicalformal

A relationship or expression involving one or more variables. (In programming) A named section of a program that performs a specific task and can be called (executed) by other parts of the program.

In programming, functions (also called methods, subroutines, or procedures in different languages) are crucial for organizing code, promoting reusability, and breaking down complex problems into smaller, manageable parts.

The story behind the word. The word 'function' comes from the Latin 'functio,' meaning 'performance, execution.' This in turn derives from 'fungi,' meaning 'to perform, execute, discharge.' It entered English in the 16th century, initially meaning 'the performance of an office or duty.' In mathematics, it gained its specific meaning in the 17th century. For computing, the idea of a self-contained block of code that performs a specific task and can be 'called' or 'executed' perfectly aligned with this sense of performing a duty.

Word relationships

  • method: Often used interchangeably with 'function,' especially in object-oriented programming, where methods are functions associated with objects.
  • routine: A sequence of instructions for a computer to perform a particular task, often a synonym for 'function' or 'subroutine.'
  • procedure: Similar to a function but may not necessarily return a value.

Commonly confused with

  • Statement: A statement is a single instruction; a function is a named block of multiple statements designed to be reusable.

Word family

  • functional (adjective): Having a special purpose or task; working or operating.
  • functionality (noun): The range of functions that a computer or other electronic system can perform.

Collocations

  • define a function
  • call a function
  • mathematical function
  • built-in function
  • main function

Idioms & expressions

  • function as (serve the purpose of)

Example sentences

  • "The 'calculate_total' function takes two numbers as input and returns their sum." In a programming context.
  • "This new software update adds a useful function for exporting data to a spreadsheet." Referring to a specific capability.
  • "The graph shows how the dependent variable is a function of the independent variable." In a mathematical context.

Memory hook

A 'FUNCTION' helps your code 'FUN'ction properly by breaking it into smaller, manageable tasks. Code's Fun Task

When not to use

While 'function' can mean the purpose or role of something, in a programming context, it specifically refers to a block of reusable code. Avoid using it loosely when a simpler term like 'task' or 'purpose' would suffice.

Fun facts

  • The concept of functions is a cornerstone of structured programming, allowing for modular and maintainable code.
  • Many programming languages come with a vast library of 'built-in functions' for common tasks like mathematical calculations or string manipulation.

Related words

Algorithm, Code, Variable, Module

LangBlitz
Take your vocabulary further with LangBlitz

Our English vocabulary app: FSRS spaced repetition, 5,000+ curated words across 119 topic groups, CEFR A1 to C2. Explore your mastery with the beautiful Vocabulary World feature.