Hacker News new | ask | show | jobs
by uticus 1073 days ago
"Conclusions... Concerning low level programming, C is superior to Ada for its flexibility and for handling pointers or strings"
2 comments

;-) Ada's advantages such as memory safety, concurrency model, range types, exception handling, pre/postconditions and invariants, etc. seem even more valuable now compared to C. Ada's memory-safe string handling seems like a very good idea vs. C.

Ada Minix sounds like it was an interesting exercise - I'd like to see more OS kernels written in memory safe languages.

True in 1993.
cracks open the "REFERENCE MANUAL FOR THE Ada(r) PROGRAMMING LANGUAGE"

looks like Ada83 specification has address clause though, which can effectively be used as a pointer when combined with System.Address / 'Address attribute. Also has access type, but you can't pass access type around all willy-nilly-like without unchecked_access (added in 95?).

C pointers are more flexible though, that much is true.

edit, almost forgot: the main downside of Ada < 95 is you don't get function pointers, or import/export pragma

I don't remember much of Ada, but here's something very basic I liked (had to look the details up):

You could declare custom integer types like this:

type My_Type is range -5 .. 10;

And then you could reference the range with My_Type'First or My_Type'Last

And there were named parameters.

   for A in Range_Type loop
      I_IO.Put (
         Item  => A,
         Width => 3,
         Base  => 10);
      ...
   end loop;
Nim [1] is like Ada in these ways but less verbose:

    import strutils # Or from strutils import repeat Or etc.
    type Foo = -5 .. 10                # Or range[-5 .. 10]
    echo Foo.low, " ", Foo.high        # range limits
    echo repeat(s = "x", n = Foo.high) # named params
    # var f: Foo = 15   # Will not compile
[1] https://nim-lang.org/