simont: A picture of me in 2016 (Default)
simont ([personal profile] simont) wrote2009-11-19 03:05 pm

Minirant

That well-known software design adage: ‘Make simple things simple, make difficult things possible.’

The implied word in the middle is ‘and’, not ‘or’!

[identity profile] hilarityallen.livejournal.com 2009-11-19 06:47 pm (UTC)(link)
What provoked this?

[identity profile] eponymousarchon.livejournal.com 2009-11-19 08:23 pm (UTC)(link)
I immediately thought "'and then' surely?" And realised that I was showing my Ada '83 heritage...

Nearest I get to cutting code nowadays is html, but obviously still default to the short-circuit operators as per the LRM. I'm sure this says *something* about me, but what exactly eludes me..

[identity profile] eponymousarchon.livejournal.com 2009-11-20 12:33 pm (UTC)(link)
Sorry - I'm obviously being 'differently geeky'.

One thing that Ada (83 certainly, I couldn't say about 95) does - that Other languages don't - is that by default redundant checks in ANDs and ORs aren't bypassed as soon as one fails/passes unlike every other language under the sun (hell, even Prolog) - Ada values consistency (especially of any other effects that the functions may have) so if you *want* to allow short-circuit, and the run-time savings that this allows, then you have to specify AND THEN or OR ELSE in place of AND and OR.

(As I confused you I'm over-explaining here for the benefit of anyone else.)


What tickled me was that mental consideration of the use of AND THEN and OR ELSE where AND and OR is found in code is a habit, certainly of this coder - and is obviously one that I still have in me after (thinks) over ten years since I last touched Ada.

Ada: Love it or hate it, but it leaves its mark.