Content deleted Content added
m Task 18 (cosmetic): eval 6 templates: del empty params (5×); del |url-status= (1×); |
Alexflatter (talk | contribs) No edit summary |
||
(32 intermediate revisions by 23 users not shown) | |||
Line 1:
{{Short description|Syntax extension and toolchain for OCaml}}
| name = Reason
| logo = Reason-logo.svg
| logo_size = 200px
| paradigms = [[Programming paradigm#Multi-paradigm|Multi-paradigm]]: [[Functional programming|functional]], [[Imperative programming|imperative]], [[Modular programming|modular]], [[Object-oriented programming|object-oriented]]
|title = Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems: facebook/reason|date=2019-03-23▼
| family = [[ML (programming language)|ML]]: [[Caml]]: [[OCaml]]
| designer = Jordan Walke
▲| released = {{Start date and age|
| website = {{URL|https://reasonml.github.io/}}▼
| latest release version = {{wikidata|property|edit|reference|P348}}
| license = [[MIT License]]▼
| latest release date = {{start date and age|{{wikidata|qualifier|mdy|P348|P577}}}}
| file_ext = .re, .rei▼
▲| license = [[MIT License|MIT]]
| influenced by = [[OCaml]], [[JavaScript]]
| influenced =
}}
'''Reason''', also known as '''ReasonML''', is a [[
The Reason community officially provides ReasonReact as a solution for
== BuckleScript and ReScript<span class="anchor" id="BuckleScript"></span><span class="anchor" id="ReScript"></span> ==
Reason was originally compiled to JavaScript using the BuckleScript compiler,<ref>{{cite news |url=https://www.bloomberg.com/company/press/open-source-at-bloomberg-introducing-bucklescript/ |title=BuckleScript |newspaper=Bloomberg L.p.|access-date=2022-09-11}}</ref> which was created at [[Bloomberg L.P.]]
In 2020, the BuckleScript and Reason toolchain was rebranded to [[ReScript (programming language)|ReScript]], essentially creating a separate language that had different syntax from Reason and only compiled to JavaScript.<ref>{{cite web |url=https://rescript-lang.org/blog/bucklescript-is-rebranding |title=BuckleScript & Reason Rebranding |website=rescript-lang|access-date=2022-09-11}}</ref>
BuckleScript was forked to Melange<ref>{{Cite web |date=2023-06-02 |title=ANN: Melange 1.0 – compile OCaml / ReasonML to JavaScript |url=https://discuss.ocaml.org/t/ann-melange-1-0-compile-ocaml-reasonml-to-javascript/12305 |access-date=2024-05-24 |website=OCaml |language=en}}</ref> to continue to support compiling OCaml to JavaScript.
== Differences from OCaml Syntax ==
While Reason compiles down to native code via OCaml's toolchain, it specifically differs in its syntax, [[Error message|error messaging]], and editor tooling.<ref>{{Cite web |title=What & Why · Reason |url=https://reasonml.github.io/docs/en/what-and-why |access-date=2025-02-08 |website=reasonml.github.io |language=en}}</ref> This allows Reason to provide an experience more similar to JavaScript or [[TypeScript]] for developers, which some may be more familiar with.
While OCaml often relies on [[Indentation style|Indentation]] and begin/end keywords, Reason tends to use curly braces to delimit blocks and semicolons for separation of expressions. Like JavaScript, Reason also defines functions via arrow-like syntax. Other notable differences include usage of a [[Switch statement|switch]] construct (instead of a match construct) and a reformatter for error messages.
== Example ==
<syntaxhighlight lang="reason">
type schoolPerson = Teacher | Director | Student(string);
let greeting = person =>
switch (person) {
| Teacher => "Hey Professor!"
| Director => "Hello Director."
| Student("Richard") => "Still here Ricky?"
| Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "."
};
</syntaxhighlight>
== See also ==
{{Portal|Free and open-source software}}
* [[Elm (programming language)|Elm]]
* [[PureScript]]
== References ==
Line 30 ⟶ 56:
== External links ==
{{
*
* {{GitHub|reasonml|Reason Project Organisation}}
* [https://reasonml.github.io/reason-react/ ReasonReact]
{{
{{Programming languages}}
{{Authority control}}
[[Category:Cross-platform free software]]
[[Category:Extensible syntax programming languages]]
[[Category:Free
[[Category:Functional languages]]
[[Category:ML programming language family]]▼
[[Category:Object-oriented programming languages]]
▲[[Category:ML programming language family]]
[[Category:OCaml programming language family]]
[[Category:Pattern matching programming languages]]
|