Definition - 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.

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.

This definition was written in the context of Computer Science
Share this:

Connect with us

Email Newsletter

Join thousands of others with our weekly newsletter

The 4th Era of IT Infrastructure: Superconverged Systems
The 4th Era of IT Infrastructure: Superconverged Systems:
Learn the benefits and limitations of the 3 generations of IT infrastructure – siloed, converged and hyperconverged – and discover how the 4th...
Approaches and Benefits of Network Virtualization
Approaches and Benefits of Network Virtualization:
Businesses today aspire to achieve a software-defined datacenter (SDDC) to enhance business agility and reduce operational complexity. However, the...
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.