Hacker News new | past | comments | ask | show | jobs | submit login
Make with Ada: Redux (nocko.se)
97 points by Raphael_Amiard on Oct 1, 2016 | hide | past | web | favorite | 27 comments



Heh, I didn't understand the title at first and thought it had something to do with an implementation of the JS redux library in Ada.

Anyway, it's a cool write up. I wish Ada came up more on HN. It's one of those languages that, like the author, I only know of as one that's "built for reliability, mainly used in defense applications".

If it's fast and safe, why doesn't it get the attention that, say, rust does?


It's before my time, so YMMV, but it seems that the 90s-era "HN crowd" took something of a "shoot-the-messenger" approach to Ada, assuming it must be a terrible language because it was created by the Department of Defense. Not unlike how anything associated with Microsoft used to be treated until pretty recently.

Complaining-about-languages-you-don't-use was an even bigger phenomenon in the era when the internet/open-source was not widespread, and trying out a new language was often far from a trivial thing to do.

It's always a bit amusing to read an old article from the 90s or early 00s, filled with unironic praise for langs now considered poor-to-mediocre, like C, Perl and PHP. (Because these were the languages that didn't take a great deal of effort/money to start writing in the first place).


I did a bunch of stuff with Ada, and like it a great deal; the core language is rock solid, fast, expressive, and extremely easy to work with. But I still have a laundry list of issues, and probably would pick something else for future projects. (My current one is in C. C89. Because reasons. Sigh.)

The three biggest turnoffs for me with Ada are:

