Archive for March 27, 2011

Functional instead of Object Oriented Programming at CMU

Recently, Robert Harper, a Professor of Computer Science at Carnegie Mellon University (CMU) posted about the new introductory CS curriculum at CMU.

Two new courses has been introduced and one more is planned. The first two are about Functional and Imperative Programming respectively. The third one will be a course on Data Structures and Algorithms.

At the same time, Object-Oriented programming is removed from the introductory curriculum, because it is considered both anti-modular and anti-parallel, thus unsuitable for a CS curriculum.

The Standard ML programming language will be used for the Data Structures and Algorithms course. SML was also my first functional programming language while taking the Programming Languages I course during my Diploma. Although it is a “clean” and easy to go language, I would prefer a more inherently parallel language to be used instead. Erlang could be a good candidate!

I vote for this change :-). This shift “against” Object-Oriented programming is a natural one since Parallel Programming is a necessity in the Multi-core era.. An old joke (which is actually stolen from a joke about regular expressions) says:

You have to solve a problem. The problem has certain performance requirements. You decide to use Java and threads.. You have to solve two problems.

Introduction to Erlang : Control Flow

This entry is part 8 of 16 in the series Introduction to Erlang

Control Flow

As we saw in the previous post, pattern matching with different function clauses can be used in order to control the execution flow in Erlang. Erlang also provides the if, case, and receive control flow constructs that can be used in a function body. In this post I will only present the if and casestatements since receive is used for message passing and I will write a dedicated post about the subject. Both if and case are similar to the equivalent statements of other programming languages.

if statement

The format of an if statement in Erlang is the following:

if
    Boolean_Expression1 ->
	If_body1;
    Boolean_Expression2 ->
	If_body2;
    ...
    true ->
	If_body_cath_all
end

So the different clauses, except the last one, are like else if in other languages, while the last one (true ->) is like the else; it succeeds when all the previous clauses have failed.
Read the rest of this entry »