Lessons from Learning Ada in 2021
fosdem.org
fosdem.org
I have not tried out Ada's multi-tasking capability, but it has a simple TASK syntax: http://www.sigada.org/conf/sigada2005/SIGAda2005-CDROM/SIGAd... This should make writing control code for new hardware easier, which is of course one of the core use cases.
When I wrote Pascal code as a kid and tried to learn C, I noticed how in Pascal you could concentrate on the problem, whereas in C you would constantly have to think about memory management and other distracting features (alas, this was before C89 improved a lot of things, notably type support so the compiler could help protect you from yourself).
Having done Turbo Pascal (3.0 - 6.0), before delving into C, was a eye opener for what a systems programming language should be able to offer as minimal set of abilities. Even the fact that C lacks something like New() is ridiculous, how many devs keep getting their array allocations wrong to malloc()?
C++ allowed me to have a bit of that Ada/Turbo Pascal feeling back.
Java, C#, and Rust all have interfaces. (Although Rust might call them something different. I had a lot of trouble learning Rust.)
Even in C you can typedef a function pointer. (Although I haven't done anything like that in ~20ish years.)
This refers to a difference in logical and physical program structure in which specifications are separate from bodies--formalized version of the header/source separation in C/C++. In addition to logical separation, this provides speed ups in recompilation times.
And like C header files, the range of things you can declare in a package spec is essentially any valid thing in the language: types, variables, functions, procedures, more packages, tasks, etc. But C permits the definition and declaration of anything to be in the header file, there are restrictions on Ada package specifications in that regard (some things have to go in a package body). C header `#include` order also matters (since they're text inclusion, a conflict in definitions or the use of macros can impact the outcome), whereas the `with`ing of Ada packages can be done in any order.
I know Ada now is different- it has OOP but back then it was very much like Pascal but string handling was stricter than TP. The on-aircraft software (which I didn't work on) didn't allow generics or threading.
Remember when companies did that sort of thing?
I guess people dont learn Pascal anymore. I still remember Turbo Pascal was what brought me into programming. It took me a very very long time to get used to C style programming.
I haven't touched Ada in like 20 years and now that it seems to be having a small resurgence it looks like a good time to relearn it. It has potential to become one of my favourite languages.
I also prefer the C++/modern C approach to declarations, where local variable declarations can be freely intermixed with other statements. Ada uses a noisier declare/begin/end syntax. [0][1]
[0] https://stackoverflow.com/a/59192530/
[1] https://www.radford.edu/~nokie/classes/320/declareblocks.htm...
You can submit language rfcs here: https://github.com/AdaCore/ada-spark-rfcs
For an example of the latest additions : https://blog.adacore.com/ada-202x-support-in-gnat
As to the developer experience, I find the tooling to be quite satisfactory (IDE, build system, memory/stack analyzers, provers, etc) , the main pain point being the lack of a decent package manager (there is one now, but there are few packages).
Edit: almost all the standard c/c++ tools work out of the box as well (profilers, debuggers, etc), so it's no different from c/c++ on this regard.
By that do you mean the GNU ones, or…?
Is this commonly accepted? I thought it came off the better-C camp, plus GC.
https://www.youtube.com/watch?v=0ReKdcpNyQg
https://go.dev/talks/2015/gophercon-goevolution.slide
> In 1960, language experts from America and Europe teamed up to create Algol 60.
> In 1970, the Algol tree split into the C and the Pascal branch.
> ~40 years later, the two branches join again in Go.
Then you merge that with Limbo's syntax and channels, and you more or less get Go.
(C begat a bunch of research languages, those begat Alef, a conflict about whether to add GC led to Alef dying and its features reimplemented as Plan9 libraries with side effect of Limbo, years later Go is built on top of Plan9 C compiler & runtime with syntax sugar for Alef-derived libraries).
Plan 9 compiler was used as means to quickly get a prototype running, and naturally Rob Pike knows the toolchain quite well.
I also agree with the Alef remark.
If you removed the c pre-processor and translated (the syntax of) a Pascal program to C, I imagine it might look a bit like go if you squint?
I'd say go is to Pascal and C as Javascript is to Scheme/Self and Java.
Ada actually did in Ada 2012 and moreso in Ada 202x.
- Expression functions, and expression forms of if/else and case statements
- more natural "aspect" versions of a lot of pragmas
- iterator syntax for containers which can be user-defined
- user-defined indexing into containers (Variable_Indexing and Constant_Indexing)
- user-defined aggregate initialization (such as for containers, the Yeison library exploits this to provide JSON-like initialization)
Overall though, the language syntax is coherently put together with orthogonal elements, despite the various pieces coming together over decades. The language designers have done a superb job ensuring that Ada 2012 felt uniform, and not like a collection of bolted on parts.
https://en.wikipedia.org/wiki/Rational_R1000
Now you can complain that none of them exist as free beer, and that GNAT Studio came too late, but that is another matter.
Character'Val
I literally failed an exam because I couldn't locate the right function in the online manual for 2 hours. And I'm pretty liberal .. I like lisp, forth and APL but still to this day, it trips me up.But I can relate that Ada feels like you should be writing it one a flickering green terminal in ALL CAPS and debugged with a daisy wheel printer.
https://en.wikipedia.org/wiki/Rational_R1000
http://datamuseum.dk/wiki/Rational/R1000s400
Think Lisp Machine experience, with Ada instead.
In a way, the reason for such a limited character set and clunky syntax (including, e.g. case insensitivity) was precisely to maintain backward compatibility with those earlier machines.
Trying to learn Haskell after C++, on the other side, was difficult for me.
The language didn't get in the way for that sort of application - we had proper specs, and proper designs, so by the coding stage we had a very good idea what we were attempting to solve, and what components would be required.
I'd be interested to know how it would work in a more modern Agile working practice. I've a feeling it would require a fair bit more work to maintain with simple changes having quite a large spread through the codebase due to the strong typing, but saying that, maybe the language has evolved since I last used it and it works well.
The opposite is true in my experience and refactors are usually well bounded.
The "killer feature" of Ada is that types are not modules for writing behavior (in general). This means that syntactically, you can move functions/procedures around somewhat freely because encapsulation and namespacing is done at the package level. It leads to a lot more appropriate data and responsibility hiding, and avoids wasted time considering "is this a method or a (standalone) free function?"
I'm porting my Rust codebase to async, and that is SUPER infective: This lead to change everything, everywhere with the exception of the "pure" functions.
And yet, the process is super boring: I get +1000 errors, start from the bottom, change this to that, now +400 errors, continues, now 0 errors, run test. Done.
Something so big will be a nightmare on a dynamic lang, and even in C# or similar (ML lineage FTW!)
Edit: The language itself never get in the way of comprehension. It was extremely easy to read and understand code written in it. After a while I barely noticed whether I was looking at C code or Ada code.
https://hackaday.com/2019/09/10/why-ada-is-the-language-you-...
"Today, software written in Ada forms the backbone of not only military hardware, but also commercial projects like avionics and air-traffic control systems. Ada code controls rockets like the Ariane 4 and 5, many satellites, and countless other systems where small glitches can have major consequences."
Here is a hobbyist example: https://www.hackster.io/ankurverma608/running-a-finite-state...
Kotlin, Dart? Mobile apps. Java, Go? backend Python, Ruby? scripting, task automation, backend
At least finding jobs requiring them is pretty easy. ADA, on the other side to me looks very niche. I think writing missile controlling code sounds fun. CRUD is boring :)
If missiles can kill safely because their control systems are written in Ada, then cars can too.
Yes, it's smaller than web development, but there's a common theme.
I can't comment on the language on itself really, but I did look at what a web stack might look like in Ada. A lot of work has gone into that but the thing that kept me away for the time being was that it felt like a lot of manual work to actually get the stack in place.
If someone comes and tells me I'm wrong, and I misunderstood, then I hope they do. Because my first impression was the same one I got when trying to figure out Cmake for a beginner C++ project, and I don't really have any desire or inclination to interact with Cmake again.
But in those days there was also Smalltalk, which I find --except for the syntax-- a very modern language. I like to think of Ruby as Smalltalk with a syntax make-over and some FP bolted on top in places it makes sense.