Red (programming language)

Red
Red Logo (stylized Tower of Hanoi)
Paradigm imperative, functional, symbolic
Designed by Nenad Rakocevic
Developer Nenad Rakocevic
First appeared 2011
Stable release
0.6.1 (Alpha) / July, 2016
OS Linux, Windows, OS X, Syllable
License modified BSD license
Filename extensions .red, .reds
Website www.red-lang.org
Influenced by
Rebol, Scala, Lua

Red is a computer programming language. Red was made to overcome the limitations of the programming language Rebol. Red is both an imperative and functional programming language introduced in 2011 by Nenad Rakocevic. Its syntax and general usage directly overlaps with that of the interpreted Rebol language (which was introduced in 1997). The implementation choices of Red were geared specifically to create what Rakocevic calls a "full stack programming language". Red can be used for extremely high-level programming (DSLs and GUIs) as well as low-level programming (operating systems and device drivers).

Key to the approach is that the language has two parts: Red/System and Red. The former (Red/System) is similar to C, but packaged into a Rebol lexical structure (e.g. one would write if x > y [print "Hello"] instead of if (x > y) {printf("Hello\n");}). Red itself is a homoiconic language capable of meta-programming, with semantics similar to Rebol's. Red's runtime library is written in Red/System, and uses a hybrid approach: it compiles what it can deduce statically and falls back onto an embedded interpreter otherwise (according to the roadmap, a just-in-time compiler will be employed for cases in between, but this has not been implemented so far).

Red seeks to remain independent of any other toolchain, and thus does its own code generation. It is therefore possible to cross-compile Red programs from any platform it supports to any other, via a command-line switch. Both Red and Red/System are distributed as open-source software under the modified BSD license. The runtime library is distributed under the more permissive Boost Software License.

Red Language architecture schema

Introduction

Red was first introduced in the Netherlands on February 2011 at the Rebol & Boron conference[1] by its author Nenad Rakocevic. In September 2011, the Red programming language was presented to a larger audience during the Software Freedom Day 2011.[2][3] Rakocevic is a long-time Rebol developer known as the creator of the Cheyenne HTTP server;[4] he was the joint winner of the "Rebol of the Year" 2011 election.[5]

Features

Red's syntax and semantics are very close to those of Rebol. Like Rebol, it strongly supports metaprogramming and domain-specific languages (DSLs) and is therefore a highly efficient tool for dialecting. Red builds on a dialect called Red/System, which provides system programming facilities. Red is easy to embed ("Think Lua") and very lightweight (no more than a megabyte). It is also able to cross-compile to various platforms (see Cross Compilation section below) as well as creating packages (like .APK packages on Android) for some platforms (currently, Android is the only platform supported but development is still in process) via bridges intended for implementation of Red on the former (like the Java JVM, .NET, JavaScript etc).

Goals

The following is the list of Red's Goals as presented on the Software Freedom Day 2011:

Development

Red's development is planned to be done in two phases:

  1. Initial phase: Red and Red/System compilers written in Rebol 2
  2. Bootstrap phase: Red and Red/System compilers complemented by a Red JIT-compiler, all written in Red

Cross compilation

Red currently supports the following cross-compilation targets:

(Note: This list will increase with time and should therefore be considered as incomplete.)

Hello World!

Red [
	Title: "Simple hello world script"
]
print "Hello World!"

Factorial Example

The following is a factorial example in Red :

Red [Title: "A factorial script"]  ; Note: The title is optional.

factorial: func [
	x [integer!]  ; Giving the type of an argument in Red is optional
][
	either x = 0 [1][x * factorial x - 1]
]

The following is the same factorial example in Red/System (in this very simple case, the source code is very similar to Red's version) :

Red/System [Title: "A factorial script"]

factorial: func [
	x       [integer!]                   ; This is compulsory in Red/System
	return: [integer!]                   ; This is compulsory in Red/System
][
	either x = 0 [1][x * factorial x - 1]
]

See also

References

  1. « New Red Programming Language Gets Syllable Backend », osnews.com, May 2011.
  2. « Red », softwarefreedomday.eu, september 14, 2011.
  3. « Red Programming Language: Red at Software Freedom Day 2011 », red-lang.org, september 14, 2011.
  4. « Red Alert! », syllable.org, May 2011.
  5. « Red & Rebol DevCon Winter 2012 », devcon, winter 2012.
Wikimedia Commons has media related to Red (programming language).
This article is issued from Wikipedia - version of the 7/20/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.