Red (programming language)

Short description: Computer programming language released in 2011

Red

Paradigm| imperative, functional, symbolic
Designed by| Nenad Rakočević[1]
Developer| Nenad Rakočević
First appeared| 2011
Stable release|

0.6.4[2] (Alpha) / December 7, 2018

OS| Linux, Windows, OS X, Syllable
License| modified BSD and Boost
Filename extensions| .red, .reds
Website| {{{1}}}
Influenced by
Rebol, Scala, Lua

Red is a programming language designed to overcome the limitations of the programming language Rebol.[3] Red was introduced in 2011 by Nenad Rakočević,[4] and is both an imperative and functional programming language. Its syntax and general usage overlaps that of the interpreted Rebol language.[5]

The implementation choices of Red intend to create a full stack programming language:[4][6] 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.[7]

* Red/System is similar to C, but packaged into a Rebol lexical structure - for example, one would write Template:Smalltalk instead of `if (x > y) {printf("Hello\n");}`.
* Red is a homoiconic language[3] capable of meta-programming, with Rebol-like semantics. Red's runtime library is written in Red/System, and uses a hybrid approach: it compiles what it can deduce statically and uses an embedded interpreter otherwise. The project roadmap includes a just-in-time compiler for cases in between, but this has not yet been implemented.

Red seeks to remain independent of any other toolchain; it does its own code generation.[3] It is therefore possible to cross-compile[6] 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.

As of version 0.6.4 Red includes a garbage collector "the Simple GC".[2]

Red Language architecture schema

## Contents

* 1 Introduction
* 2 Features
* 3 Goals
* 4 Development
* 5 Cross compilation
* 6 Hello World!
* 7 Factorial example
* 8 See also
* 9 References
* 10 Further reading
* 11 External links

## Introduction

Red was introduced in the Netherlands in February 2011 at the Rebol & Boron conference[8] by its author Nenad Rakočević. In September 2011, the Red programming language was presented to a larger audience during the Software Freedom Day 2011.[9][10] Rakočević is a long-time Rebol developer known as the creator of the Cheyenne HTTP server.[11]

## Features

Red's syntax and semantics are very close to those of Rebol.[4][12] Like Rebol, it strongly supports metaprogramming and domain-specific languages (DSLs) and is therefore a highly efficient tool for dialecting (creating embedded DSLs). Red includes a dialect called Red/System, a C-level language which provides system programming facilities.[7] Red is easy to integrate with other tools and languages as a DLL (libRed) and very lightweight (around 1 MB). It is also able to cross-compile to various platforms (see Cross Compilation section below) and create packages for platforms that require them (e.g., .APK on Android).[7] Red also includes a fully reactive cross-platform GUI system based on an underlying reactive dataflow engine, a 2D drawing dialect comparable to SVG, compile-time and runtime macro support, and more than 40 standard datatypes.

## Goals

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

* Simplicity ("An IDE should not be necessary to write code.")
* Compactness ("Being highly expressive maximizes productivity.")
* Speed ("If too slow, it cannot be general-purpose enough.")
* Be "Green", Have a Small Footprint ("Because resources are not limitless.")
* Ubiquity ("Spread everywhere.")
* Portability, Write once run everywhere ("That's the least expected from a programming language.")
* Flexibility ("Not best but good fit for any task!")

## 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:

* MS-DOS: Windows, x86, console (and GUI) applications
* Windows: Windows, x86, GUI applications
* Linux: Linux, x86
* Linux-ARM: Linux, ARMv5, armel (soft-float)
* Raspberry Pi: Linux, ARMv5, armhf (hard-float)
* FreeBSD: x86
* Darwin: OS X Intel, console (and GUI) applications
* Syllable: Syllable OS, x86
* Android: Android, ARMv5
* Android-x86: Android, x86

(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

IMPORTANT: These are intended as syntax examples. Until Red has 64-bit support, the integer example will overflow a 32-bit integer very quickly. Changing that to `float!` will go farther, but these are merely to show the syntax of the language.

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

* Rebol

## References

1. ↑ "Creator of Red". https://github.com/dockimbel.
2. ↑ 2.0 2.1 lucindamichele. "0.6.4 Simple GC and Pure Red GUI Console". https://www.red-lang.org/2018/12/064-simple-gc-and-pure-red-gui-console.html. "The main feature for 0.6.4 is what we call the Simple GC (Garbage Collector). A more advanced GC is planned for the future"
3. ↑ 3.0 3.1 3.2 "Getting Started with GUI Programming using Red Language". https://www.studytonight.com/post/getting-started-with-gui-programming-using-red-programming-language.
4. ↑ 4.0 4.1 4.2 Balbaert 2018.
5. ↑ "Interview with Nenad Rakocevic about Red, a Rebol inspired programming language". 28 August 2015. https://www.notamonadtutorial.com/interview-with-nenad-rakocevic-about-red-a-rebol-inspired-programming-language/.
6. ↑ 6.0 6.1 "6 Unusual & Groundbreaking Programming Languages to Learn in 2023". 18 October 2023. https://www.makeuseof.com/programming-languages-to-learn-in-2023/.
7. ↑ 7.0 7.1 7.2 Lucas, Mathis (21 July 2023). "Red: an imperative and functional programming language that is also a "full battery" language". Developpez.com. https://programmation.developpez.com/actu/346670/Red-un-langage-de-programmation-imperatif-et-fonctionnel-et-decrit-comme-un-langage-a-pile-complete-c-est-a-dire-qu-il-peut-etre-utilise-pour-la-programmation-de-haut-niveau-et-de-bas-niveau/.
8. ↑ « New Red Programming Language Gets Syllable Backend », osnews.com, May 2011.
9. ↑ 9.0 9.1 « Red Programming Language: Red at Software Freedom Day 2011 », red-lang.org, September 14, 2011.
10. ↑ 10.0 10.1 "Software Freedom Day 2011: Red programming language, a new REBOL dialect". https://www.youtube.com/watch?v=wgtgoliZ454.
11. ↑ « What is Cheyenne? » Last referenced Nov 2017.
12. ↑ "The Dynamic Mapping Architecture". December 2021. https://etd.ohiolink.edu/apexprod/rws_etd/send_file/send?accession=toledo1639760375713532&disposition=inline.

## Further reading

* Balbaert, Ivo (May 2018) (in en). Learn Red - Fundamentals of Red. Packt Publishing. ISBN 978-1789130706.

## External links

* Red Programming Language on GitHub
* Redprogramming.com
* on GitHub

* v
* t
* e

Programming languages

* Comparison
* Timeline
* History

* APL
* Assembly
* BASIC
* C
* C++
* C#
* COBOL
* Elixir
* Fortran
* Go
* Groovy
* Haskell
* Java
* JavaScript (JS)
* Julia
* Kotlin
* Lisp
* Lua
* MATLAB
* Objective-C
* OCaml
* Pascal
* Perl
* PHP
* Python
* R
* Ruby
* Rust
* Scala
* Shell
* Smalltalk
* Swift
* TypeScript
* Visual Basic .NET (VB.NET)
* more...

* Category
* Lists
* Alphabetical
* Categorical
* Generational
* Non-English-based

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Red (programming language). Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Red_(programming_language)&oldid=192660"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template