Hi monks,

I've been seeing alot of people saying that "this code is elegant", or "my GOD that is elegant code", and so on, and so on. I was wondering how one might "define" elegant code? Maybe it is a lack of perl experience and/or knowledge, but code seems to me like "pretty code", "well-written code", or "crap code". Pretty code consists of readable code, with comments of course, well-written code consists mainly of it's ability to be able to be applied to anything (and truthfully, me not being able to understand it, or some of it), and crap code is, well, just that, crap. Can't be used more than once, modifyications are hellishly difficult, and it's suckily verbose.
What do you, experienced monks, consider elegant code?
Thank you in advance for your responses, you are helping a young monk get a good foothold in this language :-)

-Dhoss

And if you're feeling lucky... come and take me home And if you feel loved If you feel lucky, if you feel loved If you feel lucky, if you feel loved You've crossed the walls - Excelled Further along through their hell All for my heart, I watch you kill You always have, you always will Now spread your wings and sail out to me....

In reply to IYO, what is elegant code? by stonecolddevin

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.