- Posted by liammclennan on November 23, 2009
Iām going to be looking at a few different languages and blogging my thoughts. I am not a language dork so it will probably be mostly wrong. The languages I care about are c# (which is what I mostly use), javascript (which I love) and ruby (which everyone else loves).
This post is part of a series comparing the language features of the C#, Javascript and Ruby programming languages.
Installation
C# is installed by installing visual studio, Javascript is included in all the popular browsers and Ruby can be installed (at least on Windows) using the Windows one-click installer.
Scripting-ness
Javascript and ruby are scripting languages, meaning that they are interpreted and dynamically typed. C# is strongly typed and compiled. In practice, this means that C# executes faster and is better at detecting errors at compile time. Javascript and Ruby support a faster development cycle, since there is no compile step, and provide more flexibility.
hello world
Here are the canonical hello world applications in each language.
C#:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}
Javascript:
Ruby:
To execute a ruby program open a command prompt and run: ruby [ruby file name]
Note that the scripting languages require less ceremony to get something to run. You can drop commands in a text file, hand it to the interpreter, and it will run. This simple example also demonstrates the differences in line endings ā Javascript and C# terminate lines with a semicolon, Ruby uses the new line character.