News for hackers. Stuff that matters.
Re:Learning Ada by eeZah7Ux on Friday March 29, 2019 @06:07AM (#19520332)
Scientific research on the source of bugs shows that type-related bugs are a minority.
Re:Learning Ada by OneWingedShark on Friday March 29, 2019 @05:34PM (#19525875)
Well, there's a bit of a problem in how you're qualifying things. For example, certain things that aren't obviously handled by the type-system might be.

One example would be loops and off-by-one errors. For the case of For-loops on arrays Ada's solution arguably does so via the type-system; in Ada arrays "know" their own length, start- and stop-index and these are query-able via attributes.

So, given Function Sum( Input : Integer_Array ) return Long_Long_Integer you could for-loop on the parameter, querying the 'Range attribute -- yielding a possible implementation of:

Function Sum( Input : Integer_Array ) return Long_Long_Integer is Begin Return Result : Long_Long_Integer := 0 do For Index in Input'Range loop Sum:= Sum + Long_Long_Integer( Input(Index) ); End Loop; end return; End Sum;

And the entire problem is avoided via the type-system.

Re:Learning Ada by kqr on Sunday March 31, 2019 @12:23PM (#19536390)
That is a reflection on which language you use. I prefer a language where a large majority of bugs are type-related. How about you?