Congratulations to the author, great commit! Small payload, enormous benefits.
How I fixed a bug in Atom
41–50 of 189 posts
Re: How I fixed a bug in Atom
#42It seems there's a need of a regex linter (eslint plugin?) that could warn on pathologically complex regexes. Is building this kind of plugin feasible? Having said that, probably few people would explicitly opt in to using such a plugin unless it's bundled by default to some linter.
Re: How I fixed a bug in Atom
#43Earlier quoted context omitted.
Sure the title is a bit sensationalist, but there was a legitimate issue to fix and he did fix it. Plus, it is a good write up that explains the problem, solution, and the steps taken well. It would be a shame to see others put off from fixing bugs, and posting commentary on the solution, in open source software for fear of being put down.
Others should be put off from taking more credit than due in the title of their posts and from taking on bugs that aren't important just for that purpose.
Re: How I fixed a bug in Atom
#44Completely unrelated to the issue at hand... I had no idea Atom was written in CoffeeScript. I thought it was written in Javascript, which made me positive at the thought of hacking into it. But this code? Definitely giving me a headache, and my interest went down to zero. There seems to be a meme and unchallenged claim in hacker circles that CoffeeScript is somehow more "readable" and easier to understand. Allow me…
Beyond that...
1. The JS world moves stupidly fast, and Coffeescript is a relic of a now-vanished age. It was born, it evolved, and it died. Back in those long ago days of, um, 5 year years ago, there was no ES6, and Coffeescript looked a lot more attractive. So much so, in fact, that ES6 stole a bunch of Coffeescripts better features.
2. If you're familiar with Coffeescript, it's terse and expressive and very readable. If you're not, it looks like gibberish. But that's true of any language. The proper critique of Coffeescript should be "hey, not a lot of potential collaborators know it, so it'll see unreadable to them", not "hey, Coffeescript is generally unreadable". JS is pretty confusing and unreadable if you don't know it too.
Mind you, Atom was released 2 years ago, when Coffeescript was already starting to look dated. And it was an open source project looking for contributors so...yeah. Bad, bad choice. :)
Re: How I fixed a bug in Atom
#45I got to the bottom and couldn't believe that the solution chosen was to modify the regexp instead of use a for loop. He did such a great job explaining that the code is really just trying to count the number of parentheses or braces to see if they're imbalanced, that it felt the next step was "so I wrote a really simple set of loops that is fast enough on short strings and way less crazy otherwise".
Same here. Also, I don't use Atom, but looking at the expression I'm pretty sure it fails to account for strings with parentheses. The way the matching is done, it looks like it will happily count: func("some call :)") as extra closing paren. (regex101 agrees)
I kid, but...really. The number of times I've seen people burnt by non-trivial regexps in production code is absurd.
"Oh, I need to mangle this CSV that's in the wrong format"? Sure, write a one-off regexp.
"Hm, there might be a security vulnerability in this URL parameter, I need some way to filter out bad inputs..." Oh hell no.
Literally two weeks ago I tracked down a crazy bug to a regexp someone had written to try and correct mistyped email addresses in a signup form (?!) that deleted "invalid" characters. Like a "+". So many facepalms for one short line of code...
Re: How I fixed a bug in Atom
#46Completely unrelated to the issue at hand... I had no idea Atom was written in CoffeeScript. I thought it was written in Javascript, which made me positive at the thought of hacking into it. But this code? Definitely giving me a headache, and my interest went down to zero. There seems to be a meme and unchallenged claim in hacker circles that CoffeeScript is somehow more "readable" and easier to understand. Allow me…
But Coffeescript makes many things easier and has good tooling (just another loader in webpack). While not perfect, It is a reasonnably efficient tool for front-end dev.
Try a tutorial, you may be surprised.
Re: How I fixed a bug in Atom
#47"How I fixed a bug in Atom that affected almost no one, and then spent quite a lot of time writing an article about it, then wrote a title that attempted to give me more credit than I deserved" .. which is his main pass time if you see his other posts, rather than spending his effort on fixing bugs that actually affect a lot of people. I am sorry but I don't really appreciate it and have trouble getting over the misr…
Re: How I fixed a bug in Atom
#48Re: How I fixed a bug in Atom
#49> This defines a named capture group, . I thought JavaScript regexes don't support named capturing groups. Is Atom using some library or custom functionality for that? EDIT: Or is it a CoffeeScript addition? In their table of contents I only see regex blocks mentioned though ( http://coffeescript.org/#regexes ).
Re: How I fixed a bug in Atom
#50Earlier quoted context omitted.
Same here. Also, I don't use Atom, but looking at the expression I'm pretty sure it fails to account for strings with parentheses. The way the matching is done, it looks like it will happily count: func("some call :)") as extra closing paren. (regex101 agrees)
Just tried this, you are correct... http://imgur.com/J9tP7lk (note the incorrect bracket highlighting)