Live data from Hacker News

How I fixed a bug in Atom

davidvgalbraith.com

21–30 of 189 posts

Re: How I fixed a bug in Atom

#22

Could be avoided if the editor had a full AST of the code instead of using regular expressions to try to make sense of it.

The syntax will be broken 99% of the time and making a parser that recovers gracefully under any circumstance is very hard.

You could make an editor that only allows valid programs but that opens up a lot of UI problems, it was tried many times and it never took off in practice.

Re: How I fixed a bug in Atom

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

Re: How I fixed a bug in Atom

#25
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…

Whether or not the core of your criticism is legitimate, I have a certain distaste for this kind of negativity and I don't feel that it adds to the quality of discussion on this site.

Re: How I fixed a bug in Atom

#26
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)

Just tried this, you are correct... http://imgur.com/J9tP7lk (note the incorrect bracket highlighting)

Re: How I fixed a bug in Atom

#27
post #10

First of all, this is why people should stop adding stupid features to regular expressions. A sane regular expression implementation has no pathological cases. DFA generation can be done in O(n^2) from memory (in the absolute worst case O(n) is average), and matching can't be worse than O(m) or similar (n is the size of the regex and m the size of the string). When you add features like back references and recursive…

The support of fancy features like backtracking does not cause any degradation of performance for simple regular expressions. You are not obliged to use them, but they do not hurt you when you do not use them. Some other people may love them despite their poor complexity.

Re: How I fixed a bug in Atom

#28
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…

Not to be too critical without reason, but I think you meant http://www.merriam-webster.com/dictionary/pastime.

Also, I think you're being rather rude.

Nobody forces you to read whatever the OP posts, much less dig up the history to see if you agree with how he chooses to spend his time or not.

Re: How I fixed a bug in Atom

#29
post #10

First of all, this is why people should stop adding stupid features to regular expressions. A sane regular expression implementation has no pathological cases. DFA generation can be done in O(n^2) from memory (in the absolute worst case O(n) is average), and matching can't be worse than O(m) or similar (n is the size of the regex and m the size of the string). When you add features like back references and recursive…

I don't always want to spend insane amounts of time writing full AST parsers. Sometimes it is a lot easier to write a simple, hacky, throwaway regex. It's a bit much to claim that backtracking regular expressions, a very useful tool sometimes, should never ever be used and everybody should waste loads of time writing careful code even in situations where it isn't required. The problem is not the tool. The problem is…

I don't often write AST parsers but when I do, I don't and write regexps instead.

Re: How I fixed a bug in Atom

#30
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…

> I am sorry but I don't really appreciate it

Well I do, and I found the article fascinating, so I'm glad your opinion isn't the only one that matters on Hacker News.

Post reply on HN