Skip to content

From Compiled Procedural Strongly Typed to Interpreted Weakly Semi-Functional (Part 1)

Last updated on 2014-09-07

The first language in which I programmed real systems was Ada (Ada83 to be exact). Ada was developed by the US DoD and was originally targeted for embedded and real-time systems – think your typical airplane’s computer.

ada-strong-305-color

Ada is a REALLY strongly typed language. For example, if you want an array of fruits, you would do something like this:

type Fruit_Type is (APPLE, ORANGE, BANANA);
type Fruit_Array_Type is array (Positive range <>) of Fruit

My_Fruits : Fruit_Array_Type(1..5);
My_Fruits(1) := APPLE;

Yea, those are a lot of rows, right? But it is strongly typed, so there is no way that you can assign something that is not of Fruit_Type to the array, and if you try to do this, the compiler will scream at you. You can also create arrays where the index is of a newly defined type. For example:

type Number_Of_Fruits_Type is array (Fruit_Type) of Natural;

Number_Of_Fruits : Number_Of_Fruits_Type := (other => 0);
Number_Of_Fruits(APPLE) := 5;

Pretty cool, isn’t it? but the problem is that with time people start abusing the type system and the code becomes impossible to manage. We had in our code 5 different types for one concept: one for incoming data (when accepting from external systems), one to pack the data from the receiving service into the processing service, one type when saving to the database, one for the display, and another one for sending to external systems. Just writing the type translations was a possible source of bugs. And while static typing does remove some small stupid bugs, there are still logic bugs that can never be caught by the compiler.

Don’t get me wrong – using Ada we developed an incredible parallel, mission-critical system that had thousands of lines of code, very complex logic, and great user satisfaction. But Ada didn’t become the language of the future, and currently it is used mostly for maintenance of legacy systems, and for the development of real-time safety-critical systems where the static properties of the languages are definitely worth their cost.

After Ada, the next language in which I programmed professionally was Java. But this post is getting long, so I stop here and make this a series of posts. So as always, happy coding.

Enhanced by Zemanta
Published inProgramming

Be First to Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.