A set of simple loop-based programs that demonstrate the concept of REPLs and Shells.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
simple-repl.rb
simple-shell.rb

README.md

Description

Simple loops is a repository of very simple examples of a REPL and a Shell implemented in Ruby. I've used these examples to help students understand what the more complex alternatives are really doing. Currently, the examples are extremely simple. I hope to include slightly more complex examples in the future.

What is a REPL?

REPL stands for Read, Evaluate, and Print Loop. Essentially, it allows a programmer to interactively work with an interpreter/compiler and receive feedback along the way. Wikipedia has an excellent article on REPLs, but I believe the code demonstrates the basic concept rather well.

Ruby REPLs

If this was your first introduction to REPLs, then you will likely want to play with some more sophisticated REPLS. A great place to start is TryRuby, which is an online version of the REPL that's built into the Ruby language, called IRB (Interactive Ruby). Another, more powerful alternative, called Pry is also available. Pry also has several excellent screencasts that demonstrate the power of a great REPL.

What is a Shell?

A shell is a user-interface for a computer operating system. Shells come in many, many varieties and have a long history. (I refer the interested reader to the Unix shell article on Wikipedia as a great place to begin learning about this history.) A simple shell accepts commands, executes the command, provides results to the user, and waits for another command. In this, it is very similar to a REPL.

Modern Unix Shells

Several Unix Shells remain popular today. The Bash shell is the most popular default shell for Unix systems. It is feature-rich and powerful. If you don't have a reason to pick another shell, you should start learning Bash.

A popular Bash-alternative is the Z Shell, or zsh, which was developed as a sort of superset of several popular shells for Unix systems. Partially as a result of this, it has a huge feature set. If you're looking for a comprehensive, flexible shell that will be compatible many previous shells, then zsh is for you.

A great way to learn about shells is to look at how other people use their shells. To that end, I would recommend checking out Robby Russell's Oh My Zsh project, which provides a community-based framework for extending and configuring the Z shell. A similar framework for Bash is called Bash it.