Ada (programming language) facts for kids
![]() |
|
Paradigm | Multi-paradigm: structured, imperative, object-oriented, aspect-oriented, concurrent, array, distributed, generic, procedural, meta |
---|---|
Family | Pascal |
Designed by |
|
First appeared | February 1980 |
Stable release |
Ada 2022 / May 2023
|
Typing discipline | static, strong, safe, nominal |
OS | Multi- or cross-platform |
Filename extensions | .adb, .ads |
Major implementations | |
AdaCore GNAT, Green Hills Software Optimising Ada 95 compiler, PTC ApexAda and ObjectAda, MapuSoft Ada-C/C++ changer, formerly known as "AdaMagic with C Intermediate", DDC-I Score |
|
Dialects | |
SPARK, Ravenscar profile | |
Influenced by | |
ALGOL 68, Pascal, Simula 67, C++ (Ada 95), Smalltalk (Ada 95), Modula-2 (Ada 95) Java (Ada 2005), Eiffel (Ada 2012) | |
Influenced | |
C++, Chapel, Drago, D, Eiffel, Griffin, Java, Nim, ParaSail, PL/SQL, PL/pgSQL, Python, Ruby, Seed7, SPARforte, Sparkel, SQL/PSM, VHDL | |
|
Ada is a special programming language that helps computers understand instructions. It's like a very detailed recipe language for computers. Ada was created to be super reliable and safe, especially for important systems where mistakes could be dangerous. Think of things like airplanes or train controls!
This language was named after Ada Lovelace, who is known as the first computer programmer. She lived a long time ago, from 1815 to 1852. Ada is designed to catch errors early, even before a program runs. This makes the software much safer and easier to fix. It's an international standard, meaning it's recognized and used all over the world. The newest version is called Ada 2022.
Contents
What Makes Ada Special?
Ada was first made for embedded systems and real-time systems. These are computer systems that are part of a larger machine and need to respond very quickly. For example, the computer in a car's engine or a robot. Later versions, like Ada 95, added more features for things like object-oriented programming (OOP). This helps programmers organize their code better, like building with LEGO bricks.
Key Features of Ada
Ada has many cool features that make it strong and reliable:
- Strong Typing: This means you have to be very clear about what kind of data you are using. It's like saying "this box is only for numbers" or "this box is only for words." This helps prevent mistakes.
- Modular Programming: Ada lets you break your program into smaller, organized parts called "packages." This makes big projects easier to manage.
- Checking for Errors: Ada checks for errors while the program is running. It also helps find problems before the program even starts.
- Parallel Processing: Ada can handle many tasks at the same time. This is important for systems that need to do a lot of things quickly, like air traffic control.
- Handling Problems: If something unexpected happens, Ada has ways to deal with it so the program doesn't crash.
- Generics: This allows you to write flexible code that can work with different types of data without rewriting it.
How Ada Code Looks
Ada's way of writing code is designed to be clear and easy to read. It uses English words instead of lots of symbols. For example, it uses `or else` and `and then` instead of `||` and `&&`.
Code blocks in Ada start with words like `declare`, `begin`, and `end`. The `end` keyword usually tells you what kind of block is finishing, like `end if` or `end loop`. This helps prevent common mistakes found in other languages.
Finding Bugs Early
Ada is great for building very large software systems. Its "packages" can be compiled (turned into computer instructions) separately. This means you can check parts of your program for problems even before you finish writing all of it. This helps catch bugs much earlier in the process.
Ada also has many checks that happen when you compile the code. This helps stop common software errors like using the wrong type of data or trying to access memory that isn't there. Because Ada is designed this way, it's often used in systems where safety is super important. Imagine software for airplanes, trains, or even banking systems! A small mistake in these systems could have serious consequences.
Memory Management
Ada handles computer memory in a very organized and safe way. It doesn't use "pointers" in the same way some other languages do. Instead, it uses "access types" to manage memory. This helps prevent common errors like trying to use memory that has already been given back to the system.
Most Ada systems don't automatically clean up unused memory (called "garbage collection"). This is because in real-time systems, you need to know exactly when things happen, and automatic cleanup can be unpredictable.
Comments and Semicolons
In Ada, you can add notes to your code using two dashes (`--`). These notes are called comments and help explain what your code does. They stop at the end of the line.
Every instruction in Ada usually ends with a semicolon (`;`). It's like the period at the end of a sentence.
Ada's Manuals and Tools
The official definition of the Ada language, called the Ada Reference Manual (ARM), is free to access. This means programmers can easily look up how the language works. There's also a "rationale document" that explains why the language was designed the way it was.
Many Ada programmers use a free tool called GNAT Programming Studio and the GNAT compiler. These tools help them write and test their Ada code. There's also a tool called Alire that helps manage Ada projects.
A Look Back: Ada's History
In the 1970s, the US Department of Defense (DoD) had a problem. They were using hundreds of different programming languages for their computer systems, and many were old or hard to use. They wanted one main language that was safe and easy to update.
So, they created a group to find or create this new language. They wrote down a list of requirements for what the language needed to do. This list was called the "Steelman language requirements." They looked at many existing languages but found that none of them were quite right.
The Contest to Create Ada
Because no existing language fit the bill, the DoD held a contest to design a new one. Four teams worked on proposals. In 1979, the design by Jean Ichbiah and his team at Honeywell was chosen. They named it Ada, after Ada Lovelace.
The first official version of Ada was approved in 1980. At first, it was a bit tricky for computer programs (compilers) to handle Ada because it was so big and complex. But over time, compilers got much better.
For a while, the US Department of Defense even required all their new software to be written in Ada. This rule was later removed, but Ada continued to be used in many important areas.
Where Ada is Used Today
Because Ada is so good at safety and reliability, it's used in many critical systems beyond just military projects. You can find Ada in:
- Airplanes: Like the Boeing 777 and Eurofighter Typhoon, where it controls the "fly-by-wire" systems.
- Air Traffic Control: Helping manage planes in the sky.
- Rockets and Satellites: Such as the Ariane rockets.
- Railways: Controlling high-speed trains and metro systems in big cities like Paris, London, and New York.
- Banking: For secure financial systems.
The Ada 95 version of the language added features for object-oriented programming, making it even more useful for general computer systems, not just embedded ones.
How Ada Became a Standard
Year | Informal name | Official Standard |
---|---|---|
1980 | Ada | ANSI MIL-STD 1815 |
1983 | Ada 83/87 | ANSI MIL-STD 1815A ISO/IEC 8652:1987 |
1995 | Ada 95 | ISO/IEC 8652:1995 |
2007 | Ada 2005 | ISO/IEC 8652:1995/Amd 1:2007 |
2012 | Ada 2012 | ISO/IEC 8652:2012 |
2023 | Ada 2022 | ISO/IEC 8652:2023 |
Ada became an ANSI standard in 1980. After some fixes, it became an ISO standard in 1987. This version is often called Ada 83 or Ada 87.
Then came Ada 95 in 1995, which was the first ISO standard for an object-oriented programming language. This was a big step!
Work continued, and new versions were released:
- Ada 2005 was published in 2007.
- Ada 2012 came out in December 2012.
- The very latest version, Ada 2022, was officially approved in May 2023.
Even though there are different names like Ada 83 or Ada 95, legally there's only one official Ada standard: the most recent ISO/IEC version. The older versions are simply replaced by the newer ones.
Building Blocks of Ada
Ada is a structured programming language. This means it uses clear, organized ways to control how a program runs. It has special words like `if`, `then`, `else`, `while`, and `for` to guide the computer. Ada also has ways to define different types of data, like numbers, words, or lists. These ideas were inspired by languages like Pascal.
"Hello, world!" in Ada
A classic first program in any language is "Hello, world!". Here's how it looks in Ada:
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line ("Hello, world!");
end Hello;
This simple program tells the computer to print the words "Hello, world!" on the screen. You can use a free compiler called GNAT to turn this code into a program the computer can run.
Data Types in Ada
Ada lets you create your own types of data. Instead of just using basic types like "number," you can describe what the data is for. For example, you can define a type for "Day" that only allows numbers from 1 to 31. This helps the computer find mistakes if you try to use a wrong number.
Here's an example of defining types for a date:
type Day_type is range 1 .. 31; -- A day can be from 1 to 31
type Month_type is range 1 .. 12; -- A month can be from 1 to 12
type Year_type is range 1800 .. 2100; -- A year can be from 1800 to 2100
type Hours is mod 24; -- Hours from 0 to 23
type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); -- Days of the week
type Date is
record
Day : Day_type;
Month : Month_type;
Year : Year_type;
end record;
In Ada, if you have a `Day_type` and a `Month_type`, you can't just add them together. Ada is very strict about types to prevent errors.
You can also make "subtypes" which are like specific versions of a type:
subtype Working_Hours is Hours range 0 .. 12; -- Working hours are from 0 to 12
subtype Working_Day is Weekday range Monday .. Friday; -- Working days are Monday to Friday
How Ada Controls Programs
Ada uses standard ways to control the flow of a program. This makes the code easy to follow. Here are some examples:
- While Loop: Keeps doing something as long as a condition is true.
-- while a is not equal to b, loop.
while a /= b loop
Ada.Text_IO.Put_Line ("Waiting");
end loop;
- If-Then-Else: Does one thing if a condition is true, and another if it's false.
if a > b then
Ada.Text_IO.Put_Line ("Condition met");
else
Ada.Text_IO.Put_Line ("Condition not met");
end if;
- For Loop: Repeats something a certain number of times.
for i in 1 .. 10 loop
Ada.Text_IO.Put ("Iteration: ");
Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line;
end loop;
- Loop with Exit: Keeps looping until a specific condition is met to exit.
loop
a := a + 1;
exit when a = 10;
end loop;
- Case Statement: Chooses what to do based on different values.
case i is
when 0 => Ada.Text_IO.Put ("zero");
when 1 => Ada.Text_IO.Put ("one");
when 2 => Ada.Text_IO.Put ("two");
-- case statements have to cover all possible cases:
when others => Ada.Text_IO.Put ("none of the above");
end case;
Packages, Procedures, and Functions
Ada programs are built using "packages," "procedures," and "functions."
- Functions are like mini-programs that calculate something and give you a result.
- Procedures are like mini-programs that do a task but don't necessarily give back a result.
- Packages are like folders that hold related procedures, functions, and data types.
These parts can be nested inside each other, helping to keep the code organized.
Pragmas
A "pragma" is a special instruction you give to the Ada compiler. It tells the compiler how to handle certain parts of your code. For example, you might use a pragma to tell the compiler to make your code run faster by turning off some checks, but this is usually only done when you are sure your code is perfect.
Generics
Ada has "generics," which are like blueprints for creating code that can work with different types of data. This means you can write a piece of code once, and then use it for numbers, words, or other data types without having to rewrite it every time. It saves a lot of work!
See also
In Spanish: Ada (lenguaje de programación) para niños