Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Ada's been steadily making a reassurance I think since safer languages like Rust had started to gain traction

Why one would use Ada now when it looks like there are much stronger contenders in this space: rust for close to metal and C#, Java, Go for slower programs?



Ada has features built in that those languages do not have.

Off the top of my head, Ada has "restricted types" (e.g: you can say a function takes an integer of the range 5-15 only), as well as pre-and-post conditions you can annotate your procedure definition with.


It sounds like this can be implemented as some 3p libs, and not necessary be a part of language?


I like in Ada's type system in that I can do constraints such as "type Positive is Integer range 1 .. Integer'Last;" to give me a number that I know must always be in the positive range of an integer, and it's easily readable in plain text.

From what I have read, trying to do something like "type Element is Integer range 100 .. 1000;" in rust requires something along the lines of

     struct BoundedU16<const MIN: u16, const MAX: u16>(u16);
     impl<const MIN: u16, const MAX: u16> BoundedU16<MIN, MAX> {
         pub const fn new(value: u16) -> Result<Self, BoundError> {
             if value >= MIN && value <= MAX {
                 Ok(Self(value))
             } else {
                 Err(BoundError(value, MIN, MAX))
             }
         }
     }


Now how about using this type as an array index? In Ada, when you declare an array with this kind of type as an index, it automatically knows its size, generates a bunch of methods to help with iteration and element access, and these methods are "generic" in a sense that the programmer doesn't need to know the lowest or highest index of an array in order to iterate over it.

On the other hand: these types make life hard. Kind of like Rust's lifetimes. Sometimes obviously correct code doesn't compile and you need to twist and tie yourself into knots in order to get a much more convoluted version to compile. Well, like Rust.

They are indeed very similar, and require approximately the same level of pain tolerance.


Rust tries with a crate and traits but it misses out on e.g. record memory overlays which are so powerful in Ada. Type design is beautifully intuitive for the main part in Ada too. Restricting your parameters with ease means there is less logic to write and mistakes and refactor fallout gets caught early.


Honestly Ada is far better than Rust for close to metal as it was designed for it. It is also safer and easier to use than Rust. Ada has also been demonstrated to be more cost effective over a programs lifetime than C, C++ and Java. I also dropped Go for Ada and prefer the quality and memory control that Ada offers. The only thing I miss are the stdlib docs and the ease of cross compilation.


> Ada is far better than Rust for close to metal as it was designed for it.

Sorry, can you elaborate on this? Rust was also designed to be close to the metal, so I'm assuming that there's some concrete difference that you're referring to.

> Ada has also been demonstrated to be more cost effective over a programs lifetime than C, C++ and Java.

Do you have a citation for this improved cost-effectiveness? Things like that are notoriously difficult to prove, so I'd be curious to know how this was measured.


Adas specification was developed competitively over a number of years with embedded development as well as the ability to replace all 450 languages in use by the D.O.D. at the time as requirements. Rusts first official specification is still in the works aside from the one created by AdaCore.

Representation clauses are just beautiful for embedded memory-mapped registers and network protocols and driver registers received over spi/i2c etc.. There is even built-in validity checking. No need to shift generally as the compiler does everything for you.

https://learn.adacore.com/courses/Ada_For_The_Embedded_C_Dev...

The D.O.D study that includes Java would need to be dug up but this one is interesting too.

https://forum.ada-lang.io/t/comparing-the-development-costs-...

I only found out recently that the D.O.D. Ada mandate didn't say you had to use Ada. It said you had to demonstrate why your project would be more cost-effective than using Ada. Considering Ada was designed with cost-effectiveness/maintainability as a primary requirement then that was a difficult task.


>Why one would use Ada now when it looks like there are much stronger contenders in this space: rust for close to metal and C#, Java, Go for slower programs?

Define stronger? C#, Go, Java probably by wide use in enterprise/industry, but Rust? Power of sunshine and rainbows? Wishful thinking?


> but Rust? Power of sunshine and rainbows? Wishful thinking?

adaptation, active community, more modern features, larger ecosystem


Oof! You were going so well .




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

Search: