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.
Do you work in the tech industry? Help us learn more about why
the gender gap still exists in tech by taking this quick survey!
Survey respondents will also be entered to win a $100 Amazon Gift Card!