On Mon, 19 Apr 2021 16:19:18 -0400 "Greg Reagle" <l...@speedpost.net> wrote:
Dear Greg, let me give a short overview of Ada and why I think it's great: Ada is all about dependability (that's why it was developed and is still widely used in a wide range of fields) and many things you'd find in other languages are not present in it to avoid programming errors. The type system is breathtakingly beautiful and versatile: It encourages you to really define every type you use with specified ranges, and you can even, for instance, define a type "Prime" that can only hold prime numbers (using dynamic predicates). A lot of the things that are hyped today as "data oriented programming" and would require a lot of manual checks for consistency are done for you. I'm a big critic of object oriented programming, but even though Ada has a concept of a class and derived types, you only deal with types and methods that operate on types which are, however, not part of the type itself. > Okay, I did. Very interesting. I briefly studied Ada many years > ago. Do you think that Ada is a viable alternative to Rust? Do you > think it is a decent alternative to C for things like operating > systems or utilities like sbase or ubase? The strong point over Rust is readability, stronger guarantees, built-in concurrency and the fact that it's ISO-standardized, among many other things. To see how far you can go with Ada (using SPARK, a very close subset), read chapter 2.2 in [0]. All the tooling is GPL licensed, but they also make money with professional-tier packages. Which stronger guarantees am I talking about? You can do contractual programming, guarantee there are no runtime-errors statically (!, i.e. at compile time), prove statically that there are no data-races (even in concurrent programs, how nice is that?) and Ada has had a proper memory ownership model since the 80's which Rust is selling us like this big new invention. And such guarantees are good to have when you write a program responsible for actuating nuclear-reactor-control-rods or the avionics of an aeroplane. I'm certain the only main reason Ada wasn't picked up is because it was developed in the military, and the hippies in the FSF didn't like that. Another problem is a lack of compiler diversity, but don't we also have that with C? And other than C, which becomes infested with GNU-extensions on a massive scale, Ada is still developed by consortium and relatively safe from that. > Rationally, there is nothing better than C. I wish all the other > things did not exist, so that people would stop piling crap on top of > crap. It takes a solid engineering discipline, which is long forgotten. But is the C-ecosystem really so light? We're using a slew of static analyzers, debuggers, etc. to fix our C programs, and even though I've been programming in C for a decade and would call myself relatively good at it, I still keep on making mistakes. The sad truth is that our brains are not just really good at programming, relatively speaking. We are able to work with abstractions, humanize data-structures and algorithms and encapsulate concepts as an analogy to sharpening sticks with rocks and building a hut, but we make mistakes. Ada is complex, yes, but it's more than a programming language: It's an approach to software engineering. If you had a really large project with 300 developers or something, you'd need to bring a lot of additional tools on top of the C compiler to make it all work. With Ada, you have a wide range of additional tools, and all is crystallized in an ISO standard. I see Ada as follows in the context of suckless: Others may differ in opinion, but I see the main goal of suckless to provide simple, dependable and well-designed programs and interfaces to solve common problems. Unlike any other project we really polish our code and try to make it as lean and simple as possible. But still we stumble upon memory leaks, off-by-ones and other common issues, even in "polished" code. At a certain point we should probably accept our biological limitations and try using a language that guarantees safety. You can go very low-level with Ada (sometimes even lower than C, e.g. with struct packing), but it's all with guarantees. Considering [0], I could imagine that one could work on basic tools and go up the ladder up to Platinum-SPARK-conformance where everything is statically guaranteed. In case you wonder: You don't need a special "SPARK"-compiler and any SPARK-program is a valid Ada-program. What really gave me the push, though, was parallel programming during my research and free time: It's really simple to make massive mistakes, and debugging them is a pain. Ada has a concurrency system built into the language (servers and tasks) and you don't have to think about locks, mutexes, etc. and just write what you like. In most cases, it will be as fast as C, and you get static guarantees that there will be no data-races. And even if you hit a bottleneck, which is unlikely given today's I/O-bound performance in most cases: You can always buy faster hardware with more money, but you can't just "buy more security". With best regards Laslo [0]:https://www.adacore.com/books/implementation-guidance-spark