News for hackers. Stuff that matters.
Re:A Regular Expression Matcher (2007) by leoh on Thursday February 13, 2020 @11:53AM (#22319201)
This would be a very good technical interview question — i.e. "implement this simple regex specification."
Re:A Regular Expression Matcher (2007) by elteto on Thursday February 13, 2020 @12:41PM (#22319670)
We software types must be masochists. It took Rob Pike an hour in the comfort of his private office to write this piece of code. How is this _at all_ like a typical software interview?
Re:A Regular Expression Matcher (2007) by dmos62 on Thursday February 13, 2020 @01:31PM (#22320085)
You're right. At the same time, could it be interesting to see how someone approaches (not solves) an intimidating problem?
Re:A Regular Expression Matcher (2007) by reificator on Thursday February 13, 2020 @05:40PM (#22322135)
Also known as hazing.
Re:A Regular Expression Matcher (2007) by dekhn on Thursday February 13, 2020 @03:05PM (#22320963)
There's a common question, "convert an RE into an NFA" (https://en.wikipedia.org/wiki/Thompson%27s_construction)
Re:A Regular Expression Matcher (2007) by abecedarius on Thursday February 13, 2020 @03:15PM (#22321043)
Have you seen that used for interviewing? Yes, some people can do it in a 1-hour interview, but wouldn't you rather ask something that can't be done from memory?
Re:A Regular Expression Matcher (2007) by dekhn on Thursday February 13, 2020 @03:16PM (#22321050)
I know engineers who have asked it, yes. It really seems to be a test for "who was paying attention to that one lecture in CS205 near the end of the semester"
Re:A Regular Expression Matcher (2007) by abecedarius on Thursday February 13, 2020 @03:29PM (#22321145)
Wow. That's quite a tricky test, too -- if you study Thompson's original paper you can see plenty of pitfalls. E.g. his main code would loop forever on a star of a star, and he solves this in an appendix with a preprocessor to rewrite regexes of that kind, only it looked like that rewriting would blow up the size of the regex exponentially in the length of the stack of stars. No hire!
Re:A Regular Expression Matcher (2007) by dekhn on Thursday February 13, 2020 @04:44PM (#22321727)
it doesn't any worse than what Huffman did for his CS classes at UCSC.
Re:A Regular Expression Matcher (2007) by glangdale on Thursday February 13, 2020 @04:24PM (#22321566)
I have seen this one go by, which, from the perspective of someone who has been doing regex implementation for 14 years, more or less, is fairly amusing. It seems unfair, as someone aware of potential pitfalls of backtracking would presumably feel obligated to build a automata-based solution; someone aware also of the potential pitfalls of DFAs (failure to determinize quickly on some nasty patterns) might also feel obligated to build a Thompson or Glushkov NFA solution as well.

It's quite possible you might turn someone competent into a gibbering wreck (they are asking me to implement RE2 or Hyperscan in an hour!) :-)

Re:A Regular Expression Matcher (2007) by adambyrtek on Thursday February 13, 2020 @12:07PM (#22319332)
I used to use this exact problem years ago when interviewing candidates at Google. At that time I thought it was a great question, but now I'm not that sure anymore if this approach to interviewing is the best way to assess candidates.
Re:A Regular Expression Matcher (2007) by leoh on Thursday February 13, 2020 @12:28PM (#22319536)
Super interesting. Could you say more? Perhaps it depends a bit on the role?