3.2 Getting Started

How to Install Ruby

The time has come for you to begin writing simple programs. Before you can do that, you need to install Ruby. This is explained in Appendix B at the back of the book.

How to Save Programs

The next thing to learn is how to save your work. When writing a computer program (informally called code), it is often important to be able to save it as a plain text file, which can be opened and used later.

To save a program, you must first open a piece of software that allows you to create, save, and edit text files. These programs are called text editors, and examples include Notepad, Scite (included in the one-click installation of Ruby), and many others we discuss in Appendix C. For more advanced editors, you may want to look into vim and emacs. There is also a version of the integrated development environment (IDE) Eclipse that works with Ruby. Eclipse includes a plain text editor. Once a text editor is open, be sure it is set to save as an unformatted text file (FileName.txt). Most word processors, such as Word, add special characters for document formatting, so these should not be used for writing programs. If special characters are turned off by saving the document as a plain text file (.txt), you can use various word processing programs, such as Word.

Now you are ready to write and save programs.

Gem of Wisdom

Plain text files (sometimes seen with the extension .txt) are stored as a simple sequence of characters in memory. For example, ...

Get Computer Science Programming Basics in Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.