Ruby vs Javascript: A Quick Overview

This is simply an overview for those of you with little or no programming experience to have a basic overview of the major differences between Javascript and Ruby: Which one should you choose if you are just starting out, their fundamental architectural differences and also how you the bidding coder would be able to manipulate it as you see fit. So lets get started.

Historical Differences

Since the first language I learned was Ruby, I will start with that. Ruby was developed by a group of people, leading the design team Osaka born Yukihiro Matsumoto . He, and I quote, “really wanted a genuine object-oriented with easy-to-use scripting language” that Python just didnt have but also taking influences from Perl which he really liked but referred to it as a “Toy Language”. It first appeared around the year of my birth 1995 and now is on version 2.2.0 after 20 years.

Javascript on the other hand was developed by Brendan Eich, in a trivial 10 days also in 1995. Ech was initially hired by Netscape Communications (Now subsidiary of AOL) to put Scheme in the browser to compete with Microsoft for adoption of platforms within the browser, instead he made what is known then as Livescript but was quickly renamed to Javascript . Within a year Javascript gained widespread usage as a scripting language and was adopted by Microsoft’s Internet Explorer 3.0 in 1996.

Linguistic Differences

So Ruby and Javascript are fairly similar as they both use Object Oriented Programming , they are both Dynamic Languages , General Purpose Languages and Scripting-Languages . Well what does that mean Scripting Languages are languages that support programs written for a special ‘Runtime environment’ that can interpret rather than compile. A general purpose language, Object Oriented Programming is where a programming language can create these elements called Objects that represent some form of data as opposed to actions. This makes it much easier for the programmer to manipulate an objects data. Theres a little more detail but for the sake of time I’ll move onto the more useful Syntactic Differences.

Syntactic Differences

So as some people who are familiar with programming in general will know of the concept of : Variables, Hashes , Semicolons, Methods, For Loops , While Loops, Conditionals and Classes. Im going to go over how they are called in both languages so you can see the difference.


In ruby variables are relatively easy to set, you just have to type in

variable_name = variable_value

In Javascript its a little bit longer but essentially the samething.

var variable_name = variable_value


In ruby hashes are referred to like so:

hash_name = { hash_key: hash_value , sechash_key: sechash_value}

In Javascript hashes are referred as Objects , the “Key” in Ruby is simply a variable.

var hash_name = { hash_key: hash_value , sechash_key: sechash_value}

You can call upon the hash to find the value of a key in ruby by using

hash_name[:hash_key] —-> hash_value

In Javascript you can call the “Object” to get the value of the key , which would look like so:

hash_name.hash_key —-> hash_value

The semicolon (;) :

Semicolons are not obligitory in Ruby , in fact they are not an option at all there are no semicolons where there is a statement in ruby.

However in javascript Semicolons are necessary where there is more than 1 statement on a line. However do not use them after a curly bracket

var i = 0; i++        // <-- semicolon obligatory
// (but optional before newline)
var i = 0 // <-- semicolon optional
i++ // <-- semicolon optional
// NO semicolons after }:
if (...) {...} else {...}
for (...) {...}
while (...) {...}

Also don’t use them after the round bracket of an if, for, while or switch statement. Its just redundant..

if (0 === 1); { alert("hi") }

// equivalent to:

if (0 === 1) /*do nothing*/ ;
alert ("hi");

Of course there is an exception but I’ll get onto that later..


So methods within Ruby that do not take an argument , eg. “.reverse” . Do not require parenthesis.

"string".reverse ---> "gnirts"

However within javascript almost all methods require parenthesis.

"string".split("").reverse().join("") ---> "gnirts"

For Loops:

In Ruby for loops are relatively less tiresome to write and also have a

for varibale_name != variable_value do 

So remember the exception I was talking about with semicolons, well here it is. In Javascript you have semi colons within for loops it is written as:

for (var i=0; i !== var_value; i++)  {/*actions*/}          // correct
for (var i=0; i !== var_value; i++;) {/*actions*/} // SyntaxError

While loops:

Ruby while loops are also relatively less cumbersome than Javascript while loops.

while (x < 10)
x +=1

Within Javascript we can see much more semicolons and also a tonne more curly brackets of all kinds. In addition the incrementing by +1 is different in Ruby , where it just takes you having to increase it by +=1 .

while (x<10) {


Functions in Javascript are known as reference types so essentially If I were to go ahead and call a function by saying

function sayhello(name) {
return “ Helllo “ + name

where as in Ruby functions are defined like so

def sayhello(name) 
p “Hello” + name.to_s

Usage Differences

To start out Javascript is in a large majority of websites nowadays, being famed for creating interactive features within the browser, although it may not be the most powerful language or performant.

Examples of JS sites include :,

Show your support

Clapping shows how much you appreciated Edozié Izegbu’s story.