Expression-oriented programming language: Difference between revisions
Eliotmiranda (talk | contribs) →Examples: add Smalltalk, one of the two granddaddies, to the list |
Jerryobject (talk | contribs) m WP:LINKs update-standardize. |
||
Line 1: | Line 1: | ||
{{Notability|date=July 2022}} |
{{Notability|date=July 2022}} |
||
An '''expression-oriented programming language''' is a [[programming language]] in which every (or nearly every) construction is an [[ |
An '''expression-oriented programming language''' is a [[programming language]] in which every (or nearly every) construction is an [[Expression (computer science)|expression]] 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 (computer science)|macro]] definitions, [[preprocessor]] commands, and [[Declaration (computer programming)|declarations]], which expression-oriented languages often treat as [[Statement (computer science)|statements]]. |
||
[[Lisp (programming language)|Lisp]]<ref name=":0">{{Cite journal | |
[[Lisp (programming language)|Lisp]]<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]] are expression-oriented languages. [[Pascal (programming language)|Pascal]] is not an expression-oriented language. |
||
All [[functional programming |
All [[functional programming]] languages are expression-oriented.<ref>{{Cite web |author1=Knoldus |date=2018-02-08 |title=Expression Oriented Programming |url=https://medium.com/knoldus/expression-oriented-programming-d88f621fd3a4 |access-date=2023-08-07 |website=Knoldus – Technical Insights |language=en}}</ref> |
||
==Criticism and prevention== |
==Criticism and prevention== |
||
{{Synthesis|date=July 2022}} |
{{Synthesis|date=July 2022}} |
||
{{See also|Assignment (computer science)#Assignment versus equality|Relational operator#Confusion with assignment operators}} |
{{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 [[software bug|programming mistakes]] wherein a programmer accidentally codes an [[ |
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 [[software bug|programming mistakes]] wherein a programmer accidentally codes an [[Assignment (computer science)|assignment]] ''expression'', which replaces a variable with an expression rather than testing it for [[Equality (relational operator)|equality]] with that expression. |
||
The designers of [[Ada (programming language)|Ada]] and [[Java (programming language)|Java]] prevent this type of mistake by restricting [[ |
The designers of [[Ada (programming language)|Ada]] and [[Java (programming language)|Java]] prevent this type of mistake by restricting [[Conditional (computer programming)|control expressions]] to those that evaluate strictly to the [[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> |
||
The designers of [[Python (programming language)|Python]] implemented 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.<ref>[https://www.python.org/dev/peps/pep-0572/ "PEP 572: Assignment Expressions"]</ref>) |
The designers of [[Python (programming language)|Python]] implemented 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.<ref>[https://www.python.org/dev/peps/pep-0572/ "PEP 572: Assignment Expressions"]</ref>) |
||
Line 31: | Line 31: | ||
*[[Elixir (programming language)|Elixir]] |
*[[Elixir (programming language)|Elixir]] |
||
*[[Erlang (programming language)|Erlang]] |
*[[Erlang (programming language)|Erlang]] |
||
*[[ |
*[[Haskell]] |
||
*[[Rust (programming language)|Rust]]<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> |
*[[Rust (programming language)|Rust]]<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 (programming language)|Scala]] |
*[[Scala (programming language)|Scala]] |
||
*[[ |
*[[Smalltalk]] |
||
*[[Kotlin (programming language)|Kotlin]] |
*[[Kotlin (programming language)|Kotlin]] |
||
*[[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> |
*[[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> |
Latest revision as of 07:57, 4 February 2025
![]() | The topic of this article may not meet Wikipedia's general notability guideline. (July 2022) |
An expression-oriented programming language is a programming language in which every (or nearly every) construction is an expression and thus yields a value.[1] The typical exceptions are macro definitions, preprocessor commands, and declarations, which expression-oriented languages often treat as statements.
Lisp[2] and ALGOL 68 are expression-oriented languages. Pascal is not an expression-oriented language.
All functional programming languages are expression-oriented.[3]
Criticism and prevention
[edit]![]() | This article or section possibly contains original synthesis. Source material should verifiably mention and relate to the main topic. (July 2022) |
Critics, including language designers,[4][failed verification] blame expression-orientation for an entire class of programming mistakes wherein a programmer accidentally codes an assignment expression, which replaces a variable with an expression rather than testing it for equality with that expression.
The designers of Ada and Java prevent this type of mistake by restricting control expressions to those that evaluate strictly to the boolean data type.[5][6]
The designers of Python implemented assignment as a statement rather than an expression, thus prohibiting assignment from nesting inside any other statement or expression.[7] (Until version 3.8 added 'assignment expressions', with a different syntax.[8])
In some expression-oriented languages, expressions that merely cause side effects return void types.
Examples
[edit]This article needs additional citations for verification. (July 2022) |
![]() | This section needs expansion. You can help by adding to it. (February 2018) |
- ALGOL 68
- BLISS
- Icon
- Lisp[2]
- ML
- Perl
- Rebol
- Ruby
- Elixir
- Erlang
- Haskell
- Rust[9]
- Scala
- Smalltalk
- Kotlin
- OCaml[10]
See also
[edit]References
[edit]- ^ "Glossary - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
- ^ a b Syme, Don (2020-06-14). "The early history of F#". Proceedings of the ACM on Programming Languages. 4 (HOPL): 1–58. doi:10.1145/3386325. ISSN 2475-1421.
- ^ Knoldus (2018-02-08). "Expression Oriented Programming". Knoldus – Technical Insights. Retrieved 2023-08-07.
- ^ Java Code Conventions "10.4 Variable Assignments"
- ^ The Java Language Specification, Java SE 8 Edition "14.9 The if Statement"
- ^ Introducing Ada
- ^ The Python Language Reference "6.2. Assignment statements"
- ^ "PEP 572: Assignment Expressions"
- ^ "Functions - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
- ^ "COS 326: Functional Programming". www.cs.princeton.edu. Retrieved 2022-07-06.