Expression

Why Trust Techopedia

What Does Expression Mean?

An expression is a particular concept in computer science in which a number of variables or constants, and operators and functions, are put together in a single statement that is acted on by a particular programming language.

Advertisements

Techopedia Explains Expression

In computer science, expressions are written by developers, interpreted by computers and ‘evaluated.’

The evaluation produces a return or result. Simple mathematical equations such as 2 + 2 are expressions in code. They’re typically called arithmetic expressions.

Other kinds of numerical or arithmetic expressions may use variables, so that they look like algebra equations. In addition, various data types such as characters, strings, integers, floating point numbers and others can be acted on in expressions as constants or variables.

Operators and functions determine how the computer will act on these objects in a given expression. Different types of expressions are categorized according to how they work and what they ‘evaluate to.’ Boolean expressions evaluate to either a true or false value, while numerical expressions evaluate to numbers.

String expressions evaluate to character strings, where text and character strings are changed by functions to produce a different result.

For instance, adding an exclamation point to the display or printing of the phrase ‘hello world’ would be an example of a string expression that uses functions to add ASCII characters, rather than changing numerical values or creating different code conditions.

In the above example, different programs would treat this differently: Some of the more primitive ones may use syntax like print hello world; print ! while others might use something like this:

String a = hello world

String b = !

Print string a + string b

Like other kinds of fundamentals, expressions rely on the specific syntax of a programming language. In terms of structure, experts point out that an expression inherently needs at least one ‘operand’ or value that is acted on, and must have one or more operators.

Beyond this, it’s important for programmers to understand what’s ‘legal’ or ‘illegal’ in program syntax. Inputting incorrect or illegal syntax will result in compiling errors, and developers will have to make expressions and code modules conform to proper syntax in order to run them.

Advertisements

Related Terms

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.