- case insensitive identifiers. I understand why they chose that, but history has shown that that's not what programmers want, as evidenced by ever other mainstream programming language ever. Also, there's nothing more likely to repel a new developer than forcing them to switch to a new coding style. (It's also weirdly unAdalike; surely a language which puts such an emphasis on correctness and precision wants things that look different to be different?)

- no garbage collector. As soon as you spend any time with the language it becomes obvious that one's been planned right from the very beginning --- it would drop right in. It just hasn't been implemented.

- deeply inscrutable object oriented syntax. I've used it several times and I still have to look it up, every single time, and even so I keep getting it wrong. There are several hidden gotchas --- it only works properly if your class is defined in a named package and all your method declarations need to be next to each other. I think. It's all totally unmemorable and desperately needs a 'class' keyword.

There's some other stuff which would be nice to have, like better strings, or the ability to have pre- and post-conditions on procedure definitions and not just declarations, but for me those are the three big ones.

I might try Nim next, as that looks nice, and appears to have a number of features borrowed from Ada.


- case insensitivity

I'm not sure it was clear in 1983 that programmers preferred one way or the other. Most languages were case sensitive because it was easier to write the compiler that way and I think programmers "prefer" it now because it's what they are used to. Personally I find the different syntax and conventions as one of the fun things about learning different languages

- no GC

This is a consequence of the level of abstraction Ada is operating at. Actually I think it's one of Ada's greatest strengths because Ada does a really amazingly good job of implementing the pattern C++ programmers call "RIAA". Ada calls it Controlled Types and it puts the power to manage memory in the hands of the programmer without making it unsafe or prone to bugs. RIAA is implemented so messily in C++ and explained so poorly in the community that I've spoken with C++ programmers who agree that the best way to learn to write good C++ is to learn Ada.

- OO Syntax

Yeah I agree with your assessment. I think the problem was that Ichbach wanted to make an OO language originally but felt that some OO features (inheritance, dispatching) weren't appropriate in a high-integrity language in 1983. So he ended up making a language that was 80% OO. Then in 1995 it was clear that the language was worse for not having those features so they were shoehorned in.


*RAII. And C++ does just fine.


I rather like Ada. It certainly does have some issues, but I'm not sure I agree completely with all of your points anymore. I have had similar thoughts in the past though.

- In practice I don't find the case insensitive identifiers to be much of an issue. GNAT (and perhaps other compilers?) will check for consistent casing if you ask. I'm pretty happy with that middle ground - things that look different are different, and you don't have identifiers that vary by case only.

- You're right that it was designed to be able to accept a garbage collector, but it was never intended to be required either. If you really wanted it, you could try targeting the JVM. I haven't found anybody with much experience with it, but it does look like an option. Apparently there is also a 13 year old patch for GCC GNAT [1] but I imagine that's mostly a historical curiosity.

- I've gone back and forth on this one. It basically treats classes as any other type, which I like. It would seem pretty strange if you had to change to completely different syntax structure for declaring a tagged or non-tagged type. So if you wanted to do a more traditional 'class' syntax for tagged types, you'd need them for non-tagged types too. That could be both strange and nice. But that wouldn't really fly with the way primitive operations work right now - it can be primitive for more than one non-tagged type, so where does it go? It's actually a pretty complex issue that would have a large impact on some core parts of how the language works. The rules around this sort of stuff are probably some of my least favorite parts of Ada. It's a lot more implicit than the rest of the language, which has gone out of the way to be explicit. I don't think it has an easy syntax-level fix though.

Hopefully Nim works out for you, but I found it seemed to mostly be inspired by a few of the complaints you just raised about Ada. It also seems to lack the things I enjoy most about it.

[1] http://www.enyo.de/fw/software/gnat-gc/


I believe that Ada allows case insensitive identifiers in order to prevent programmers from using the same names for different variables/procedures. Once I saw some C code like this:

   int x, X;

   X = 0;
   for(int i=0; i < N; i++) {
       /* long code to calculate the value of x */
       ...

       X += x;
   }
Personally, I appreciate that there are languages which prevent this, like Ada and Pascal.


Ada83 had support for optional GC, but since no vendor ever bothered to implement it, Ada 2005 removed it from the standard.

In any case the memory management is quite similar to how Rust does it and in the SPARK dialect for high integrity systems, one isn't even allowed to do dynamic allocations anyway.


"case insensitive identifiers"

Why is this considered bad? I tend to think the opposite. I've never come across a convincing argument in favour of case-sensitivity.

In fact, every language that is case-sensitive always warns users to be alert to misspelled case-sensitive identifiers as a source of errors.

"there's nothing more likely to repel a new developer than forcing them to switch to a new coding style."

So the principal reason in favour of case-sensitivity is habit and familiarity on the part of the programmer (rather than any sound or convincing design reasons)?


I did some VB6 coding back in the day. I simply loved it how you could write identifier without any regard to case (lowercase), and IDE would bump it to correct capitalization automatically. And when you decide to change capitalization in variable declaration, it would then re-capitalize it in your sources, sort of "rename variable" refactoring lite.

And yes, it's pretty insane that languages will treat 2 differently-cased variables as separate, or indeed even allow them. If compiler is allowed to play dumb, at least modern IDEs will flag such code, and modern lints will not allow it.


VB.NET still works that way.

Likewise the SQL, Oberon and Modula editors, where keywords are uppercase by convention.


The class syntax feels like they wanted to make it clear that an object is just a tagged record with a vtable. Unfortunately, it ended up looking like they were trying to design a Java-like OO system without using the word “class”.

Thankfully you can generally avoid OOP in Ada with the really well designed packages and generics. I wish they hadn't tried to tack on OOP or at least not half-assed it so much.

I agree with you about the core language. It's elegant and fun to use. The stdlib isn't too bad either. I just wish it either was explicitly GCed or explicitly not-GCed like Rust, instead of “well, it could be GCed, so we'll make pointers kind of safe but kind of not”.


> "the ability to have pre- and post-conditions on procedure definitions and not just declarations"

Perhaps it wasn't supported in older versions of Ada, but it seems to be supported now.

http://www.adacore.com/adaanswers/gems/gem-31/


I learned Ada in a survey course in the late 1980s. My impression was that it was perfectly fine, but no one was hiring Ada programmers other than in the immediate DC area. There were few public libraries to do stuff (compared with C or Fortran for example). Finally the defense industry imploded just before the technology boomed caused by the rise of the Internet.

I vaguely recall intense licensing issues as well, like it was the only compiler we used which we had to return the floppy disks. So while we could hack around with C, Prolog, Perl, etc. we couldn't "play" with Ada outside of the course.


I have papers from the 70's already giving examples of C's lack of safety, but on those days one would need to pay for getting them by snail mail.


I didn't pursue it, but I found some blogs about low level type safe Ada through generics and modules that looked very interesting. Since, I believe, most of us are sad about C lack of safety, seeing these was inspiring.


Current complaints are about the language not being free enough.

And kind of boring looking.


Actually Ada is quite unusual in that the official ISO standard has always been licensed under terms that permit unrestricted redistribution and even modification; it is AFAIK the only ISO language standard that you can install as a package[1][2] from Debian's "main" repository.

The language is thus more free than ISO C and C++, where everybody googles for "draft" pdfs and hopes their content does not substantially differ from the actual standard.

[1] https://packages.debian.org/jessie/ada-reference-manual-2005 [2] https://packages.debian.org/jessie/ada-reference-manual-2012


The main compiler nowadays for Ada is GNAT, the compiler is GPL and the runtime is LGPL.

In a sea of C-syntax languages I find an ALGOL-syntax language to be really neat looking. :)

