Learning Ada Language

Programonauta
2 min readJun 18, 2019

--

Leia esse artigo em português aqui

It’s Never Too Late to Start

This month I decided start my study in Ada Language. I work with embedded computers a long time (almost 30 years) and since the beginning using basically C.

About 5 years ago I started use C++ and in 2017 I did my first project using Python, running in a Raspberry Pi board.

But I always heard about the advantages of Ada Language. And finally I decided go deeply.

The first steps are being very hard. I need to change my mind set, forged for years working with C, where you have a great flexibility to deal with variables, pointers, structures, and arrays.

But what is very interesting, reading some tutorials, I remember some very big problems that I faced during my experience with C. A lot of nights without sleep, concerns, headaches, and some times was that little pointer I didn’t take care with it. A buffer overflow that was very difficult to detect, a missing cast that destroy the variable beside you are accessing. Who works with C and C++ knows exactly what I’m talking about.

How to start

GNAT is the ada compiler, and I suggest install GPS (GNAT Programming Studio) an IDE with a lot of great features.

You can download a Community Version in the Ada Core site.

Tutorials

As soon as you install GPS, you can find a tutorial that explain the features of GPS. It’s a very good tutorial, but if you don’t know Ada, I suggest get familiar with it first.

You can find some tutorials in the internet, but I suggest follow this tutorial on Learn Adacore.com.

If you are a C++ or Java programmer, I also suggest read this: Ada For CPP and Java Developer.

Hello World!

As usual, let’s start with a Hello World program. For now, it’s not necessary use GPS, you can run it from command line.

First, update the PATH environment variable with directory where GPS was installed followed by \bin.

In my case (Windows 10), D:\GNAT\2019\bin

Verify if gcc is pointed to this directory:

where gcc
D:\GNAT\2019\bin\gcc.exe

Create a file named HelloWorld.adb:

with Ada.Text_IO;
use Ada.Text_IO;
procedure HelloWorld is
begin
Put_Line ("Hello World!");
end Main;

To compile use gprbuild

>gprbuild HelloWorld.adb
using project file D:\GNAT\2019\share\gpr\_default.gpr
Compile
[Ada] helloworld.adb
Bind
[gprbind] helloworld.bexch
[Ada] helloworld.ali
Link
[link] helloworld.adb

Now, it’s just run your new Ada HelloWorld project!

>helloworld
Hello World!

Conclusion

I know it will be a very excited journey, and I will share with you every step here.

Every new post I will create a link here

--

--

Programonauta

Engenheiro de Computação e um apaixonado por tecnologia. Atualmente procurando as conexões entre blockchain, IoT e Inteligência Artificial.