# Expression-oriented programming language

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Expression-oriented_programming_language
> Markdown URL: https://mediated.wiki/source/Expression-oriented_programming_language.md
> Source: https://en.wikipedia.org/wiki/Expression-oriented_programming_language
> Source revision: 1343936656
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Notability|date=July 2022}}

An '''expression-oriented programming language''' is a [programming language](/source/programming_language) in which every (or nearly every) construction is an [expression](/source/Expression_(computer_science)) and thus yields a value.<ref>{{Cite web |title=Glossary - The Rust Programming Language |url=https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/glossary.html#expression-oriented-language |access-date=2022-07-06 |website=web.mit.edu}}</ref> The typical exceptions are [macro](/source/Macro_(computer_science)) definitions, [preprocessor](/source/preprocessor) commands, and [declarations](/source/Declaration_(computer_programming)), which expression-oriented languages often treat as [statements](/source/Statement_(computer_science)).

[Lisp](/source/Lisp_(programming_language))<ref name=":0">{{Cite journal |last1=Syme |first1=Don |date=2020-06-14 |title=The early history of F# |journal=Proceedings of the ACM on Programming Languages |language=en |volume=4 |issue=HOPL |pages=1–58 |doi=10.1145/3386325 |issn=2475-1421 |doi-access=free}}</ref> and [ALGOL 68](/source/ALGOL_68) are expression-oriented languages. [Pascal](/source/Pascal_(programming_language)) is not an expression-oriented language.

All [functional programming](/source/functional_programming) languages are expression-oriented.

==Criticism and prevention==
{{Synthesis|date=July 2022}}
{{See also|Assignment (computer science)#Assignment versus equality|Relational operator#Confusion with assignment operators}}
Critics, including language designers,<ref>[https://www.oracle.com/java/technologies/javase/codeconventions-programmingpractices.html#547 Java Code Conventions "10.4 Variable Assignments"]</ref>{{Failed verification|date=July 2022}} blame expression-orientation for an entire class of [programming mistakes](/source/software_bug) wherein a programmer accidentally codes an [assignment](/source/Assignment_(computer_science)) ''expression'', which replaces a variable with an expression rather than testing it for [equality](/source/Equality_(relational_operator)) with that expression.

Some languages such as [Ada](/source/Ada_(programming_language)) and [Java](/source/Java_(programming_language)) prevent this type of mistake by restricting [control expressions](/source/Conditional_(computer_programming)) to those that evaluate strictly to the [boolean data type](/source/boolean_data_type).<ref>[https://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.9 The Java Language Specification, Java SE 8 Edition "14.9 The if Statement"]</ref><ref>[https://www.adaic.org/learn/materials/intro/part4/ Introducing Ada]</ref>

Some languages such as [Python](/source/Python_(programming_language)) implement assignment as a statement rather than an expression, thus prohibiting assignment from nesting inside any other statement or expression.<ref>[https://docs.python.org/3/reference/simple_stmts.html#assignment The Python Language Reference "6.2. Assignment statements"]</ref> (Until version 3.8 added 'assignment expressions', with a different [syntax](/source/Syntax_(programming_languages)).<ref>[https://www.python.org/dev/peps/pep-0572/ "PEP 572: Assignment Expressions"]</ref>)

In some expression-oriented languages, expressions that merely cause [side effects](/source/Side_effect_(computer_science)) return [void type](/source/void_type)s.

==Examples==
{{More citations needed|date=July 2022}}
{{Expand section|date=February 2018}}
*[ALGOL 68](/source/ALGOL_68)
*[BLISS](/source/BLISS)
*[Icon](/source/Icon_(programming_language))
*[Lisp](/source/Lisp_(programming_language))<ref name=":0"/>
*[ML](/source/ML_(programming_language))
*[Perl](/source/Perl)
*[Rebol](/source/Rebol)
*[Ruby](/source/Ruby_(programming_language))
*[Elixir](/source/Elixir_(programming_language))
*[Erlang](/source/Erlang_(programming_language))
*[Haskell](/source/Haskell)
*[Rust](/source/Rust_(programming_language))<ref>{{Cite web |title=Functions - The Rust Programming Language |url=https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/functions.html#expressions-vs-statements |access-date=2022-07-06 |website=web.mit.edu}}</ref>
*[Scala](/source/Scala_(programming_language))
*[Smalltalk](/source/Smalltalk)
*[Kotlin](/source/Kotlin)
*[OCaml](/source/OCaml)<ref>{{Cite web |title=COS 326: Functional Programming |url=https://www.cs.princeton.edu/~dpw/courses/cos326-12/notes/type-check.php |access-date=2022-07-06 |website=www.cs.princeton.edu}}</ref>
<!-- *[PHP](/source/PHP)<ref>[https://www.php.net/manual/en/language.expressions.php PHP Manual "Expressions"]</ref> -- See talks. PHP manual saying something does not ensure its truth. =( -->

==See also==
*[Command–query separation](/source/Command%E2%80%93query_separation)
*[Functional programming](/source/Functional_programming)

==References==
{{Reflist}}

{{Programming paradigms navbox}}

Category:Programming language classification

---
Adapted from the Wikipedia article [Expression-oriented programming language](https://en.wikipedia.org/wiki/Expression-oriented_programming_language) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Expression-oriented_programming_language?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
