Hacker News new | ask | show | jobs
by wglb 6190 days ago
Mine as well. State machines early on. However, immediately went into computer programming but that stuck with me.

If a person reads GoF carefully, they talk about it there. Also, UML has a whole state machine concept segment and Uncle Bob wrote a package years ago to handle state machines.

I wonder if programmers rely too much on RE for problems that would be best handled by FSM.

Excellent article, excellent software.

1 comments

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.

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.