Monday, June 27, 2011

Concepts of programming languages

I'm quite busy with many things lately (too many things if I'm quite honest), but it's a good thing to point out that I'm still alive :-).

The last couple of months I was also a teaching assistant for the new edition of TU Delft's 'Concepts of programming languages' course, given by my supervisor Eelco Visser. In this course, students learn a couple of new programming languages, which are conceptually different compared to the first programming language they have learned at TU Delft (which is Java). The programming languages covered in this course are:

Scala, a multi-paradigm programming language integrating object oriented and functional programming language features. In this course, students use this language to discover functional programming, functional objects, traits and pattern matching.

The C programming language is used to teach students low-level principles, such as pointers and stack and heap based memory allocation.

JavaScript, is used as a different object oriented language which uses prototypes instead of classes for inheritance. Moreover, students also explore the underlying structure of objects in JavaScript, which are represented as associative arrays with prototypes.

Except for learning new programming languages using different concepts, the lab assignments are about programming languages themselves. A simple lambda calculus based language (which itself is a way to demonstrate programming language fundamentals) is used as a case study for the exercises.

In the final exercises of the lab, students have to implement a evaluator for the lambda calculus language in Scala, "translate" an object oriented Java program into a C program using structs and dispatch tables for virtual method lookup and they have to port the lambda calculus evaluator to JavaScript, which can be invoked through a web page in a web browser.

During my period as a PhD student I have had many discussions about programming languages, with colleagues and peers during conferences. One of the things I have discussed the most, is what language students should learn in the introduction programming language course.

Some peers from a German university, wanted students to learn C# instead of Java, which is normally taught at their university (because C# is the programming language they used for their research projects and they argued that they wouldn't attract any master students because they were not familiar with it). I also had discussions with peers about using a minimalistic programming language such as Lisp, because these languages are less complicated.

In my opinion, it doesn't matter that much what programming language is chosen as introduction. I think it's probably a better idea to pick a mainstream language, which is not to complicated than a complex language that nobody uses.

The way I see it, the main purpose of the introduction programming courses is to teach people dealing with complexity. To achieve that goal, they need to understand a programming language and they have to learn to divide a big problem into smaller sub problems and translate those to concepts which can be implemented in that language.

Moreover, I also find it important that software engineers are flexible regarding to programming languages, for the following reasons:

Once students start working in a software engineering project (e.g. for industry), they may have to use a programming language they are not familiar to.

No programming language is perfect for every job. By studying multiple programming languages you can make decisions about what language is the best solution for a particular task. For instance, for web programming JavaScript is in many cases a good choice, and for embedded systems programming C may be a better choice.

There are many factors influencing a programming language choice, such as maintenance, portability (of the language itself and the underlying platform) and efficiency.

By studying multiple programming language concepts, it become easier to learn other languages. Programming languages have differences, but also many similarities (e.g. compare the syntax of C, C++, Java and JavaScript or the structure of if-statements). Furthermore, languages also adopt concepts from each other, e.g. closures.

You may have to develop a programming language or domain specific language (DSL) yourself. For these tasks, knowledge about language concepts is crucial.

For all the reasons mentioned above, I think that having a 'Concepts of programming languages' course is essential for a software engineer and also "solves" the problem of thinking about what language is crucial for a student to learn. You have to make them familiar with multiple concepts.