I think the biggest problem with Ada is a small community/mindshare.


Because compilers used to be pretty expensive, and the only one free, GNAT, took a long time to become available.

Also the average age of HN readers seem to never have seen or used Algol variants for systems programming, so Rust gets hyped, while ESPOL, NEWP, Mesa, Modula-*, Ada, .... get forgotten.

It is great to see people adopting Rust, but it would be nicer if history doesn't get forgotten.


If it's fast and safe, why doesn't it get the attention that, say, rust does?

It failed for the same reason that Smalltalk and Lisp failed: back in the day compilers and even access to documentation cost a fortune, so there was no way to "kick the tyres" for the average developer. The only people using it were people already employed at companies who were using it, and they used it strictly for their day jobs. Nowadays you can get them for free of course (along with supported commercial implementations) but their time has passed.

Incidentally, a subset of Ada lives on in PL/SQL for which there is a large installed commercial base.


Ada isn't safe the way Rust is safe. It can statically check that an access type (pointer) is only used with objects from a particular storage pool, but dangling pointers to deallocated objects and stack-allocated objects still happen.


It's a bit more complicated than that. Ada has no safe object deallocation, but guarantees safety as long as you don't use any unchecked operations (object deallocation being one).

Ada is also much more powerful than C/C++ in terms of how far you can go with the safe subset of the language, since you can pass/return objects of unknown size in and out of functions by value.

There is no doubt that Rust static guarantees in terms of allocation/deallocation are very useful in some contexts. There is also no doubt that they're not sufficient at all to express every useful programs (for example you cannot safely express any structure with circularities, linked lists/graphs). In those cases you'll be back to unsafe constructs directly or indirectly.

So Rust has more expressivity in this regard but is still no silver bullet.


In terms of safe programs (e.g. programs that, if failing, could kill people), dynamic allocation is not allowed anyway (at least, dynamic deallocation is not allowed). So this makes this point void.

Rust makes user-land programs less prone to crashes, but safe programs found a better way years ago to deal with deallocated pointers issues.

That's also one of the reasons that prevented Ada compilers back in the days to create a garbage collector: there's no sound way to have a garbage collector compatible with real time constraints (which is sometimes safety critical: just imagine an air bag waiting for a garbage collection when it would instead need to pop out), and people creating safe applications don't need it anyway. So why bother?


I believe that the Ada complier was like $2-3K back in the day which turns out is a major obstacle to language adoption.


I really regret not getting my act together and working on my entry for the Make With Ada contest - the language really appeals to me. One day...


I hope someone creates React/Redux with Ada and posts it under the same title.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: