Reply to post: Re: Or...

A Reg-reading techie, a high street bank, some iffy production code – and a financial crash

Loyal Commenter Silver badge

Re: Or...

Will someone please tell me why I am wrong to say that no-one using a modern language (of a higher level than Assembler or C) needs to explicitly code a loop to sum [attributes of] the elements in an array?

I didn't down-vote you, because what you wrote was, in essence, eminently sensible.

However, in real life, the developer rarely gets to choose the programming language, and a lot of business software is written in languages that would make you shudder.

Also, it's worth remembering that the above is pseudo-code, and the loop in question could very well have had several hundred lines of code. In principle, it is often more performant to write set-based, rather than loop-based code. However, if you are doing anything inside that loop that is anything beyond trivial, that code may become utterly unreadable if rewritten as a lambda (or whatever). There's always a balance to be struck between performance and maintainability. Don't forget: Premature optimization is the root of all evil.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon