(I meant to include this in my previous post.)

One big difference is the ability to create heterogeneous lists with ease in untyped language. That allows us to create powerful general purpose functions. For example, compare

# "pack" in an untyped language. my $packed = pack('c N c/a*', $c, $i, $s); # "unpack" in an untyped language. my ($c, $i, $s) = unpack('c N c/a*', $packed);

vs

# "pack" in an typed language. Array<Object> unpacked; unpacked.push(c); unpacked.push(i); unpacked.push(s); String packed; pack(packed, "c N c/a*", unpacked); # "unpack" in a typed language. Array<Object> unpacked; unpack(packed, "c N c/a*", unpacked); char c = unpacked[0]; int i = unpacked[1]; String s = unpacked[2];

I don't care so much about the difference in *code size*. The size is not that much different. (80% seems ridiculous.) In fact, the code is not that much different. The real difference is in the amount of *hassle*. Almost all of the extra code needed in a typed language is very repetitive.

In order to hide the extra code and avoid more hassle, you end up creating (repetitive) special-purpose functions as shown below. Of course, this is a hassle as well.

# "pack" in a typed language. Func pack_my_format(String& packed, char c, int i, String s) { Array<Object> unpacked; unpacked.push(c); unpacked.push(i); unpacked.push(s); pack(packed, "c N c/a*", unpacked); } pack_my_format(String packed, c, i, s); # "unpack" in a typed language. Func unpack_my_format(String packed, char& c, int& i, String& s) { Array<Object> unpacked; unpack(packed, "c N c/a*", unpacked); c = unpacked[0]; i = unpacked[1]; s = unpacked[2]; } unpack_my_format(packed, char c, int i, String s);

Note: For the typed language, I used a mixture of C, C++, Java, Pascal and Perl that keeps the code as small as possible. Features include implicit type conversion, autoboxing, object allocation without "new", no separation of variable declarations and code, templates or generics, a Variant type, etc.


In reply to Re^5: Interesting read: "Why I use perl and still hate dynamic language weenies too" (heterogeneous lists) by ikegami
in thread Interesting read: "Why I use perl and still hate dynamic language weenies too" by ghenry

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.