:: Re: [DNG] Wirth's law
Forside
Slet denne besked
Besvar denne besked
Skribent: Steve Litt
Dato:  
Til: dng
Emne: Re: [DNG] Wirth's law
On Fri, 22 Jul 2016 12:21:00 -0400
Brian Nash <bcnjr5@???> wrote:

> This describes a problem I used to have perfectly.
>
> For example, when I discovered multithreading, all my programs used it
> in some way, even when it was unnecessary.
>
> This might be the root of all the problems we are facing with
> computers today: If we see a cool new feature, we have to find some
> way to use it.


Brian's branch of this thread later went on to spawn discussions of
mutexes, closures, and other stuff. But I'd like to bring it back to
Brian's mention of multithreading. By agreeing with him...

I've never written any multithreading code in my life. Some might
attribute that to my not knowing how (and in fact I don't know how).
But those of you who know me know I never let not knowing how stop me
from getting the necessary things done.

No, the real reason I don't write multithreading code is because it's
complex. Everything involved must be thread safe. It must be written
right. And it's quite a bit more complex than other forms of
multitasking, such as those depending on separate processes.

Complexity has costs that must be paid. Before including any
complexity, I ask myself "can I pay the freight?" Can I afford the
decreased repairability? Can I afford the decreased readability? Am I
ready to document how it works, so a well meaning future maintenance
programmer knows which variables are out of bounds for him to change?

And if I *can* afford it, is that expense needed? Would things like
forking be as expensive? On a web server handling thousands of
connections, the answer is "probably." On my home workstation, the
answer is "of course not."

In a lot of cases, worrying about extra processes is a lot like
worrying about your car's fuel economy and what will happen to it if
you let your car's alternator charge your cell phone.

In summary: Complexity has a cost. Be cost conscious.

SteveT

Steve Litt 
July 2016 featured book: Troubleshooting Techniques
     of the Successful Technologist
http://www.troubleshooters.com/techniques