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

To get the most out of this book

Some knowledge of the basic concepts of programming and a bit of experience of any programming language, such as Java, C#, Python, Ruby, or JavaScript, is assumed. To follow along with the examples and exercises, only a minimal install is required, which is discussed in detail in Chapter 2, Setting Up for Development. Practice is the best way to learn a new language. That's why each chapter contains some questions and small exercises to try out your new skills. You'll find the solution in the code files and in the Assessments section.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learn-Red-Fundamentals-of-Red. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The console executable is built inside the /home/user/.red folder and is named in the format console-yyyy-m-dd-nnnnn."

A block of code is set as follows:

Red [
Name-Of-Info: "Value of Info"
Name-Of-Info2: "Value of Info2"

...
]

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

a: [1 2 3]
b: copy a
b ;== [1 2 3]
append a 4
a ;== [1 2 3 4]
b ;== [1 2 3]

You can find the code in the codefile that accompanies each section. At the start of each code snippet, you'll see:

;-- see ChapterNN/codefile.red:

This means that this snippet is found in the file ChapterNN/codefile.red in the code download (where NN goes from 01 to 10), as well as the code snippets shown after that, until a new codefile is indicated.

We'll use the terms program, script, app or application as synonyms in this book, because a Red source file can be compiled or interpreted.

We show the return value of a piece of code after ;== like a: 5 ;== 5, because == is how the Red console displays it, and the prefix ; makes it into a comment in scripts.

We have chosen to make all programs immediately runnable in the console without errors. However, certain code is there explicitly to make you see certain errors. These are indicated with a comment: *** Script Error …. Just remove the comment (;) sign at the start of the line to make the error occur.
The same goes for lines staring with #include, just uncomment them in order to compile the program.

Any command-line input or output is written as follows:

$ sudo apt-get update

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example:
"From the menu, open File | Run.
"

Warnings or important notes appear like this.
Tips and tricks appear like this.