Loading ...
Sorry, an error occurred while loading the content.
 

Re: YUI Compresser could produce shorter output

Expand Messages
  • crlender
    ... Just tested it, and it works just as expected. ... No, it s *two* statements inside the outer if . And those semicolons are not optional, so taking them
    Message 1 of 15 , Nov 2, 2008
      --- In ydn-javascript@yahoogroups.com, Philip Tellis <philip@...> wrote:
      > Try this code:
      >
      > if (map.hasOwnProperty(k)) {
      > if (!(k in target))
      > target[k] = map[k];
      > else
      > target[k] = null;
      > }

      Just tested it, and it works just as expected.

      > It's still one statement inside the outer if, but if you remove the
      > braces, you confuse the engine. Take out the semi colons for more fun.

      No, it's *two* statements inside the outer 'if'. And those semicolons
      are not optional, so taking them out *would* be a syntax error without
      line breaks.

      I'm not sure what you mean by the engine getting confused... I've
      never seen a JavaScript implementation that couldn't correctly parse
      control structures with or without redundant curlies. This is basic
      stuff. Or maybe did you mean the compressor engine could get confused?

      > In any event, what you're stating is a micro-optimisation that buys you
      > nothing if you also gzip your javascript before serving. All those
      > braces will compress into a single bit or something of that order.

      Sure, it's not that big a deal, but the compressor's output *could*
      be improved (even if only by a few hundred bytes per script) without
      sacrificing code integrity. Whether the developers choose to implement
      it that way is of course their choice.

      Regarding gzip: if we could just assume that gzip were universally
      available and supported, the compressor wouldn't have to go to all
      the trouble... just strip out comments and let gzip do the rest.


      - Conrad
    • Randall R Schulz
      ... Umm... Yes? Unless, perhaps, you re an acolyte of Ray Kurzweil. However, I fail to apprehend the significance of the assertion... RRS
      Message 2 of 15 , Nov 2, 2008
        On Sunday 02 November 2008 16:11, Philip Tellis wrote:
        > RRS dropped bits saying:
        > > On Sunday 02 November 2008 15:30, D. Wayne Fincher wrote:
        > >> That would be great if it weren't bad programming technique.
        > >
        > > Grotesque! Redundant punctuation does not accentuate readability,
        > > and
        >
        > When 900 years old you reach, look as good, you will not. Hmm?
        >
        > :)


        Umm... Yes?

        Unless, perhaps, you're an acolyte of Ray Kurzweil.


        However, I fail to apprehend the significance of the assertion...


        RRS
      • crlender
        ... expected is an error ;) ... in code that doesn t run as you want it to. Dav, I may be misreading you, but I don t see how the example I posted could be
        Message 3 of 15 , Nov 2, 2008
          --- In ydn-javascript@yahoogroups.com, dav.glass@... wrote:
          > I used the wrong term (syntax error), to me code that doesn't run as
          expected is an error ;)
          >
          > So not putting the braces in and compressing the line could result
          in code that doesn't run as you want it to.

          Dav, I may be misreading you, but I don't see how the example I posted
          could be interpreted in any other way than the example with braces. The
          ECMAScript standard specifies how these structures are to be parsed and
          evaluated; any difference would indicate a (severe) bug in the script
          engine.

          Just in case, let me mention that I personally do use braces even if
          they're not necessary, but a compressor doesn't get any bonus points
          for readable output.


          - Conrad
        • D. Wayne Fincher
          Code conventions aren t just about making code more readable . Anyone that attacks my post on that one single issue is taking part in a straw man. That is,
          Message 4 of 15 , Nov 2, 2008
            Code conventions aren't just about "making code more readable".

            Anyone that attacks my post on that one single issue is taking part in
            a straw man. That is, instead of presenting a rebuttal based on the
            argument at hand, you take another argument which is easier to rebut
            and refute that one.

            In this case, I never mentioned anything about the readability of the
            code. And yet, a few posts only rebutted me on that point.

            Classic straw man approach. ;)


            --- In ydn-javascript@yahoogroups.com, "crlender" <crlender@...> wrote:
            >
            > --- In ydn-javascript@yahoogroups.com, dav.glass@ wrote:
            > > I used the wrong term (syntax error), to me code that doesn't run as
            > expected is an error ;)
            > >
            > > So not putting the braces in and compressing the line could result
            > in code that doesn't run as you want it to.
            >
            > Dav, I may be misreading you, but I don't see how the example I posted
            > could be interpreted in any other way than the example with braces. The
            > ECMAScript standard specifies how these structures are to be parsed and
            > evaluated; any difference would indicate a (severe) bug in the script
            > engine.
            >
            > Just in case, let me mention that I personally do use braces even if
            > they're not necessary, but a compressor doesn't get any bonus points
            > for readable output.
            >
            >
            > - Conrad
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.