Data conversions seem to be very easy in Perl. So why then do other languages struggle so much with them.
Because they have different requirements. Perl's datatypes are flexible, but they come with a price. It takes longer to get to the value (more pointers to walk), and it consumes a lot of memory (IIRC, the overhead of a string that has never been used in numeric context is 24 bytes; that's 24 bytes more than the data it's holding, it's even more if the string has been used in numeric context). It's also easier to get the 'wrong' typed value in them.

T-SQL is a language geared to query databases. A VARCHAR takes more space than an INT (except perhaps very small VARCHARs, because it needs to record the size somewhere. An INT takes 4 bytes (or 8, but a fixed amount) - nothing more, nothing less. An INT variable will only store an INT - no checking whether it's a number or a string (and hence, no bits needed to record this - or spending time figure out what it is). Database variables are lean: that way, you can pack more of them in a page, which needs your cache expires less often, which means you can access your data faster.

It also means you need less disk space (and no, disk space isn't cheap. Sure, it's cheap if you buy a disk for you PC to store your porn collection on - but it's not if you're using disk cabinets without single points of failure), and hence, less tapes.

There are pick-up trucks, and there sports cars, and there are tiny fuel economical cars. There's a market for all of them. It's the same with variables.

Perl --((8:>*

In reply to Re: Datatypes. A Perl T-SQL comparison by Perl Mouse
in thread Datatypes. A Perl T-SQL comparison by Win

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.