Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects simply to a non-technical, business audience. Over…
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.
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.
Techopedia’s editorial policy is centered on delivering thoroughly researched, accurate, and unbiased content. We uphold strict sourcing standards, and each page undergoes diligent review by our team of top technology experts and seasoned editors. This process ensures the integrity, relevance, and value of our content for our readers.
Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects 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 by 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 helping IT and business professionals learn to speak each other’s highly specialized languages.
What Is Hyperdimensional Computing? Hyperdimensional computing is a new approach to information processing that uses high-dimensional mathematical vectors to represent...
Margaret RouseTechnology Expert
What Does STEM Mean?STEM is an integrated, interdisciplinary, and student-centered approach to learning that encourages critical thinking, creativity, collaboration and...
What Does Distributed Cloud Mean?Distributed cloud is a business model that extends a public cloud provider’s infrastructure and services to...
Trending NewsLatest GuidesReviewsTerm of the Day