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

Re: [jslint] for comma

Expand Messages
  • mathew
    ... Well, this is clearly one of those Your mileage may vary situations. I had a bunch of JavaScript source I hadn t touched in two months, around 50K of it,
    Message 1 of 33 , Jul 21, 2011
      On Wed, Jul 20, 2011 at 22:00, John Hawkinson <jhawk@...> wrote:

      > **
      >
      > More and more JSLint features are added that are things I don't feel
      > comfortable with, that make me write code that is convoluted and less
      > clear, and I don't like that. I don't write a lot of Javascript, and I
      > find the cost of having to deal with JSLint (keeping up with the
      > JSLinting, as it were) is exceeding the cost of actually writing code.
      >

      Well, this is clearly one of those "Your mileage may vary" situations. I had
      a bunch of JavaScript source I hadn't touched in two months, around 50K of
      it, and decided to pull the latest JSLint and see if it would complain to
      me. I got exactly zero errors, just like back in May when I last checked the
      code.

      Maybe the difference is that I learned JavaScript from Douglas Crockford's
      book, so I didn't start with any bad habits? Being from a CS / Lisp
      background, I always pedantically define my functions using "var foo =
      function (args)", avoid side effects, etc. (I'd have thought you'd be the
      same way, being at MIT and all.)

      > I don't see a good reason for JSLint to exclude comma expressions in
      > for(;;) loops. They are not a common error, and they are no different
      > in Javascript than they are in C (or am I wrong on this?)
      >
      A lot of people think they're a bad thing in C. The real question you should
      be asking is what benefit they serve. Can you come up with an example where
      their use makes code clearer?


      mathew
      --
      <URL:http://www.pobox.com/~meta/>


      [Non-text portions of this message have been removed]
    • Douglas Crockford
      ... So how do you design a programming style? What justification is there for preferring one feature over another? One school says that Just Cuz is an
      Message 33 of 33 , Jul 21, 2011
        > > Can you come up with an example where
        > > their use makes code clearer?
        >
        > Why is that "the real question"?
        >
        > Computer languages are tools. The tools are flexible and varied.
        > Absent a very clear harm, we should not remove flexibility.

        So how do you design a programming style? What justification is there for preferring one feature over another? One school says that "Just Cuz" is an adequate criteria. It just comes down to personal taste. And even though we know it isn't true, we are all free to believe that one person's taste is as good as anyone else's.

        My approach is different. I am trying to have mechanical identification of defects. There are some situations that are difficult to distinguish mechanically, so I now consider all of those cases problematic, even when they are not obviously wrong.

        I believe strongly in subsetting, and my design of subsets factors in things like mechanical identification.

        There are certainly tradeoffs here. I am rejecting some features. But I think this is a minimal cost because those features are not essential. We can still write very good programs without them. The benefit is that we can mechanically detect more defects. An unexpected but significant benefit is that the subset is itself a better language than the whole language, and the programs written in that subset tend to communicate better to other humans.
      Your message has been successfully submitted and would be delivered to recipients shortly.