Programming

Introduction to Erlang post series

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

While I was writing my first actual (and extremely delayed :-S) article for the Parallelizing simple algorithms series, I realized that since Erlang is not a popular programming language it would be nice to start an Introduction to Erlang post series. I consider Erlang as a must-know language for an engineer that works with distributed systems and parallel programming. Believe me, in several cases, Erlang is a problem solver!

I will try to keep the posts short and example based. An approximation of the posts that I intend to write is:

  1. Basics: how to get a working Erlang environemt
  2. Basic Types: integers, floats, …
  3. Modules and Compiling: how to write and compile a module
  4. Functions: how to delcare functions
  5. Library Functions & BIFs
  6. Lists: list manipulation
  7. Processes: how to create new processes
  8. Message Passing: how to send messages between processes
  9. Debugging: how to debug Erlang programms
  10. Records: how to use records

I will keep this list updated in case that I come up with new ideas!

I hope I will convince you that Erlang worths every software engineer’s attention..

Parallelizing simple algorithms : Fibonacci

This entry is part 2 of 2 in the series Parallelizing simple algorithms
Fibonacci Blocks

Fibonacci Blocks

It took me a little more than I expected, but finally I managed to write the first post for the Parallelizing simple algorithms series.

As I “promised”, I will start these series by parallelizing the Fibonacci Number sequence generation. As you probably already know, Fibonacci numbers are the integer sequence produced by the following relationship:

   F0 = 0
   F1 = 1
   Fn = Fn-2 + Fn-1

The resulting sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, . . .

Lets start with programming!

Read the rest of this entry »

Netbeans 6.9.1 on Ubuntu 10.10 Installation – OpenJDK problem

I wanted to install Netbeans IDE 6.9.1 (C/C++ version, but I believe that the problem is generic) on my Ubuntu 10.10 laptop, so after downloading the latest version from netbeans.org, I tried to install it:

$ ls -l netbeans-6.9.1-ml-cpp-linux.sh
-rw-r--r-- 1 ** ** 36699136 2011-02-06 00:58 netbeans-6.9.1-ml-cpp-linux.sh
$ chmod +x netbeans-6.9.1-ml-cpp-linux.sh
$ sudo ./netbeans-6.9.1-ml-cpp-linux.sh

and got the following output:

Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...
null

The installation wizard (GUI) did not appear at all.

Luckily, I “immediately” thought “hmm, I re-installed Ubuntu quite recently, did I install JRE?”
So, I checked if I had “Java” installed and checked that everything is “good”:.

$java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)

As you can see, I had OpenJDK installed..
For some reason, which I don’t know, I had already installed the Sun JDK, but not removed the OpenJDK, or at least set the java to point to the Sun version.

So, using synaptic, I unistalled OpenJDK (you can (un)install OpenJDK and Sun JDK from the Software Center also):

$java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)

And then, everything worked fine..

Pointers and Arrays in C

As anyone who had programmed in C knows, pointers can be (also) used to access the data of an array.

From the Wikipedia article about C language:

C supports the use of pointers, a very simple type of reference that records, in effect, the address or location of an object or function in memory. Pointers can be dereferenced to access data stored at the address pointed to, or to invoke a pointed-to function. Pointers can be manipulated using assignment and also pointer arithmetic. The run-time representation of a pointer value is typically a raw memory address (perhaps augmented by an offset-within-word field), but since a pointer’s type includes the type of the thing pointed to, expressions including pointers can be type-checked at compile time. Pointer arithmetic is automatically scaled by the size of the pointed-to data type.


Read the rest of this entry »

Parallelizing simple algorithms series

This entry is part 1 of 2 in the series Parallelizing simple algorithms
Fibonacci Spiral

Fibonacci Spiral

In the following weeks, I will try to write some posts about parallelizing simple algorithms with the Erlang programming language. The main motivation for executing program instructions in parallel is to complete the computation faster than the sequential equivalent solution. As it is used, when someone wants to present the “parallelization power” of a programming language/model, the Fibonacci numbers are used. So, following this conversion, my first post will be about parallelizing the calculation of the Fibonacci integer sequence.
Read the rest of this entry »