You do realize that to many people the phrase "X considered harmful" is, well, considered harmful? It's often used with the tongue and a cheek being very friendly to one another.

What's usually meant by such statements is that without due care, a fairly mundane and common practice can have unpleasant consequences. The prototypical case is "goto() considered harmful", which of course is silly at some level because most structured code simply abstracts it and does nothing to remove its proper use. The Djikstra article was much more conservative in its complaints about goto() than most who know it only by reference would guess. The author says that structured program flow was easier to follow, debug and formally prove. He does not say that careful use of goto() in some instances is bad, only that it was typical at the time to overuse and abuse the feature. Only improper use is the problem, as it is with system(). In fact, almost anything in our lives could be put to the same claim. It's not a perfect world we live in. Nothing's without risk, but we go on living. Overstating danger to get noticed is for news reporters and politicians, not programmers.

From the top of my head, "crosswalks considered harmful -- every intersection should have a bridge or tunnel", "kitchen knives considered harmful -- everyone should only eat things easily bitten apart, because you might cut a finger or hand", "firearms considered harmful -- if misused or handled recklessly, they can be deadly", "sex considered harmful -- if you're not careful you could catch something", and "tomatoes and spinach considered harmful -- if you raise, harvest, or handle most fruits and vegetables improperly, they might carry bacteria like salmonella or e. coli".

This last one has been a big deal recently in the US, actually, not because tomatoes are dangerous (and not even that salmonella is usually particularly dangerous where it's expected and properly mitigated). It's the improper handling that's the problem.Animals that carry salmonella in their meat should always be fully cooked, and animals that carry it in the intestines should be slaughtered and butchered responsibly (and their meat still cooked thoroughly on the surface if unsure). Tomatoes, not having intestines, should probably not be expected to carry an intestinal bacterial culture. With proper care, they don't.

Such is the issue with system(). There are risks, but most of them have to do with improper use and handling. Most of them can be either eliminated or mitigated with proper care. If its usefulness outweighs the risks, then use it. The risks rise more in certain situations, so more mitigation is needed. Perhaps in some cases there's too much risk, but in most of those calling any outside program should be strongly questioned in the first place.


In reply to Re: Use of system() considered harmful by mr_mischief
in thread Use of system() considered harmful by pc88mxer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.