4 ms·
Ada still has killer features that haven't made it into C-like languages. One of my favourite is the split between the abstract/programmer's view of a type, an
by retrac 3y ago
Ada still has killer features that haven't made it into C-like languages.
One of my favourite is the split between the abstract/programmer's view of a type, and the machine implementation/representation of the type.
There's no bit twiddling, no masking with 0xFFFF..., no worries about order in a struct or packing. If you have a 4 bit value, and want to store it in bits 27 ... 31 of a word, Ada lets you specify that. From the programmer's perspective, you work on the abstract type, perhaps defined as range 0 .. 15 in this case. (It can be any type that fits into the number of bits available, by the way.) It packs/unpacks transparently behind the scenes. And if you overflow that 0 .. 15 range it will raise an overflow/underflow exception. If you were trying to cram that 0 .. 15 range into only 3 bits, that'll raise a compile time error.
Ever since I've encountered that its absence from the C family seems like a very obvious oversight.