News for hackers. Stuff that matters.
Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by bitanarch on Saturday December 13, 2014 @06:49AM (#8744975)
Well, just a curious question - do you lint your JavaScript code?
Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by niklasni1 on Saturday December 13, 2014 @06:57AM (#8744994)
I just ran a few of my longer files through jslint.com and it looked like all the errors were related to me using two spaces for indentation instead of four, and some missing semicolons. But I don't know what sort of errors I should be expecting?
Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by bitanarch on Saturday December 13, 2014 @07:18AM (#8745022)
If you're working on a project with just a few people and on the first version, you'd probably not see many of these problems. But imagine your project grows, you keep modifying the code, and often times you'd make typing mistakes..

Let's say originally you have this.

  // Run node to the end
  for (; node.next != null; node = node.next);
  doSomethingElse();
After a few months of team work on the same code, one day, somebody got careless with the "x" key in vim and deleted the semicolon after the for.

  // Run node to the end
  for (; node.next != null; node = node.next)
  doSomethingElse();
And your web page still works! It's just become mysteriously very slow, sometimes. Must be caused by the latest Chrome update.

There're lots of other ways for a pile of JavaScript code to accumulate bugs like this over time without a strict standard in place to lint everything. e.g. people forgetting to add "var" before variable declaration because they've been writing Python as well, causing namespace leaks that DON'T seem to break anything at first.

If you team has a standard practice to always lint everything, always do data binding in a certain way, never modify the DOM directly (combined with the proper libraries), etc. Then, yea, maybe you can scale up your team and the code size without always fixing funny bugs that pop up only after the original mistake was made 6 months ago.

But, standardized development practice with JavaScript? hmm.... how many hotshot frameworks and major updates to hotshot frameworks have we seen in the past 2 years? Compared to that, people using inheritance carelessly is just a minor problem.

Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by scrollaway on Saturday December 13, 2014 @08:11AM (#8745107)
> After a few months of team work on the same code, one day, somebody got careless with the "x" key in vim and deleted the semicolon after the for.

Not to detract from the subject at hand because you do have a point, but that sort of error is caught by patch reviews. Even on my own projects I review diffs before/after I commit them.