Hacker News new | ask | show | jobs
by mgreenbe 6190 days ago
RE and FSM are equivalent. There are no problems handled better by regular expression than by FSM. Of course, this is for a very narrow definition of problem. And, by most accounts, a narrow definition of FSM. SCM calls its systems FSMs even though they have stacks. Sure, the number of programmer defined states is finite, but the number of system states is infinite. Also, what do you mean by better? :)

So, for an un-specious response: FSMs are well suited to stream processing, while REs do well with block processing. (And are generally implemented by compilation into FSMs, anyway.) FSMs also do well as program logic/control structures, often clarifying the underlying system.

1 comments

Well, equivalent in there is a direct transformation from one to the other, but in the sense of a programmer's approach, not really equivalent.

Yes, REs are transformed to FSM, but the problem-solving approach provided by skills in writing FSM is different, and according to the article, often better.