Live data from Hacker News

How I fixed a bug in Atom

davidvgalbraith.com

41–50 of 189 posts

Re: How I fixed a bug in Atom

#41
I wonder if this is why Atom feels so snappy now. It's my main editor as of a few weeks ago because the speed is now good. It used to choke on a 1000 line rails controller, but now it edits that file just perfectly.

Congratulations to the author, great commit! Small payload, enormous benefits.

Re: How I fixed a bug in Atom

#42
post #24

It 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.

Well, regex101 [1], linked in the article, detects it, so it's definitely possible. Whether that code is open, or it's easy to replicate, is another matter.

[1] https://regex101.com/

Re: How I fixed a bug in Atom

#43
post #15
post #13

Earlier 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.

No, nobody should be put off taking on any bug. I hugely appreciate the fact that different people are up for different challenges and, therefore, with enough people, bugs should be fixable. Your ethos appears to be 'some bugs are just boring and not important enough; never bother fixing them'.

Re: How I fixed a bug in Atom

#44

Completely 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…

First, good news: The Atom teams is (slowly) moving away from Coffeescript towards modern JS, and I think they'd agree (unofficially) that the choice proved to be a mistake.

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

#45
post #11

I 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)

Sometimes I feel like the difference between a junior, intermediate, and senior developers is that the junior hasn't yet figured out how to use regexps, the intermediate dev has, and the senior dev has figured out not to.

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

#46

Completely 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…

you're not familiar with coffeescript and used to the many javascript warts, so your perspective is biased.

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
post #8

"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…

yea but if its a slowdown when you press the fricken enter key it obviously affects some. its not like atom has pretty good fix.

Re: 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 ).

https://github.com/atom/node-oniguruma

Re: How I fixed a bug in Atom

#50
post #26

Earlier 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)

Jesus, how did nobody catch this before? The least a code editor should do is to match parentheses correctly.
Post reply on HN