Compiling

Local Programming

When you think about it, using compilers online can be not so useful. It's good for testing some small pieces of code and show you its effects in a web format. But that's mostly it.

To really program and use multiple libraries and your own packages, you may want to use a local system to your computer.

This is obtained with a text editor, such as atom, and a compiler.

The free compiler GNAT (GNU New York University Ada Translator) is available online.

Fortunately, Ada comes preinstalled in many Linux Systems. If you are not that lucky, or you don't even know Linux exist (check it out! It's full of penguins!) you can install it really easily.

You may consider using GPS, a programming system for GNAT.

Windows

Download and install GNAT from the web.

The program must finish with the extension .adb

program.adb

To compile and link the program you can call from the console

gnatmake program.adb

The executable file will be saved with the extension .exe

You can execute with:

./program.exe

or you can launch both in order as follows

gnatmake program.adb && ./program.exe

all in one line. && means the right side will only execute if the left side went without error.

Linux

To install GNAT you open a command window and put the next command:

  • sudo apt-get install gnat

The program must finish with the extension .adb

program.adb

To compile and link the program you can call:

gnatmake program.adb

Or you can call:

gnatmake program

The executable file will be saved without extension. You can execute with:

./program

Apple

Download the Mac OS X compiler for your version of OS X from MacAda.org.

Open the disk image and run the package installer.

Download the Carbon bindings for your version of OS X from MacAda.org

Open the disk image and run the package installer.

The rest is just like for Linux console..

Compilation issues

The compiler has certain feedback messages that will help you make your code be correct at doing it's purpose. It can be from "Hey, you are not using this variable you declared" to "Well, this is πŸƒπŸ’©"

They compiler will tell you where and what the mistake is, or where and what he thinks it is.

Errors

🚨 The code contains something illegal and will not compile.

Warnings

⚠️ A program with warnings is legal, and will compile, but it may need revision.

Guaranteed

It's remarkable, and therefor I'm going to remark it, that "Ada" is trade marketed and standardized, so the Ada Joint Program Office has to approve any compiler to be Validated Ada.

This means to us that every program will work the same (or with minimal difference) in any system that can run it.

The AJPO has been the most successful group to avoid proliferation of dialects of a programming language. Just notice that when people say C, they refer to the C-family languages and include C++ and C#, even Java, and contextually, Python. That's crazy!

Modulation

Each program unit normally consists of two parts: a specification, containing the information that must be visible to other units, and a body, containing the implementation details, which need not be visible to other units. Most program units can be compiled separately.

This distinction of the specification and body, and the ability to compile units separately, allows a program to be designed, written, and tested as a set of largely independent software components.

About Gnat

GNAT started as Software Libre (Free as in freedom, not as in free beer).

Since the original development, AdaCore has commercialized a PRO version of it, and takes care of the updates to the libre version.

They also produce other tools and courses... wait, why am I doing free publicity???

Just know who to send complains if you find a problem with Ada you think someone should take care of.

Also if they want to hire me, I'm already living in Paris, and I accept patrons. So... call me!