Reason (programming language)

Last updated
Reason
Reason-logo.svg
Paradigms Multi-paradigm: functional, imperative, modular, object-oriented
Family ML: Caml: OCaml
Designed by Jordan Walke
First appearedMay 16, 2016;8 years ago (2016-05-16) [1]
Stable release
3.13.0 [2]   OOjs UI icon edit-ltr-progressive.svg / October 21, 2024;50 days ago (October 21, 2024)
License MIT
Filename extensions .re, .rei
Website reasonml.github.io OOjs UI icon edit-ltr-progressive.svg
Influenced by
OCaml, JavaScript

Reason, also known as ReasonML, is a general-purpose, high-level, multi-paradigm, functional and object-oriented programming language and syntax extension and toolchain for OCaml created by Jordan Walke, who also created the React framework, at Facebook. [3] [4] Reason uses many syntax elements from JavaScript, compiles to native code using OCaml's compiler toolchain, and can compile to JavaScript using the ReScript compiler. [5]

Contents

The Reason community officially provides ReasonReact as a solution for React-based web applications. [6]

BuckleScript and ReScript

Reason was originally compiled to JavaScript using the BuckleScript compiler, [7] which was created at Bloomberg L.P.

In 2020, the BuckleScript and Reason toolchain was rebranded to ReScript, essentially creating a separate language that had different syntax from Reason and only compiled to JavaScript. [8]

BuckleScript was forked to Melange [9] to continue to support compiling OCaml to JavaScript.

Example

typeschoolPerson=Teacher|Director|Student(string);letgreeting=person=>switch(person){|Teacher=>"Hey Professor!"|Director=>"Hello Director."|Student("Richard")=>"Still here Ricky?"|Student(anyOtherName)=>"Hey, "++anyOtherName++"."};

See also

Related Research Articles

This is a record of notable programming languages, by decade.

OCaml is a general-purpose, high-level, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

In computer science, a preprocessor is a program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and macro expansions, while others have the power of full-fledged programming languages.

<span class="mw-page-title-main">F Sharp (programming language)</span> Microsoft programming language

F# is a general-purpose, high-level, strongly typed, multi-paradigm programming language that encompasses functional, imperative, and object-oriented programming methods. It is most often used as a cross-platform Common Language Infrastructure (CLI) language on .NET, but can also generate JavaScript and graphics processing unit (GPU) code.

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under an MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

In computer programming, an anonymous function is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for constructing the result of a higher-order function that needs to return a function. If the function is only used once, or a limited number of times, an anonymous function may be syntactically lighter than using a named function. Anonymous functions are ubiquitous in functional programming languages and other languages with first-class functions, where they fulfil the same role for the function type as literals do for other data types.

QuickCheck is a software library, a combinator library, originally written in the programming language Haskell, designed to assist in software testing by generating test cases for test suites – an approach known as property testing.

<span class="mw-page-title-main">Svelte</span> JavaScript framework

Svelte is a free and open-source component-based front-end software framework, and language created by Rich Harris and maintained by the Svelte core team members.

<span class="mw-page-title-main">Google Closure Tools</span> JavaScript developer toolkit

Google Closure Tools is a set of tools built with the goal of helping developers optimize rich web applications with JavaScript. It was developed by Google for use in their web applications such as Gmail, Google Docs and Google Maps. As of 2023, the project had over 230K LOCs not counting the embedded Mozilla Rhino compiler.

Haskell is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell has pioneered several programming language features such as type classes, which enable type-safe operator overloading, and monadic input/output (IO). It is named after logician Haskell Curry. Haskell's main implementation is the Glasgow Haskell Compiler (GHC).

<span class="mw-page-title-main">Elm (programming language)</span> Functional programming language

Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice", made possible by the Elm compiler's static type checking.

<span class="mw-page-title-main">F* (programming language)</span> Functional programming language inspired by ML and aimed at program verification

F* is a high-level, multi-paradigm, functional and object-oriented programming language inspired by the languages ML, Caml, and OCaml, and intended for program verification. It is a joint project of Microsoft Research, and the French Institute for Research in Computer Science and Automation (Inria). Its type system includes dependent types, monadic effects, and refinement types. This allows expressing precise specifications for programs, including functional correctness and security properties. The F* type-checker aims to prove that programs meet their specifications using a combination of satisfiability modulo theories (SMT) solving and manual proofs. For execution, programs written in F* can be translated to OCaml, F#, C, WebAssembly, or assembly language. Prior F* versions could also be translated to JavaScript.

<span class="mw-page-title-main">Nim (programming language)</span> Programming language

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level system programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

<span class="mw-page-title-main">Babel (transcompiler)</span> Backwards compatible JavaScript compiler

Babel is a free and open-source JavaScript transcompiler that is mainly used to convert ECMAScript 2015+ (ES6+) code into backwards-compatible JavaScript code that can be run by older JavaScript engines. It allows web developers to take advantage of the newest features of the language.

Next.js is an open-source web development framework created by the private company Vercel providing React-based web applications with server-side rendering and static rendering.

<span class="mw-page-title-main">PureScript</span> Strongly-typed language that compiles to JavaScript

PureScript is a strongly-typed, purely-functional programming language that transpiles to JavaScript, C++11, Erlang, and Go. It can be used to develop web applications, server side apps, and also desktop applications with use of Electron or via C++11 and Go compilers with suitable libraries. Its syntax is mostly comparable to that of Haskell. In addition, it introduces row polymorphism and extensible records. Also, contrary to Haskell, the PureScript language is defined as having a strict evaluation strategy, although there are non-conforming back-ends which implement a lazy evaluation strategy.

<span class="mw-page-title-main">Gleam (programming language)</span> Programming language

Gleam is a general-purpose, concurrent, functional high-level programming language that compiles to Erlang or JavaScript source code.

References

  1. "Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems: facebook/reason". GitHub. Facebook. 2019-03-23. Retrieved 2019-03-23.
  2. "Release 3.13.0". 21 October 2024. Retrieved 27 October 2024.
  3. "What is ReasonML?". 2ality. Retrieved 2019-03-23.
  4. Rauschmayer, Axel (2018). Exploring ReasonML and functional programming. ReasonML Hub. Retrieved 2024-05-14.
  5. "Overview: ReScript Documentation". rescript-lang.org. Retrieved 2020-08-10.
  6. "ReasonReact". GitHub .
  7. "BuckleScript". Bloomberg L.p. Retrieved 2022-09-11.
  8. "BuckleScript & Reason Rebranding". rescript-lang. Retrieved 2022-09-11.
  9. "ANN: Melange 1.0 – compile OCaml / ReasonML to JavaScript". OCaml. 2023-06-02. Retrieved 2024-05-24.