-
Essay / Ruby vs Bash - 940
Comparison and Contrast of Bash Shell Scripting Language with Ruby Programming LanguageAt first glance, these two languages seem to be polar opposites. Bash shell script with its roots in Unix terminal scripting versus a modern object-oriented scripting language. So, are these two languages really that different and what could they have in common? This document 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 (mainly installed on Linux-based systems). Bash scripts are created with an editor and are executed with the Unix sh command. The Bash language itself is highly procedural, supporting shell variables and procedural constructs such as ifs and loops. Bash provides excellent support for combining Unix commands and their outputs in almost unlimited ways. The Ruby programming language, designed by Yukihiro "Matz" Matsumoto, arrived about five years later with the goal of making programmers more productive and making the process of creating software more enjoyable. Ruby itself can be used to create graphical user interfaces (guis) and is the cornerstone of the "Ruby on Rails" web application framework. Three elements of code syntax that define and differentiate programming languages are: degree of free form, case sensitivity. and instruction terminators. Based on these elements, Bash and Ruby have a lot in common. Both languages are case sensitive and do not have a statement terminator. However, Ruby is considerably freer than Bash where even a misplaced space can prevent a command from executing p...... middle of paper ......rver). So we shouldn't be surprised to learn that Bash allows us to run any Unix command in background mode simply by adding an ampersand (&). In this sense, Bash appears to support concurrent programming, but only at a very crude level. Ruby, however, offers finer-grained control via Ruby threads. Ruby threads are not real operating system threads, but allow us to emulate them and are quite adequate for most situations where concurrent processing is required. The latest version of Ruby (version 1.9) now offers a feature called "Fibers" which provides additional concurrent capabilities. In conclusion, Ruby appears to offer much superior language features through which it is possible to accomplish more with less code. But we must not forget that languages themselves have quite different roles and that we are comparing apples to oranges here...