codethinked (kōdthĭngked) adj. To be consumed by or obsessed with code.

Learning Scala via C# Part 3 – Getting Loopy

Welcome back! In the last part of this series we took a quick look at how you declare immutable variables, then looked at the “everything is an object” features of Scala, and now we are going to jump back into some simple variable declarations, but this time we are going to look at creating mutable variables.

Mutable Variables

You might be wondering why we didn’t just go ahead and jump straight into mutable variables after discussing immutable variables, and the reason is that I wanted to give you a bit of advice before introducing them. Basically, Scala takes the stance that most things should be immutable and the developer should really only fall back to mutable objects when it makes sense from a complexity or performance standpoint.

Continue reading the rest of this post...

Learning Scala via C# Part 2 – The Basics

In the last part of this series we talked a little bit about Scala and why I think it is an interesting language. We also spent a good amount of time getting the boring work out of the way of setting up an environment for us to work in. We are not going to start off with the IDE though. The reason for this is that it is much easier for us to start to get our bearings within Scala by using Scala’s REPL (Read Evaluate Print Loop).

If you have come from C# or Java then it is quite possible that you have never even used a REPL before, and in fact, it is fairly uncommon for a static compiled language to have a REPL. If you have any experience with dynamic languages though, then you are probably intimately familiar with the concept. The idea is that you will enter in statements and they will be dynamically evaluated and the results printed to the screen. This may sound strange and useless at first, until you realize that you can enter multiple commands and they are all loaded up into the same environment. You can load files and libraries and do all of the things you would do in a normal development environment, but in a more interactive fashion.

Continue reading the rest of this post...

Learning Scala via C# Part 1 – What Is Scala?

There are new languages that come about all of the time. Lately it seems that most of the languages du jour are dynamic or functional languages. We have all seen a lot of talk about languages such as Ruby, Python, F#, Groovy, Erlang, and Clojure. All of these languages represent a huge shift in programming paradigm from many of the current “corporate” languages such as C# and Java. They also all represent a significant syntactical difference from these languages.

What is Scala?

Scala on the other hand is a little bit different. From a syntax point of view, it is quite similar to both C# and Java. From a paradigm perspective it does represent a shift, but at the same time it allows for a style of development that will be quite familiar to any C# or Java developer. In fact, Scala was designed to run on the JVM and it even shares its type system with Java (although it adds namespaces of its own) so that it can easily interoperate. A version of Scala has been developed to run on the .NET platform, although the development effort is a bit behind the JVM version (from what I have heard though, Microsoft has provided a grant to help development of the .NET port, if anyone has any more information on this, please let me know).

Continue reading the rest of this post...