Flix (programming language): Difference between revisions

Content deleted Content added
m SL93 moved page Draft:Flix (programming language) to Flix (programming language): Publishing accepted Articles for creation submission (AFCH 0.9.1)
Cleaning up accepted Articles for creation submission (AFCH 0.9.1)
Line 1:
{{AFC submission|||ts=20201001203745|u=JorKadeen|ns=118}}
{{about|the Flix programming language|other uses|Flix (disambiguation)}}
{{Infobox programming language
Line 7 ⟶ 6:
| typing = [[Hindley-Milner|inferred]], [[Static typing|static]], [[Strong and weak typing|strong]], [[structural typing|structural]]
| platform = [[Java virtual machine|JVM]]
| license = [[Apache License 2.0]].<ref name="license-github">{{cite web |url=https://github.com/flix/flix/blob/master/LICENSE.md|title=Apache License 2.0|via=[[GitHub]]}}</ref>
| website = {{URL|https://flix.dev/}}
| influenced_by = [[F_Sharp_(programming_language)|F#]], [[Go_(programming_language)|Go]], [[Haskell_(programming_language)|Haskell]], [[OCaml]], [[Scala_(programming_language)|Scala]]
Line 30 ⟶ 29:
Flix supports [[tail call elimination]] which ensures that function calls in tail position never consume stack space and hence cannot cause the call stack to overflow<ref>{{cite journal |last1=Madsen |first1=Magnus |last2=Zarifi |first2=Ramin |last3=Lhoták |first3=Ondřej |title=Tail call elimination and data representation for functional languages on the Java virtual machine |journal=Proceedings of the 27th International Conference on Compiler Construction - CC 2018 |date=2018 |pages=139–150 |doi=10.1145/3178372.3179499|isbn=9781450356442 |s2cid=3432962 }}</ref>. Since the [[Java_bytecode_instruction_listings|JVM instruction set]] lacks explicit support for tail calls, such calls are emulated using a form of reusable stack frames<ref>{{cite journal |last1=Tauber |first1=Tomáš |last2=Bi |first2=Xuan |last3=Shi |first3=Zhiyuan |last4=Zhang |first4=Weixin |last5=Li |first5=Huang |last6=Zhang |first6=Zhenrui |last7=Oliveira |first7=Bruno C. D. S. |title=Memory-Efficient Tail Calls in the JVM with Imperative Functional Objects |journal=Programming Languages and Systems |series=Lecture Notes in Computer Science |date=2015 |volume=9458 |pages=11–28 |doi=10.1007/978-3-319-26529-2_2|isbn=978-3-319-26528-5 }}</ref>. Support for tail call elimination is important since all iteration in Flix is expressed through [[recursion]].
 
The Flix compiler disallows most forms of unused or redundant code, including: unused local variables, unused functions, unused formal parameters, unused type parameters, and unused type declarations, such unused constructs are reported as compiler errors<ref>{{cite web |title=Redundancies as Compile-Time Errors |url=https://flix.dev/blog/redundancies-as-compile-time-errors/ |website=flix.dev}}</ref>. [[Variable shadowing]] is also disallowed. The stated rationale is that unused or redundant code is often correlated with erroneous code<ref>{{cite journal |last1=Engler |first1=D. |title=Using redundancies to find errors |journal=IEEE Transactions on Software Engineering |date=October 2003 |volume=29 |issue=10 |pages=915–928 |doi=10.1109/TSE.2003.1237172}}</ref>.
 
A [[Visual Studio Code]] extension for Flix is available<ref>{{cite web |title=flix - Visual Studio Marketplace |url=https://marketplace.visualstudio.com/items?itemName=flix.flix |website=marketplace.visualstudio.com |language=en-us}}</ref>. The extension is based on the [[Language Server Protocol]], a common interface between [[Integrated_development_environment|IDEs]] and [[compilers]] being developed by [[Microsoft]].
Line 174 ⟶ 173:
A higher-order function can also be effect polymorphic: its effect(s) can depend on its argument(s).
 
For example, the standard library definition of <code>List.map</code> is effect polymorphic:<ref>{{cite web |title=The Flix API - List|url=https://api.flix.dev/List |website=api.flix.dev}}</ref>:
 
<syntaxhighlight lang="Scala">
Line 184 ⟶ 183:
A higher-order function that takes multiple function arguments may combine their effects.
 
For example, the standard library definition of forward [[Function_composition_(computer_science)|function composition]] <code>&gt;&gt;</code> is pure if both its function arguments are pure:<ref>{{cite web |title=The Flix API - Prelude |url=https://api.flix.dev/ |website=api.flix.dev}}</ref>:
 
<syntaxhighlight lang="Scala">
Line 226 ⟶ 225:
=== First-class Datalog Constraints ===
 
Flix supports [[Datalog]] programs as first-class values<ref name="oopsla2020b"/>.<ref>{{cite web |title=Programming Flix - Fixpoints |url=https://doc.flix.dev/fixpoints/ |website=flix.dev}}</ref><ref>{{cite journal |last1=Arntzenius |first1=Michael |last2=Krishnaswami |first2=Neel |title=Seminaïve evaluation for a higher-order functional language |journal=Proceedings of the ACM on Programming Languages |date=January 2020 |volume=4 |issue=POPL |pages=1–28 |doi=10.1145/3371090|s2cid=208305062 }}</ref>. A Datalog program is a logic program that consists of a collection of unordered [[Fact|facts]] and [[Horn_clause|rules]]. Together, the facts and rules imply a [[minimal model]], a unique solution to any Datalog program. In Flix, Datalog program values can be passed to and returned from functions, stored in data structures, composed with other Datalog program values, and solved. The solution to a Datalog program (the minimal model) is itself a Datalog program. Thus, it is possible to construct pipelines of Datalog programs where the solution, i.e. "output", of one Datalog program becomes the "input" to another Datalog program.
 
The following edge facts define a graph:
Line 349 ⟶ 348:
* [[Expression-oriented_programming_language|Everything is an expression]]. Most Flix constructs, except for top-level declarations, are expressions that evaluate to values.
* [[Closed-world assumption]]. The Flix compiler assumes that the source code of the entire program is available at compile-time.
* Pure and impure code is separated. The type and effect system precisely captures whether an expression may produce an effect<ref>{{cite web |title=Taming Impurity with Polymorphic Effects |url=https://flix.dev/blog/taming-impurity-with-polymorphic-effects/ |website=flix.dev}}</ref>.
* The language has no compile-time warnings, only errors.
 
Line 370 ⟶ 369:
* [https://api.flix.dev/ The Flix Standard Library]
 
[[:Category:FunctionalProcedural programming languages]]
 
[[:Category:Procedural programming languages]]
[[:Category:Logic programmingFunctional languages]]
[[:Category:High-levelProcedural programming languages]]
[[:Category:ProceduralLogic programming languages]]
[[Category:High-level programming languages]]
[[Category:High-level programming languages]]