Top all-time · #110
swtchboard
Personal blog · swtch.comprogrammingsystems
swtchboard is a personal blog at swtch.com about programming and systems. Since 2007, 356 different Hacker News readers have linked it 534 times, most often “Regular Expression Matching Can Be Simple and Fast (2007)”. No feed was found, so read it on the site itself.
Sometimes recommended · 8 of 40 sampled comments recommend it?
Why HN links it
HN readers link Russ Cox's regular-expression articles on swtch.com to explain NFA matching, backtracking and RE2. Commenters call them very well written and easy to understand.
- Recommended for · 8 comments
- 'very well written', 'easy to understand', 'pretty indispensable', 'good pictures', 'worth a read', 'a great example of using pointers in C'
Summarised by Claude from a sample of 40 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Regular Expression Matching Can Be Simple and Fast (2007)91 people · 109 mentions · first linked 2015-04-14
- Regular Expression Matching Can Be Simple And Fast56 people · 60 mentions · first linked 2008-01-22
- Implementing Regular Expressions (2007)32 people · 38 mentions · first linked 2015-06-08
- How Google Code Search Worked: Regex Matching with a Trigram Index (2012)32 people · 32 mentions · first linked 2015-05-22
- Plan 9 from User Space23 people · 33 mentions · first linked 2009-05-05
- Regular Expression Matching: The Virtual Machine Approach (2009)18 people · 19 mentions · first linked 2016-02-20
- Implementing Regular Expressions16 people · 16 mentions · first linked 2010-08-23
- How Google Code Search Worked13 people · 14 mentions · first linked 2012-01-19
- Bell Labs and CSP Threads12 people · 20 mentions · first linked 2007-11-05
- Libtask: a Coroutine Library for C and Unix9 people · 11 mentions · first linked 2009-06-27
What Hacker News says?
> What is currently still not feasible is to create a custom git repository whose HEAD matches that of the Linux kernel. I'm not convinced that's good enough. In git, the SHA1 is always the hash of a gzip, which is subject to tricks[1] where a header might be prepared and then some padding inserted to collide a malicious tail. [1]: http://swtch.com/r.zip
Comment linking /r.zip
on “Announcing the first SHA-1 collision”Submitted How Google Code Search Worked: Regex Matching with a Trigram Index (2012) as a story · 434 points
HN discussionThanks for these tips -- I've seen your visualizations and it's nice to hear from people who have done it! It's cool that you were able to reproduce the diagram quickly and in a small amount of code. It looks a bit foreign to me, probably because I don't know much about SVG (or canvas for that matter). And as I understand it Observable is almost another language on top. (I do know HTML, CSS, and JS pretty well, but…
Comment linking /~rsc/regexp/regexp1.html
on “Gears”Submitted How Google Code Search Worked as a story · 287 points
HN discussionFor anybody who's lost: Russ Cox is the original author of re2, a fast C++ library implementing regular expressions that are guaranteed to run in linear-time. There's a collection of articles they wrote talking about regexes and various pitfalls: https://swtch.com/~rsc/regexp/
Comment linking /~rsc/regexp/
on “An Unbelievable Demo”Submitted How Google Code Search Worked (2012) as a story · 168 points
HN discussionYes, I recall that he talks about the multi-engine approach with respect to both PCRE and RE2 somewhere in these articles: https://swtch.com/~rsc/regexp/ Sorry I don't have the exact reference handy. Apparently the author of PCRE tried to implement an NFA/DFA engine for some regexes as well. And I think RE2 might also have different strategies for different regexes as well, but I forget the details (it might be rela…
Comment linking /~rsc/regexp/
on “Stack Overflow Outage Postmortem”Submitted Regular expression matching can be simple and fast (2007) as a story · 141 points
HN discussionAdmittedly I haven't stepped through all the code, but it's 958 lines and doesn't look horrible. It somewhat resembles the example C programs here: https://swtch.com/~rsc/regexp/ In particular there don't seem to be crazy optimizations and non-portable stuff like you see in other production regex implementations and in interpreters. It's pure ANSI C. The functions are all short -- no 1000 line monsters like I've see…
Comment linking /~rsc/regexp/
on “Stack Overflow Outage Postmortem”Submitted Regular Expression Matching with a Trigram Index (2012) as a story · 96 points
HN discussionExperienced something similar myself. Was even thinking about creating regular expression library which just allow "safe" and fast expression. The trick would be to not allow only expression that can be translated easily to state automate. Good regex: "Phone number [0-9]* " Bad regex: ";Name=. ;" as . can also match ";" and it can lead to bad backtracking. You should rewrite this regex to ";Name=[^;] ;" RE2 is proba…
Comment linking /~rsc/regexp/regexp1.html
on “Stack Overflow Outage Postmortem”Submitted Regular Expression Matching Can Be Simple And Fast as a story · 95 points
HN discussionHa! The same bug happened internally at my company. In that case it was a regex matching a URL taking so much CPU as to cause a DOS of a proxy server. I won't be surprised if it's happened to someone here too. This is very timely, because minutes ago, I made a link to Russ Cox's articles in my Kernighan awk repo: https://github.com/andychu/bwk https://swtch.com/~rsc/regexp/regexp1.html If you are not familiar with t…
Comment linking /~rsc/regexp/regexp1.html
on “Stack Overflow Outage Postmortem”Submitted Why threads vs events is a nonsensical question. as a story · 92 points
HN discussionre2 is described here: http://swtch.com/~rsc/regexp/regexp3.html
Comment linking /~rsc/regexp/regexp3.html
on “Node.js in Flame Graphs”Submitted Regular Expression Matching Can Be Simple and Fast (2007) as a story · 78 points
HN discussionI agree with this ... I coded a Thompson NFA [1] out of interest a few years ago; definitely recommended as an exercise. [1] https://swtch.com/~rsc/regexp/regexp1.html
Comment linking /~rsc/regexp/regexp1.html
on “More challenging projects every programmer should try”Submitted Regular Expression Matching Can Be Simple and Fast (2007) as a story · 73 points
HN discussionHave a look at RE2 and Russ Cox's paper [0]. I found it particularly elegant the use of a small LRU cache to effectively lazily convert portions of the NFA to a DFA. A fast regex engine is pretty easy to implement, as long as you don't need extensions, particularly backreferences. [0] https://swtch.com/~rsc/regexp/regexp1.html
Comment linking /~rsc/regexp/regexp1.html
on “More challenging projects every programmer should try”Submitted Regular Expression Matching in the Wild as a story · 68 points
HN discussionYes, I certainly benefitted very much from the series. Here is the first episode - devastating, convincing, easy to understand and very well written: https://swtch.com/~rsc/regexp/regexp1.html
Comment linking /~rsc/regexp/regexp1.html
on “Russ Cox is stepping down as the Go tech lead”Submitted 9vx: a port of the Plan 9 operating system to FreeBSD, Linux, and OS X as a story · 64 points
HN discussionAgreed, see the index of those posts: https://research.swtch.com/vgo Other contenders I find myself sharing and re-reading: - https://swtch.com/~rsc/regexp/regexp1.html - https://swtch.com/~rsc/regexp/regexp4.html - https://research.swtch.com/bisect - https://research.swtch.com/zip
Comment linking /~rsc/regexp/regexp4.html
on “Russ Cox is stepping down as the Go tech lead”Submitted Regular Expression Matching: the Virtual Machine Approach as a story · 53 points
HN discussionOne thing that was interesting to me: The outage was caused by a regex that ended up doing a lot of backtracking, which caused PCRE, the regex engine, to essentially handle a runaway expression. This reminded me of a HN post from a couple months back by the author of Google Code Search, and how it worked: https://swtch.com/~rsc/regexp/regexp4.html . Interestingly, he wrote his own regex engine, RE2, specifically bec…
Comment linking /~rsc/regexp/regexp4.html
on “Details of the Cloudflare outage on July 2, 2019”Submitted Regular Expression Matching: The Virtual Machine Approach (2009) as a story · 49 points
HN discussionRuss Cox also wrote RE2: https://swtch.com/~rsc/regexp/
Comment linking /~rsc/regexp/
on “Details of the Cloudflare outage on July 2, 2019”Submitted Semaphores in Plan 9 [pdf] as a story · 49 points
HN discussionNote: Golang's stdlib regexp ( https://golang.org/pkg/regexp/ ) is guaranteed to run in time linear to the size of input. Russ Cox has a detailed article https://swtch.com/~rsc/regexp/regexp1.html
Comment linking /~rsc/regexp/regexp1.html
on “Details of the Cloudflare outage on July 2, 2019”Submitted Implementing Regular Expressions as a story · 48 points
HN discussion