LiveScript (programming language)

Last updated
LiveScript
Paradigms multi-paradigm, functional, object-oriented
Designed by Jeremy Ashkenas, Satoshi Murakami, George Zahariev
Developers (same)
First appeared2011;13 years ago (2011)
Stable release
1.6.1 / 14 July 2020;4 years ago (2020-07-14) [1]
Typing discipline dynamic, weak
Scope Lexical
OS Cross-platform
License MIT
Filename extensions .ls
Website livescript.net
Influenced by
JavaScript, Haskell, CoffeeScript, F#

LiveScript is a functional programming language that transpiles to JavaScript. It was created by Jeremy Ashkenas, the creator of CoffeeScript, along with Satoshi Muramaki, George Zahariev, and many others. [2] (The name may be an homage to the beta name of JavaScript; for a few months in 1995, it was called LiveScript before the official release. [3] )

Contents

Syntax

LiveScript is an indirect descendant of CoffeeScript. [4] The following "Hello, World!" program is written in LiveScript, but is also compatible with Coffeescript:

hello=->console.log'hello, world!'

While calling a function can be done with empty parens, hello(), LiveScript treats the exclamation mark as a single-character shorthand for function calls with zero arguments: hello!

LiveScript introduces a number of other incompatible idioms:

Name mangling

At compile time, the LiveScript parser implicitly converts kebab case (dashed variables and function names) to camel case.

hello-world=->console.log'Hello, World!'

With this definition, both the following calls are valid. However, calling using the same dashed syntax is recommended.

hello-world!helloWorld!

This does not preclude developers from using camel case explicitly or using snake case. Dashed naming is however, common in idiomatic LiveScript [5]

Pipes

A pipe operator |> passes the result of an expression on the left of the operator as an argument to the expression on the right of it. LiveScript supports these, as do some other functional languages such as F# and Elixir; the argument passed in F# is the last one, but in Elixir is the first one.

"hello!"|>capitalize|>console.log# > Hello!

Operators as functions

When parenthesized, operators such as not or + can be included in pipelines or called as if they are functions.

111|>(+)222# > 333(+)12# > 3

Related Research Articles

A "Hello, World!" program is generally a simple computer program that emits to the screen a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustrate a language's basic syntax. A "Hello, World!" program is often the first written by a student of a new programming language, but such a program can also be used as a sanity check to ensure that the computer software intended to compile or run source code is correctly installed, and that its operator understands how to use it.

Rebol is a cross-platform data exchange language and a multi-paradigm dynamic programming language designed by Carl Sassenrath for network communications and distributed computing. It introduces the concept of dialecting: small, optimized, domain-specific languages for code and data, which is also the most notable property of the language according to its designer Carl Sassenrath:

Although it can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain-specific languages or dialects

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.

<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.

<span class="mw-page-title-main">Apache Groovy</span> Programming language

Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries. Groovy uses a curly-bracket syntax similar to Java's. Groovy supports closures, multiline strings, and expressions embedded in strings. Much of Groovy's power lies in its AST transformations, triggered through annotations.

In some programming languages, eval, short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree, or of special type such as code. The analog for a statement is exec, which executes a string as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either eval or exec is.

In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments.

xHarbour is a free multi-platform extended Clipper compiler, offering multiple graphic terminals (GTs), including console drivers, GUIs, and hybrid console/GUIs. xHarbour is backward-compatible with Clipper and supports many language syntax extensions, greatly extended run-time libraries, and extensive third party support.

Harbour is a computer programming language, primarily used to create database/business programs. It is a modernised, open source and cross-platform version of the older Clipper system, which in turn developed from the dBase database market of the 1980s and 1990s.

<span class="mw-page-title-main">Scala (programming language)</span> General-purpose programming language

Scala is a strong statically typed high-level general-purpose programming language that supports both object-oriented programming and functional programming. Designed to be concise, many of Scala's design decisions are intended to address criticisms of Java.

<span class="mw-page-title-main">JavaScript syntax</span> Set of rules defining correctly structured programs

The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.

CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehension and destructuring assignment.

In computer programming, string interpolation is the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placeholders are replaced with their corresponding values. It is a form of simple template processing or, in formal terms, a form of quasi-quotation. The placeholder may be a variable name, or in some languages an arbitrary expression, in either case evaluated in the current context.

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

Opa is a programming language for developing scalable web applications. It is free and open-source software released under a GNU Affero General Public License (AGPLv3), and an MIT License.

Mustache is a web template system. It is described as a logic-less system because it lacks any explicit control flow statements, like if and else conditionals or for loops; however, both looping and conditional evaluation can be achieved using section tags processing lists and anonymous functions (lambdas). It is named "Mustache" because of heavy use of braces, { }, that resemble a sideways moustache. Mustache is used mainly for mobile and web applications.

<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">ReactiveX</span> Program library

ReactiveX is a software library originally created by Microsoft that allows imperative programming languages to operate on sequences of data regardless of whether the data is synchronous or asynchronous. It provides a set of sequence operators that operate on each item in the sequence. It is an implementation of reactive programming and provides a blueprint for the tools to be implemented in multiple programming languages.

<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">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. "LiveScript Releases". GitHub . Retrieved 21 February 2021.
  2. "LiveScript contributors page". GitHub . Retrieved 20 June 2015.
  3. "Chapter 4. How JavaScript Was Created". speakingjs.com. Archived from the original on 2020-02-27. Retrieved 2017-11-21.
  4. "LiveScript - a language which compiles to JavaScript".
  5. "prelude.ls - a functionally oriented utility library in LiveScript".