Essay on Ruby against Bash

930 Words 4 Pages
Comparing and contrasting the Bash Shell scripting language with the Ruby Programming language

At first glance these two languages appear to be poles apart. Bash shell script with its roots in Unix terminal scripting versus a modern object oriented scripting language'. So, are these two languages really so different and what might they have in common? This documents aims to answer these questions.

The Bash Shell was implemented in 1989 by Brian Fox. Its purpose was to act as a 'command processor'. In other words, this language would act as an interface between the user and the GNU operating system (primarily installed on Linux based systems). Bash scripts are created with an editor and are run with the Unix sh command. The Bash
…show more content…
Writing Bash scripts requires a good deal of effort and research to complete a given task. Programmers in Ruby however, often experience the 'oh, its done already' phenomenon after coding for only a short period. Another categorizing criterion for any given programming language is whether that language is compiled or interpreted. Again, in this respect, the two languages prove to be similar as they are both interpreted. Bash scripts interpreted by a Unix shell, and Ruby by a Ruby virtual machine.

Perhaps the most glaring difference between Bash and Ruby is the fact that Ruby is a pure object oriented language, whereas Bash is not. In Ruby everything is considered some kind of object even numbers. Ruby implements all the features that a programmer might expect to see in any modern object oriented scripting language such as inheritance, encapsulation, and polymorphism. Curiously though Ruby has no abstract classes or interface types. Ruby uses 'modules' to address this apparent deficiency though.

Variable typing is quite different in the two languages. In Bash, variables are not really considered to have any given type and mostly they act to hold some string value. Shell variables do not need to be declared prior to their use, although their scope can be limited with the Bash 'local' keyword. As for Ruby, variables do have specific types. Ruby makes use of 'Duck typing'. Duck typing comes from the expression 'If it walks

Related Documents