Clearing up Myths about Ada
pyjarrett.github.io
pyjarrett.github.io
There are still 7 companies around selling Ada compilers, granted not all of them support the very latest standard.
https://www.ghs.com/products/ada_optimizing_compilers.html
https://www.ptc.com/en/products/developer-tools/apexada
https://www.ddci.com/products_score/
http://www.irvine.com/tech.html
And it seems you overlooked the article. Anyone coming to the comments after reading the article can be forgiven for being confused by the reversal that happened here.
Here's one unusual example, a BSD package manager written in Ada: https://github.com/jrmarino/synth
1. It was designed by committee.
According to Wikipedia, it was designed by a small team at Honeywell Bull in France. A different connotation from the label 'committee'. What is the more accurate description? It may seem unimportant, but most programming languages are designed by one or two individuals and the word 'committee' is perceived negatively by many developers. (Aside: Julia was designed by multiple authors, but no-one says the language was designed by committee.)
2. Ada is a very large language. Not suitable for small projects.
This belief about the size of the language is true, but the question is: does it matter? I prefer small languages over larger ones, but I would be interested in the opinions of Ada developers. Is the language size irrelevant? And is Ada suitable for projects of any size?
Except we are now in 2021 and while Ada 2012 has naturally gained on features, since 1983 there are other ecosystems that grew beyond what is available in Ada, like my list above.
You don't have to use the entirety of the language, you can use pragma Restrictions to get the compiler to ensure you don't use certain features. Some features don't even work for really tiny devices. Even tasking can be done one small systems, like a Z80, for example.
Importantly though, Ada is much more coherent (and less timtowtdi) than say C++ so as you do start bringing in more of the language into your codebase the "every one uses a different 10% of the language" problem of C++ isn't much of a problem for Ada.
Ada is a name, not an abbreviation. It should be written "Ada" and not "ADA".
---
Keywords in Ada should be written in lower case letters:
It is a common misconceptions that Ada enforces or encourages upper case, but here is the official Ada 83 Language Reference Manual on the subject: http://archive.adaic.com/standards/83lrm/html/lrm-02-09.html... > Reserved words differing only in the use of corresponding upper and lower case letters are considered as the same (see 2.3).
The manual itself doesn't even use upper case:
> For readability of this manual, the reserved words appear in lower case boldface.
So even the Ada standard recognizes the upper case is less readable and undesired.
To me, the destructor is the single most distinctive and powerful feature of C++, adopting it is what made Rust viable, and lacking it makes Zig overwhelmingly less interesting than it might have been. If Ada got destructors, that would promote the language, in my view, from dead to potentially viable.
If not, how predictable is it?
[1] https://stackoverflow.com/questions/67131931/does-ada-deallo...
Any variable declared as controlled type will have their "destructor" called just like C++, and that is what matters.
Like like RAII doesn't do anything, if the type is heap allocated and due to a bug not deleted or freed(), and someone has to write the destructor code, just like someone has to write the controlled type.
Does Ada come with optional garbage collection, at least? Memory leaks are a big safety concern, perhaps the biggest in practical code, and IIRC Ada still doesn't have GC "by default" for some unimaginable reason.
Additionally Ada controls many types directly like strings and vectors, and storage pools.
I recommend the FOSDEM talk about Ada memory management.
{
raii_handle *my_type = new raii_handle(new type);
....
} /// ooops
Naturally it doesn't happen just like that, rather in 500 lines of code function in code that has already been through 10 contracting agencies, including some offshored ones. {
auto p =
std::make_unique<type>;
...
} /// no oops. {
auto p =
new std::make_unique<type>;
...
} /// oops again.
The fact being the "reliability" is a good as the hundreds of developers that touched the code.Real reliabile features don't depend on their skills to actually work 100% of the time, and doing something like newing a RAII type would be a compiler error, but alas it isn't.
What matters is whether it is easier to write crap that compiles than correct code, and whether the easiest sort of crap compiles. That is where there has been progress. If you never, ever need to write "new" anymore, why would you accidentally write it?
The BS example above does not, in fact, compile, because make_unique<> is not a type. So, it illustrates the progress I cite.
One thing Ada was designed for and C++ not, was to prevent crappy developers to mess up.
Anyone that has reviewed C++ code from offshoring Asian companies is well aware of what I mean.
Bad code from dodgy, offshore outsourcing services may be in any language. Bad Ada code is no better than bad code in any other language. Bad Ada code could be worse if it often works by accident, where other code might have failed visibly and been rejected.
Ada's strictness allows it to catch many more errors at compile time than, say, C.
> Bad Ada code could be worse if it often works by accident, where other code might have failed visibly and been rejected.
This is backward. Errors will be more easily detected in Ada than in, say, C. C is full of footguns and undefined behaviour. Vanilla Ada still isn't actually a safe language, unfortunately, but as a matter of degree, it's much safer than C.
You might consider that example stupid and argue no one would ever write code like that.
To which I would answer you haven't reviewed enough offshored C++ projects.
That is the opposite of automation: everywhere you need cleanup, you have to repeat the incantation, and get it right, again, every time. The point of destructors is that they are wholly contained in the library. It takes no extra client code to run them, and they are exercised identically on every single use of the type, so are well tested. Identically the same code runs on a throw, so there is much less risk from usually poorly exercised failure cases.
I wonder now whether Ada auto-generates destructors for types with a member that defines one. And whether its standard library is such as to make a need to code them yourself vanishingly rare.
The fact that many still think it only came with C++11 or whatever "modern C++" is where the problem lies.
Borland and Microsoft ruled the compilers party in the Iberian Penisula during those days. :)
Ada's syntax makes differentiating variables/arrays from functions unnecessarily difficult. This is because parentheses are used for both function calls and array accesses. And function calls without parameters do not require parentheses at all.
Lets play a game. See if you can figure out which is a variable, array, or function.
A := B;
C := D;
E := F(G);
H := I(J);
A, B, C, E, H, and J are variables. F is an array. D, G, and I are functions.The only way to really tell what's what in many cases is to look up definitions. That would be fine... except there is very little competition for Ada IDEs. I use AdaCore's GNAT Pro Studio (GPS), but the interface is clunky and often very slow compared to modern JetBrains IDEs.
This syntax issue is a constant frustration and it's something which could have very easily been avoided.
comp.lang.ada, reddit.com/r/ada, irc, gitter, telegram, etc.
> A, B, C, E, H, and J are variables. F is an array. D, G, and I are functions.
That was by design, because when it was designed, ide's like we have now didn't exist so being able to change a variable to an array from a function or vice versa was made easier. There is another reason and that mathematically an array is a function.
Yeah, but I don't want to join a community just to make a single complaint about a 40 year old language.
> That was by design, because when it was designed, ide's like we have now didn't exist so being able to change a variable to an array from a function or vice versa was made easier.
What a bizarre decision for a language built around such a strict and elaborate type system. I'd consider it being difficult to swap functions and variables to be a feature.
If anything, I'd say that the missed opportunity was to make arrays compatible with function access types.
Ok, so if I download the GNAT Community Edition from Adacore, how I do switch GPS to use the FSF GNAT tool chain? How about the static analysis tools? Windows and Linux?
Everytime I look at Ada, I want to start doing a project with it. What a wonderful tool.
> Ok, so if I download the GNAT Community Edition from Adacore, how I do switch GPS to use the FSF GNAT tool chain?
Toolchains are customizable within GNAT Studio. If you use `alr edit` your Alire-configured toolchain should be selected. I would check to be sure. I don't work on Alire, but that work last time I tried. (I've been using Visual Studio Code lately as my editor)
> Windows and Linux?
I've built and run several projects on Windows and Linux without a problem.
https://github.com/alire-project/alire/blob/release/1.1/doc/...
So you have a workflow similar to cargo in Rust:
* Install package manager * Let package manager install toolchains * ??? * Profit
I think both Airbus and Boeing have been doing their best to demonstrate the limitations of Ada and Spark.
I am not very familiar with it (have published 1 small library and 1 PR to a large, popular framework), but when learning the language after having written most other things it felt like it had the most footguns and number of random rules you had to memorize + instances of undefined behavior.
I've never published anything with Ada (mostly because almost nobody uses it, so I've not had the same practical usecases) but I do follow the language passively and have experimented with it.
I feel much more comfortable that I could write a correct Ada program than a correct C++ program. I think I could write C++ for 5 years and not feel sure my program is entirely correct, even with IE "cppcheck", "clang-static-analyzer", "ASAN/TSAN/UBSAN" etc.
First, contracts are step one: they enable additional tools that can do static formal proofs using those contracts. It is impossible to prove anything about code that has a buffer overlow. In theory we have can write those tools without contracts, but the runtime for anything more than helloworld is unacceptable so nobody has even written them, contracts are believed to help bring that under control.
second, I assume only the latest modern C++ is used. I expect tools to give up as soon as they see constructs that are hard to analyze. (new/delete is obvious - but they reserve the right to add more constraints)
Third, modern C++ if you stick to only that is a lot easier to write safe code than C++98. Things are getting better - or where they are not we can treat them like rust treats unsafe - sometimes you need to do tricky things that tools can work with: isolate them to only those areas, have your best write the code, test it hard, and pray they work.
Fourth, conductive to bug free development is relative. I won't claim C++ will be the most conductive to bug free code. Part of that is intentional: C++ aims to be useful in places where you are willing to make trade offs - if you are not willing to trade at least some productivity for runtime speed C++ is not the right language for you.
Note the last: I never claimed it will be better than Ada/Rust/whatever. I have no experience with either, but tend to believe those who claim they are more productive.
I maintain a lot of C++, which interoperates with other C++: adding another language is probably lower productivity than writing more C++ in the long run just because those interfaces between languages tend to be where things are the hardest. So I'm taking a different approach: getting involved with the C++ standard to attempt to make it more productive.
> So I'm taking a different approach: getting involved with the C++ standard to attempt to make it more productive.
This is fantastic -- kudos to you!"Why should I learn Ada if I am not programming AIM-9X heatseeking missiles in my day to day job?"
Because it changes the way you think about programming. Taking about Lisp, Eric Raymond said:
"Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot." Ada provides a different kind of enlightenment than Lisp:
1) Ada has a powerful type system that lets you define exactly what values are allowed and how they should work:
https://learn.adacore.com/courses/intro-to-ada/chapters/stro...
https://learn.adacore.com/courses/intro-to-ada/chapters/more...
2) Ada has built-in concurrency primitives that very simple to understand and use:
https://learn.adacore.com/courses/intro-to-ada/chapters/task...
3) Ada supports design-by-contract programming to precisely define the semantics between different parts of your code. Design-by-contract is ideal for large codebases and helps to catch errors similar to unit tests, but within the code itself:
https://learn.adacore.com/courses/intro-to-ada/chapters/cont...
Even if you aren't writing code for heatseeking missiles, learning about Ada can make you a better programmer.
I guess it's more use in the contexts where Ada is normally found.
It isn’t really an “attempt” either. The language exists and is used and has developed as experience was gained. Why bother with it? Because you could maybe learn something new despite it being old.
I'd like to give it a try again as an experienced programmer and see how the language has evolved over time.
I think I was lucky to go and work for a company where I got to do both Ada (specifically SPARK) and Prolog in a professional capacity. It wasn't until I used them "for real" that I really appreciated the benefits of both when used for what they were designed for.
Sadly Ada has a bad rep, in part I think because it was mandated on so many terrible death-march defence projects. It seems to be having a minor renaissance, with people like Nvidia using Ada 2012 and SPARK to code their Risc-v security chip.
As a beginner language I recall it being quite nice compared to C.
Eventually, they switched to Java who became popular around that time.
As a web dev looking to deep dive on some non-web topic with the pragmatic constraint that it must be a hireable one, Ada seems promising but I wouldn't know where to start looking for jobs.
In short, C & C++ took over. SpaceX surprisingly used a LOT of LabVIEW in their mission control.
I come across a lot medical device startups/contracts who could be a really great fit for an embedded application in Ada but who will not have the budget for Adacore's GNAT. The production examples on Adacore's website are typically very large companies in regulated industries.
I did see a very cool looking job listings the other day at a small company, but it involed getting rid of Ada.
In particular, in the 'industrial provable' space, there's almost no competition I think. If you have to write the source code for an artificial heart, what are your options?