Eigenaar van een windmolen

Vanaf begin volgend jaar ben ik eigenaar van een windmolen! Nouja, mede-eigenaar met nog 1700 anderen. Via de windcentrale hebben we geld ingelegd om de aanschaf van een windmolen bij Culemborg te financieren. Deze molen moet de komende 12 jaar ongeveer 75% van mijn stroomverbruik gaan opwekken en misschien wel meer dan dat als het goed hard waait en dat wil het in ons land wel doen.
Continue reading Eigenaar van een windmolen

Ada: A strict language

A first encounter with Ada takes Adame back with programming a few years because there are a lot new or slightly different concepts compared to Java or PHP. So simply creating a program and trying to run will often end in an error from the compiler. Understanding why these error occur are key in understanding the design of Ada and why it is so strict in a lot of ways. The first two problems I encountered when starting with Ada are the following. Continue reading Ada: A strict language

Ada: Hello world

Learning a new language always start with the famous words “Hello world”. This article will show how creating a “hello world” application is done in Ada.

First you should make sure the free Ada compiler is installed, check if the command gnatmake is available. When it is not you should install it with apt-get install gnats on Linux. This compiler is provided as open source by the GNAT Pro company that also provide the Pro version for mission critical support.
Start with a file and name it test.adb, .adb is the default Ada file suffix.

with Ada.Text_IO;
use Ada.Text_IO;

procedure test is
   Put_Line("Hello world");
end test;

Now compile the file to an executable with the command gnatmake:

$ gnatmake test.adb
gcc-4.6 -c test.adb
gnatbind -x test.ali
gnatlink test.ali

The executable file test should be compiled and in the current directory. To try the program execute this file with ./test.

$ ./test
Hello world

So that’s it! A real simple but working program in Ada. Below is a short description about the different lines of code and what they do and mean:

  • Row 1 and 2, In Ada you should define which packages you want to compile within the executable and which package you want to use within the scope. The use Ada.Text_IO could be ommitted but then row 6 should be prefixed with Ada.Text_IO to make clear from which package the Put_Line is coming.
  • Row 4,5 and 7, We define the procedure test and include a begin/end block. A procedure can be compared with a function but does not return any value. A procedure does more but that will be covered in another article.
  • Row 6, Put_Line outputs the string to the console. This procedure is defined in the package Ada.Text_IO.