Jonas Follesø profile picture

Jonas Follesø

Software Developer

Learn the language, live the lifestyle

May 28th 2007

The last year there has been a wind of "dynamisms" sweeping the developer community. Developers are getting exited about dynamic languages in general, and perhaps one language in particular; Ruby. The Ruby programming language, and it's supporting frameworks, seams to spread allot of joy and happiness among web developers. Microsoft has recognized this, and has picked up on dynamic languages with IronPython, IronRuby and the Dynamic Language Runtime.

The keynote for day 2 of Developer Summit 2007 was held by Niclas Nilsson and was titled "Dynamic languages for statically typed minds". Niclas talked about talked about three dynamic languages (Ruby, Python, Groovy) and three static languages (C++, C# and Java), but focused mostly on Java and Ruby. Through and interesting talk and several good comparisons and examples Nicolas tried to open up the eyes of the C# and Java developers to this new world of dynamic languages.

Fellow RD Scott Hanselman have talked about dynamic languages several times on this blog. A couple of months back he did an interesting Hanselminutes episode covering dynamic languages (Ruby and PowerShell) from a .NET perspective. Yesterday he wrote a post trying to highlight some of the key aspects that makes Ruby an attractive programming language. I don't think he quite managed to get the message across, but his post caused a really interesting discussion in the comments section. Well worth checking out! Wilco Bauwer followed up on this with an interesting posts on why developers should explore new programming languages. As a developer you should never settle, and always try to improve your self as a professional. By learning new languages you can pick up bits and pieces from the language and its lifestyle that will make you an more efficient programmer. This discussion got me thinking about my programming background, and the different languages I've used over the years.

My dad works for the army, and through his job I got access to computers at an really early stage. When I was 5 or 6 he used to bring home a couple 8086 Apricot computers from work in the holidays so that me and my sister could play with it. I got into programming when I was 11 or 12, and the first language I used was QBASIC. The main reason was that it shipped with Windows/DOS.

Since I couldn't compile my QBASIC 1.0 programs I soon moved on to Borland Turbo Pascal with Borland Delphi as a natural next step. I remember I could do some really cool networking applications in Delphi by dragging and dropping visual components onto a form. You just dragged a TcpSocket component, set a few properties, and you had a simple chat application. Great times! With the web taking off I got into web development using VBScript and classic ASP and did that for quite some while. After high school I co-founded the company GreIT AS, where we built websites in ASP, and later a full blown content management system in C#. I picked up .NET and C# early 2002, and It was love at first sight.

Even though I consider myself a pretty good .NET developer I constantly try to improve as a programmer. This involves looking outside Visual Studio and see what other developers find interesting and cool. Last fall I took a really cool programming course on functional programming at the university. The course taught me about Scheme (LISP) programming and the beauty of functional programming. Writing Scheme and seeing some of the powerful concepts that arise you can do when the distinction between code and data blurs, and you start passing functions as parameters to other functions, or create code dynamically on the fly was an eye opener.

I doubt I'll ever write Scheme or LISP code in my professional career, but I've already found the concepts I learned useful when learning and understanding C# 3.0 and LINQ. Anders Hejlsberg and his team have introduced several concepts from functional programming in C#, including lambdas. An example of one of the cool things you can do is passing functions as predicates to filter method. In C# 2.0 you can do this using delegates and anonymous methods. In C# 3.0 you can even do this even more elegantly using the new lambda construct (taken from LISP).

The way I can leverage my LISP experience in C# is an example of what I mean by learning a new language and it's lifestyle. If you're interesting in learning more on functional programming and how this applies in C# 3.0 I suggest checking out this excellent Channel9 video with Anders.

Enough about functional languages, let's get back to the dynamic languages. All the buzz around dynamic programming might give you an impression that this is a brand new breed of programming languages. But actually it isn't. The first version of Python was released by Guido van Rossum in 1991, Ruby was released by a Yukihiro "Matz" Matsumoto in 1995, and the concept of dynamic typing go all the way back to the beginning of programming and the LISP language created in 1958.

I think there are a couple of reasons why people are starting to pick up dynamic languages, where one of the major driver is test driven development and unit testing. Much of the criticism of dynamic languages is that you get no "spell checking" from the compiler. You can add strings and integers in your code with out getting a compile time error. Most developer agree that a successful compilation isn't enough to ensure that a program work as intended. Therefore we need unit tests to run our code and do assertions to prove that the program works as expected. Great unit testing frameworks like NUnit and Junit, and even out of the box tool support in Visual Studio Team System, has made it an everyday task to write unit tests. Dynamic languages, such as Ruby, facilitates testing in a great way so when developers are picking up a dynamic language they can apply their unit testing habit to the code they write. This will catch your runtime exceptions and actually prove that the code works as intended.

Another important reason why people are exited about dynamic languages, and Ruby in particular, is productivity. Ruby is easy to write, and more importantly, is easy to read. When we write code we don't write it for the computer (the compiler is the one writing code for the computer), we're writing it for other developers. Expressing developer intend in a clear way is one of the most important things when writing software. How many times have you looked back at code you wrote a couple months ago, scratching your head asking "what the hell does this code do"? Languages like Ruby let's you express your intent in a very clear and crisp way, and with fewer lines of code:

The book "Code Complete" includes a chart on language expressiveness in terms of the statement ratio (lines of code) of a language compared to C.

Language Statements ratio Lines ratio
C 1 1
C++ 2.5 1
Fortran 2.5 .8
Java 2.5 1.5
MS Visual Basic 4.5  ?
Perl 6 6
Smalltalk 6 6.25
Python 6 6.5

Personally I haven't written much Ruby code yet, but I'm currently playing with it and finding it lots of fun and really interesting. With IronRuby and the possibility to run Ruby code on .NET I might even be able to use it for work related projects in a not to distant future. The way I was introduced to Ruby code was actually through an ASP.NET project at work where we used the Watir framework to do functional testing of a web application. Ruby is definitely the next language I'm going to learn.

Which languages have you used, and what is the next language you're learning?

blog comments powered by Disqus