Book Image

Learn Red ? Fundamentals of Red

By : Ivo Balbaert
Book Image

Learn Red ? Fundamentals of Red

By: Ivo Balbaert

Overview of this book

A key problem of software development today is software bloat, where huge toolchains and development environments are needed in software coding and deployment. Red significantly reduces this bloat by offering a minimalist but complete toolchain. This is the first introductory book about it, and it will get you up and running with Red as quickly as possible. This book shows you how to write effective functions, reduce code redundancies, and improve code reuse. It will be helpful for new programmers who are starting out with Red to explore its wide and ever-growing package ecosystem and also for experienced developers who want to add Red to their skill set. The book presents the fundamentals of programming in Red and in-depth informative examples using a step-by-step approach. You will be taken through concepts and examples such as doing simple metaprogramming, functions, collections, GUI applications, and more. By the end of the book, you will be fully equipped to start your own projects in Red.
Table of Contents (13 chapters)
11
Assessments

Red's main features

As a programming language, Red embraces nearly all paradigms:

  • Imperative: Providing everything needed for controlling code execution and error-handling (see Chapter 4, Code Controlling Structures and Chapter 5, Working with Series and Blocks)
  • Functional: With functions as first class values (see Chapter 6, Using Functions and Objects)
  • Object-oriented: Complete with inheritance, but not class-based (see Chapter 6, Using Functions and Objects)
  • Concurrency: With async task support and an actor model (from v 0.9.0)
  • Symbolic: Being able to manipulate its own code as if it was plain data (all chapters)
  • Reactive: Included in the GUI (Graphical User Interface) system (see Chapter 9, Composing Visual Interfaces and Chapter 10, Advanced Red)

Aside from REBOL and LISP, Red has taken inspiration from the following:

  • Forth and Logo for its syntax
  • Lua, for its capabilities as an embedded language, and its JIT (Just-In-Time) compiler
  • Self, for its prototype object-model
  • Scala, for its type inference engine and compilation

Although it can be statically compiled, Red has a graphical REPL console (Read Evaluate Print Loop) like other dynamic and scripting languages, to experiment with code interactively. We will explore this console in Chapter 2, Setting Up for Development.

In contrast to REBOL, which is an interpreted language only, Red also compiles to native code through Red/System, thus achieving much better performance, something like Crystal compared to Ruby. Compared to C, at this moment Red/System is 2-4x slower.

Portability

Red runs in the Windows, Linux, Android, macOS, and FreeBSD environments in a 32-bit version (the 64-bit version is planned) with cross-compilation capability. Furthermore, it runs on ARMv5 processors and on the Raspberry Pi and Arduino boards.

Like a Swiss Army knife

The versatility of the Red platform makes it suitable for apps on the entire spectrum, such as:

  • High-level scripting (for example, glue code such as Lua)
  • Web apps
  • GUI desktop applications
  • Android apps (from Version 0.7 onward)
  • 2D games
  • Data processing
  • Grammar parsing and constructing specialized languages
  • Network/system programming, IoT devices programming, robotics