On the Unreasonable Effectiveness of Finite State Machines
blog.kevmo314.com
blog.kevmo314.com
No. That is simply not true. See https://en.wikipedia.org/wiki/Chomsky_hierarchy#The_hierarch...
As a simple example, try to make an FSM (which will have a fixed number n states) for matching parentheses – then I can always make a parenthesized expression of a certain size that your FSM cannot match. So you try to add some states to the FSM, now it can handle that expression. But then I wrap the expression in more parentheses and your FSM fails. However, a computer (or turing machine – or in this case even a pushdown automaton) can always match it.
(But the limitations of FSM's are also strengths – just like some people like to keep parts of their programs pure or free of I/O and feel safe when their compiler can check that, you know that the FSM itself won't eat your memory, and has a bunch of other provable characteristics.)
For the post I was referring to the physical computers we work with daily. I should clarify :)
In the declaration
let door = "open";
the intended type of door is DoorState, but it could also be a string type. How does the compiler decide which is the best choice? By looking ahead? let door: DoorState = "open";
works though. :) I've updated the post and a link to the TS playground.