16 ms·
Summary After Four Months with Ada
- rswail 5y agoInteresting review... the last time I looked at Ada was back in the 90s when it was being promoted as the new/replacement C, was the "chosen" DOD language etc.
- kqr 5y agoMost programmers fall into one of two categories in terms of how they think about program structure. Either 1) They think the fundamental elements of code are classes and methods on classes, or 2) They think the fundamental elements of code are functions. Sometimes either of these also know there's something called a module or package, but the idea is loosely understood. I was one of these people. If you're happy to stay that way, stop reading my comment now. Ada is extremely well designed. One of the reasons is that the language design cleanly separates concepts normally bunched together into ideas like "everything is a class". In many languages, if you want implementation hiding you get a whole bunch of other things with it. You can't use just implementation hiding without automatically opting into all parts of class-based programming, like inheritance, subclassing, etc. Then you go "wait, what? Isn't inheritance and subclassing sort of the same thing?" Yeah, no. Not fundamentally. It's only the same thing in popular programming languages because everything is the same thing in popular languages. Everything is a class and if you need anything you get the whole class concept, whether or not you wanted it. This is problematic especially for beginner programmers because they learn implementation hiding is good. So they use that. But that opens up a huge toolbox of additional tools, not all of which are appropriate. But beginners are like beginners are, and when they see all those tools they simply use them -- sometimes out of desperation. This leads to messy code. Ada is different. In Ada, you can pull out just the concepts you need, and it won't automatically opt you in to everything else. A beginner that uses implementation hiding in Ada won't suddenly have an open toolbox full of subclassing. Their toolbox still contains just implementation hiding and whatever else they intentionally put in it. That leads to better code. Just for that experience, Ada is worth learning, in my opinion. Here are some quotes from TFA that alludes to this. > Packages are namespaces for functions and types, unlike other languages where types can “contain” functions and types. Organising code into subcomponents with implementation hiding is separated in Ada from class-based programming. You can do both, but you can also choose to do only one of them. > Function overloading acts as a key design element You can have polymorphism without opting into inheritance. (Further, you can have inheritance without opting into class-based programming.) > Everything in a package is related, there’s no syntactical split between “free function”, “class function”, or “member function” (method). You can have methods on types without opting into class-based programming. > What most C-family languages call “functions”, Ada calls “subprograms”. Ada distinguishes between those which return a value and are truly “functions” and those which do not return a value, and are “procedures.” A procedure is fundamentally different from a function from a reasoning-about-the-code perspective. You can have either without automatically opting into the other (as is the case when everything is a method.) > Examples are “accesses” (sort of like pointers), “accesibility” (similar to a scope for borrowing), “tagged types” (classes), “derived types” (unrelated to OOP), and “subprogram”. Using different words for different concepts -- instead of bundling them into the same generic idea -- increases the richness of your mental vocabulary which also increases the nuance your thoughts are able to express. ---- If you read my comment all the way down here, you might be interested in the Rust beginner's tutorial adapted to Ada, one of my more popular articles (which tells you something about my popularity...) https://two-wrongs.com/guessing-game-ada-style.html https://two-wrongs.com/guessing-game-ada-style.html
- masklinn 5y ago> A procedure is fundamentally different from a function from a reasoning-about-the-code perspective. They really are not unless the langage puts specific limitations or features on one or the other. And odds are the average “procedure” should not be one, because it only exists for its side effect but then provides no feedback about these side effects.
- kqr 5y agoObviously what you're saying is completely correct. Maybe we can agree on that they should be different, but in languages where all code is a method it is dangerous to assume they are different?
- masklinn 5y ago> Maybe we can agree on that they should be different Why would we? And how should they be different, and what useful properties would that provide? > in languages where all code is a method it is dangerous to assume they are different? Why would you assume undifferentiated functions are different in the first place, and what would the difference be?
- louthy 5y ago> Why would we? And how should they be different, and what useful properties would that provide? Functions should be similar to mathematical functions and come with guarantees like purity, referential transparency, and totality. Another reason they should be different is they've got different names! Might seem trite to say that, but what's the point in having the same concept with different titles? Pure functions are very powerful concepts, especially when it comes to composition, if the consumer of a function can't rely on that, then the consumer must investigate the internals to know what it does. Once you're several layers deep into your composition that becomes exponentially harder to do. So, there is value to having a concept (with a suitable name, like 'function') that indicates to the consumer what it is they're dealing with. Some languages, like Haskell, bake this in; others like JS really don't - making the whole process of dealing with 'functions' (really procedures) much harder once an application is more than a toy project.
- TurboHaskal 5y ago> “There’s some quirky behavior, like tab indenting to where it thinks the indent should be and not actually inserting a tab.” No sorry, inserting a tab is the actual quirky behavior.
- guerby 5y agoInterestin things about Ada: - language designer have a document where they explain their choices, the Ada Rationale: http://www.ada-auth.org/standards/rationale12.html http://www.ada-auth.org/standards/rationale12.html - there is an annotated version of the standard, and it's freely available as the standard: http://www.ada-auth.org/arm.html http://www.ada-auth.org/arm.html - A language test suite was developped at the same time of the language: https://en.wikipedia.org/wiki/Ada_Conformity_Assessment_Test_Suite https://en.wikipedia.org/wiki/Ada_Conformity_Assessment_Test... The last point was also in retrospect not sot good for the language ecosystem: buyers wanted a 100% on this test suite before considering your Ada compiler, which means dev had hundreds of compiler bugs to fix and no paying customers.
- ChrisMarshallNY 5y ago> dev had hundreds of compiler bugs to fix and no paying customers. From what I understand, a principal rationale of Ada, was to have a “100% reliable” toolchain, and compile-time assurance. So this is actually a reasonable posture. It seems that Ada can be challenging. In the 1980s, there was a project to rewrite the nation’s air traffic control system, in Ada (I knew a couple of engineers, working on it). I don’t think it ended well.
- topdancing 5y ago> I don’t think it ended well. https://www2.seas.gwu.edu/~mfeldman/ada-project-summary.html https://www2.seas.gwu.edu/~mfeldman/ada-project-summary.html would suggest otherwise
- ChrisMarshallNY 5y agoThe US version flamed out, in spectacular fashion. The European one, however, worked. Another poster put up links ([0], [1]). [0] https://web.archive.org/web/20160601100527/http://www.bloomberg.com/news/articles/1993-04-25/flying-in-place-the-faas-air-control-fiasco https://web.archive.org/web/20160601100527/http://www.bloomb... (Unpaywalled) [1] https://www.skybrary.aero/index.php/Central_Flow_Management_Unit_(CFMU) https://www.skybrary.aero/index.php/Central_Flow_Management_... It wasn't a ding at Ada. However, big projects (regardless of the toolset) need to be well-managed.
- surfsvammel 5y agoAds was one of the languages used to learn basic concepts of programming at the university programme I attended. We Lisp and Ada where the two main language that we used, to contrast the differences.
- alex_duf 5y agoYou wouldn't have trained at the Computer Science University of Bayonne (France) would you? Because we also used Ada as our first language there.
- Tomte 5y agoUniversity of Stuttgart, as well. One of the language designers was the department head for programming languages and compiler construction.
- dagw 5y agoChalmers University in Sweden used Ada as its intro language for a while as well (late 90s).
- toolslive 5y agoKULeuven (Belgium) used Ada in the mid 90s for some of the programming-in- the-large CS courses. (So not as first programming language. That was Scheme or Pascal). It (Ada) got replaced by Java later.
- tcard 5y agoUniversidad Politécnica de Madrid, too.
- tialaramex 5y agoI learned SML. At the time the CS department here had the philosophy that the introductory programming course should be in a language students were very unlikely to already know, thus putting the self-taught programmers on a somewhat level playing field with those who've never programmed a computer before. They did have to stream that intro course anyway, because irrespective of familiar syntax some people "get it" and some don't. I remember the bottom stream were named "Strugglers" but I don't remember what the stream for people it comes as second nature to is called, most people move up and down a bunch e.g. maybe they were fine right up until currying, and they go all the way from "Attend one lecture a week, complete the assigned work in ten minutes, hand in and we're done" to "I need both classes and the extra one-on-one tutorial to even understand the assignment, let alone try to do it" overnight. Today I believe they teach Java, or possibly Python, bowing to industry pressure to churn out people who can cut code on day one, as if that's the purpose of a three year degree. Interestingly the same university's IT department just hired me based on the rationale that although I don't actually know most of the technologies they're using, I clearly can just acquire everything needed as I go. So they don't believe this bullshit, but many people hiring their graduates do, and 18 year olds pick institutions with the best hiring rates.
- bb88 5y agoI would hesitate to call Ada "obscure", though. Maybe "once popular" -- especially since DoD spent billions writing Ada.
- alex_duf 5y agoAda was the first language I learned through my Computer Science courses during my University years (Bayonne, France).
- pjerem 5y agoSame for me at University of Nantes (France). Unfortunately, I was too narrow-minded to understand that it was a really interesting langage and not just a useless academic hobby of my teachers. At least I do now, but I’m sad I was not more attentive at this time.
- jabl 5y agoI wonder how much more robust the software we all interact with daily would be, had Ada become the standard systems programming language instead of C and C++.
- Jtsummers 5y agoAs much as I like Ada, there were a couple projects at an old office that were great demonstrations that you could write C code in any language. Among other things, they absolutely failed to understand the type system so had a lot of manual range checks instead of letting the compiler and automatically generated runtime checks do the work for them. They didn't understand how to loop over arrays, passing in size information as a parameter. It was gross code, like someone had simply translated C or Fortran to Ada without consideration of the target language's abilities. It would be like someone choosing Rust and then making everything unsafe. Or Haskell (I saw this in a tutorial once, it was hilarious and disgusting at the same time) and using strings (data) for dispatch instead of translating them into types and actually exercising the type system. All that is to say, thoughtless programmers outnumber thoughtful ones. The language can only take you so far.
- ggm 5y agoWell written. Always interesting to see new eyes in modern guise on old ideas. I studied and worked at the university of york, 1980s, but not on their Ada compiler project. I recall it had an astronomical number of passes, and was said to have been formally rejected as "not compliant" until they removed a compile time warning which said something like: congratulations you have used the most obscure part of the ada specifications
- noisy_boy 5y agoIf you have ever written in Oracle's PL/SQL[0], Ada will come across strangely familiar to you (because the designers of PL/SQL modelled its syntax on that of Ada). For me, it was almost like a blast from the past since I wrote lots of PL/SQL almost 20 years ago. [0]: https://en.wikipedia.org/wiki/PL/SQL https://en.wikipedia.org/wiki/PL/SQL
- hnlmorg 5y agoThe similarities are only skin deep though. It's like comparing Javascript to Go because they both have C-style braces. Plus PL/SQL is an abomination of a language whereas Ada can be a real pleasure. A much closer comparison would be Pascal. Which is another awesome language (I was gutted when the home computing industry moved away from Pascal and towards C).
- noir_lord 5y ago> Pascal and towards C As was I, Object Pascal was for it's time one of my all time favourite languages - it was so effortlessly boring it just got out the way.
- EamonnMR 5y agoWhat is it about SQL embedded languages that made them so hard to get right? I had to port a stored procedure from MySQL to Pl/PSQL once and it was nuts how much better the PSQL one was once it was finished.
- ako 5y agoWhat makes pl/sql an abomination of a language?
- hnlmorg 5y agoIt's an attempt at bringing procedural workflows to SQL but the two paradigms aren't really compatible. It's much easier working with a scripting language like Perl or Python and embedding SQL queries. Use a relational language for the relational logic and a procedural language for the procedural logic.
- edem 5y agoI came here to read about Cardano, then I realized that this was about the programming language.
- eashish93 5y agoSame thought. I think the article on top because of ADA coin.
- DonHopkins 5y agoI hoped it was about Ian Dury and the Blockheads. https://www.youtube.com/watch?v=8EMR9DXU_NQ https://www.youtube.com/watch?v=8EMR9DXU_NQ
- greg7mdp 5y agoBoth are named after Ada Lovelace, mathematician and first computer programmer.
- edem 5y agoWhy all the hate?
- yawaramin 5y agoBecause it's an irrelevant comment. If the topic is not what you expected, keep scrolling. No need to let everyone know.
- ajxs 5y agoGreat article! I've written lots of Ada, and I actually had no idea Ada had such a thing as "Expression functions". I do understand the reasons why many people seem to dislike Ada so much, compared to C it's fussy and verbose. However using Ada resolves so many of the issues people have with coding in C, and C++. I'd recommend anyone who regularly writes programs in C to see what Ada has to offer. SPARK is also worth taking a look at. AdaCore's documentation on what SPARK has to offer to people working with MISRA C makes a great case for the language's use: https://learn.adacore.com/courses/SPARK_for_the_MISRA_C_Developer/index.html https://learn.adacore.com/courses/SPARK_for_the_MISRA_C_Deve...
- thesuperbigfrog 5y ago>> I actually had no idea Ada had such a thing as "Expression functions". The John Barnes book mentioned in the article covers some of the differences between the Ada language versions. Expression functions were added in Ada 2012 and directly support preconditions, postconditions, and various aspects in SPARK 2014.
- chris_wot 5y agoThe link to the tutorial site gives a 404 error
- pyjarrett 5y agoThanks for mentioning this. Fixed.
- mcculley 5y agoI worked with Ada a lot during the 90s (and even maintained the Linux port of GNAT early on). This document does not address one thing that I am curious about. What does the modern, idiomatic Ada programmer do about memory management? Are library implementers still required to use Unchecked_Deallocation? I don't see how a language where Unchecked_Deallocation is used can be considered safe at a time when we have modern choices with automatic memory management. Edit: I guess another way to put this is, "Can a non-trivial project be developed in modern Ada without using Unchecked_Dealloation?" Because I don't see how I can consider a library safe if it is allowed to call Unchecked_Deallocation.
- zetalyrae 5y agoOff the top of my head there are two ways: - Lexically scoped access types have storage pools that are destroyed when the type goes out of scope. This is similar to region-based memory management as in Cyclone[0]. - Limited controlled types are a lot like linear types and prevent unwanted aliasing and ensure deallocation happens correctly, as described in this paper[1]. [0]: https://en.m.wikipedia.org/wiki/Cyclone_(programming_language) https://en.m.wikipedia.org/wiki/Cyclone_(programming_languag... [1]: https://dl.acm.org/doi/10.1145/165354.165362 https://dl.acm.org/doi/10.1145/165354.165362
- mcculley 5y agoI think I understand these. I think these solutions work where it is very clear what the scope of object should be. But what about cases in large projects with many developers where a library/package allocates an object on the heap and passes it back to a caller? Sometimes it is not clear who is responsible for deallocating the object. This is the challenge we ran into building large projects in C, C++, and Ada. These days, I use Java, C#, Rust, or Go, because I know there will be no dangling pointers.
- zetalyrae 5y ago>a library/package allocates an object on the heap and passes it back to a caller Limited controlled types handle this case. Limited types prevent assignment (i.e. aliasing). Controlled types introduce destructors so everything is closed even when an exception is thrown.
- jl2718 5y agoI went to a college that taught CS in ADA, and I never took CS because I tested out of 101, but I ended up fixing attempts at the problem sets for about half my dorm section (this was okay as long as and they documented it). Well anyway, I found it to be very easy to pick up just by reading, hard to make semantic errors, and easy to modify without breaking things. The pace of learning for the entire cohort, mostly non-CS students, was, I think, much faster than e.g. C++ and possibly more complete than e.g. Python. It’s pedantic and exact, but it uses real english language keywords and modifiers. I went to a different school later where I did the same thing but it was taught in C++. It seemed like many students would get by purely by repeating patterns that they didn’t understand. And I started to catch myself in that trap as well, realizing that I had a lot to learn. But I wasn’t going to be a programmer; I was going to be a theoretical physicist cogitating on the deep mysteries of the universe. Fast forward…. D’ohhhh.
- zozbot234 5y agoDoes "real english language keywords" actually make it easier to learn programming? AIUI, this was popular in the past simply because many computing systems used bespoke, pre-ASCII character sets, sometimes with few symbols available and no distinction between uppercase and lowercase (hence why Ada is case insensitive as well!). Typing stuff like DIVIDE A INTO X can come in handy when your machine literally doesn't have a / character.
- formerly_proven 5y agoPretty sure it does. Line-noise languages (e.g. math, C++, Rust, Perl, K) optimize for expert use, the trade-off being that they're difficult to parse and understand for newcomers and infrequent users. There is of course also a huge difference between languages were the meaning of symbols/notation is largely context-independent (e.g. the three types of braces in C) and those were this is not the case (e.g. C++, math).
- tialaramex 5y agoI agree C++ is worse about the context dependence than C but they're both pretty bad about this. Notice that C has two different operators named * and two named & for example.
- zetalyrae 5y agoHaving separate module interface and module body files, as in Ada or Modula-2/3, is a great idea that sadly a lot of people are burnt out on because C and C++ do this in a very unprincipled way. Having a terse little file where I can scan the interface of a module, rather than having to scroll through the implementation and see which declarations have `public` in front of them, is a great way to quickly refresh your mental model of a module's API. And it allows you to have both interface docstrings and implementation docstrings, which a documentation generator could use to compile an API guide for clients and a developer's guide for people working on the internals.
- MaxBarraclough 5y ago> Having a terse little file where I can scan the interface of a module, rather than having to scroll through the implementation and see which declarations have `public` in front of them, is a great way to quickly refresh your mental model of a module's API. There's also another structured approach to the interface/implementation distinction: leave it up to the IDE to offer an interface explorer. This is the approach used by, say, Java. I'm not sure that either approach is outright better than the other; it's a trade-off.
- zetalyrae 5y agoI tend to prefer things being on the code itself as opposed to being added dynamically by the IDE. For example I think type annotations should be in the IDE. This is because it lets me read code in extra-IDE settings: browing GitHub, or in a patch file, or on a book. Or I can write code on paper. Another benefit is that you can design a program entirely by writing the module interface files, and typechecking them against each other without an actual module body file. Then, as you start actually implementing the program, you can implement one module at a time, typechecking it against the module interfaces of its dependencies, without said dependencies having any actual code in them. So you can write the actual implementation in whatever order makes sense.
- joppy 5y agoIn C++ you can’t really even separate them if you want to define templates, because (unless I am mistaken) template instantiation can only be done at compile time rather than link time. It’s sad to not be able to cleanly separate the interface from the implementation.
- MaxBarraclough 5y agoAn interesting read, but there's an error: > Unfortunately, the top tiers of [SPARK] analyses are paid only, but you can get data/information flow analyses, as well as guarantee of no runtime errors for free. That's not right. Straight from AdaCore's Yannick Moy, a year ago: [0] > SPARK as included in GNAT Community allows you to go up to platinum level, with the 3 provers included (Alt-Ergo, CVC4 and Z3) [0] https://old.reddit.com/r/ada/comments/hwgbwa/survey_on_the_future_of_gnat_community/g1z6s5z/?context=99 https://old.reddit.com/r/ada/comments/hwgbwa/survey_on_the_f...
- pyjarrett 5y agoThanks for pointing this out. Fixed.
- MaxBarraclough 5y agoSpeedily done, thank you.
- glafa 5y agoI'm personally amazed by their productivity - in 4 months of learning the language they've completed 7 projects - they've read a 700 page book in a month - they've made a ebook on ada
- bdavis__ 5y agoThere were a few studies on ada (avionics software) and productivity when the language first came out, and ada scored very well compared to the state of the art at that time. People learned that using static typing and sub-typing moved a lot of defects from runtime to compile time. (that was sure my experience; getting it to compile took hours, but runtime errors were greatly diminished). Looking back, the power of the "spec and body", IN and OUT parameters, and such where just so much more powerful than Fortran or Assembly or even JOVIAL. C was too uncontrolled and wild.
- SavantIdiot 5y agoAda is like the exact opposite of "move fast and break things". Ada is more like: think long and hard before writing your first line of code.
- ksec 5y ago>think long and hard before writing your first line of code. Which is no longer allowed in Modern software development influenced by Silicon Valley.
- SavantIdiot 5y agoIronically, this is the #1 think people whine about government research: "eeew, it takes too loooooonnnggg." Yeah, there's a good reason for that.
- systems_glitch 5y agoZERO-NINE! Good to see you're still hacking on stuff :)
- pyjarrett 5y agoThat's a very welcome blast from the past! :) Feel free to send an email if you want to catch up.
- systems_glitch 5y agoSent to your gmail!
- WalterBright 5y agoI always liked Ada, going back to the first MIL-STD-1815 of it (from 1980). It looked very complicated to me at the time, so I didn't try implementing it (instead I thought C++ would be a couple months to implement and did that instead). A couple things D took from Ada were the in, out, and inout parameters, and embedding _ in numeric literals like 1_000_000. The latter is so simple and so useful. I still have my copy of MIL-STD-1815 on the shelf. No, you can't have it.
- mst 5y agoThe 1_000_000 thing exists in perl as well (I think also via theft from Ada) and frankly I can't understand why everybody hasn't stolen it.
- jhayward 5y agoPretty much every currently updated language does these days.
- WalterBright 5y agoThis wasn't remotely true in 2000 when D was being created. AFAIK D was the first after Ada, and certainly popularized it as I made many presentations including it. C is still holding out :-)
- mst 5y agoPerl 5.000 was released in 1994 (see https://perl.bot/p/kw3gbl https://perl.bot/p/kw3gbl for a demonstration that had the syntax) Edit: That bot is far too easy to be curious with, and unless I got my testing wrong, perl 2 (from 1988) seems to have been where it was added: https://perl.bot/p/jzyi91 https://perl.bot/p/jzyi91 All assistance convincing the rest of the world they should also adopt the feature is very much welcome though :D
- WalterBright 5y ago
- thayne 5y ago> An interesting aside is that if Github locations are to be believed, the Ada community is predominantly European That's a little ironic, given ADA was originally a US government project.
- detaro 5y agoMight be that the US has more the commercial closed-source side, which doesn't show in Github stats obviously, and for whatever reason there is more academic/open interest in Europe?