Ragel State Charts
zedshaw.com
zedshaw.com
The difference is that ragel is oriented around consuming a stream-of-chars: the generated state machine expects to be consuming chars as input.
You can pick up on this in the writeup even though Zed's not pointing it out: he first has to define his messages as chars (eg: 'done' == 'D'), then he specifies his states + transitions in terms of those definitions.
SMC instead generates methods for each 'message' and it's the enveloping program's responsibility to call the correct method to update the state.
This is cleaner for simpler state machines.
None of this is intended as a knock on ragel, btw: it's a very solid piece of software, and for more-complicated state machines should be the go-to choice.
<http://www.cs.brown.edu/~sk/Publications/Talks/SwineBeforePe...; is a fun talk that describes an implementation of state machines in Scheme macros. With a good compiler, those tail calls will be translated to local branches!
Also thanks for this: http://news.ycombinator.com/item?id=134834
It's a wonderfully useful statement, and gets at what I was trying to get at much better than I could.
I stand by SMC being a better fit for simple finite state machines (eg: the kind best specified using state charts); typical uses I've put SMC towards are for ensuring consistency of internal state in complicated UI elements and similar tasks...for which there's no real 'regular language' that needs parsing (or, at least: no real gain to be had in setting up a regular language of input-events when state charts will do).
I'm guessing you're the thurston behind ragel: thank you for making ragel, for making it available, and for making it so well; it is an extremely high-quality piece of work.
But +1 for SMC; used it quite a few times already, in many cases in new product versions replacing legacy code where the original insisted to implement a partially-identified state machine "by hand" (and invariably ended up tripping over all sorts of unforeseen and edge cases).
I've also found that merely the exercise of thinking in terms of FSM definition, often helps to simplify the problem (for example by identifying that there may actually be multiple independent/"orthogonal" FSMs present, instead of one monolithic one).
My background is as a EE, and I work in hardware. I can't imagine not knowing about state machine design. Is Zed's statement accurate for those with a pure software focus?
I personally think it's important to know about state machines. at least once in a lifetime you are going to write a DSL or parse specific input, and these are use cases were the application of state machines is pretty useful.
oh and by the way: Zed has written a nice tutorial about finite state machines, called "A Painless Introduction To Finite State Machines" and located at http://lamsonproject.org/docs/introduction_to_finite_state_m... . it's worth reading it if you're interested in the subject!
(a) just because you covered it in a class doesn't mean you remember it five years later
(b) lots of people rise through the ranks of IT without formal CS training
(c) some CS programs are not so reputable
(Granted, the education system might have some responsibility there, but personally I recall examples being made. There's only so hard the profs can make the point that this stuff actually matters.)
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.
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.
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.
Additionally, I find state machines in many business domains. Everything that some kind of "ticket" object (be it customer support or defect tracking) will (or should!) have state machines, with rules of varying complexity, to escalate the status of these tickets.
Having the ability to see good code allows an investor to find the hidden gems-- excellent programs that no one knows about because they aren't promoted. I'd be willing to bet that there is a goldmine of ideas implemented in already existing code, just waiting to be discovered.
I'm not sure I agree though, for two reasons.
First, the projects you mentioned are great projects, but they're not something an angel investor would be interested in.
Second, most startups - or at least web startups - do not fail for lack of technical expertise. The product might be an unusable mess, or it might solve entirely the wrong problem, or it might be marketed in completely the wrong way, or there might simply not be enough demand for it. I'm sure there are cases where a startup fails for technical reasons, but I'm willing to bet real money that in the vast majority of cases investors and founders don't say "man, if only the programmers were a tiny bit better, we could've made it". (even when they do say it, chances are that wasn't the real problem)
Tons of people have great ideas, but their success is going to be determined by how well they can code. When you say that startups don't fail because of a lack of technical expertise, you're right in a limited sense. Startups of decent calibur will not fail because the founders don't know closures, continuations, design patterns, etc; they'll still be able to build products. They just wont have the vision to know the full range of products they are capable of building. If that's the case, you'll only last as long as it takes for a better hacker to enter the market. Experts Exchange being overtaken by Stack Overflow is a perfect example. Same idea, but because actual hackers are running Stack Overflow, it's trouncing Experts Exchange, with no signs of slowing down.
As far as I can tell Stack Overflow is a perfect example of a site where technical talent is almost irrelevant. Just like this site. We're not here because this site is written in Arc. We're here because of the community.
I think your second point is off, too. Your argument is that startups usually fail for non-technical reasons, and I agree. But that's what tsally was trying to say: it's a rare person who can smell-out good technical work, understand it, and realize it's contribution. This is the sort of person you'd want to have as an adviser when it comes time to determine a business model or how to advertise.
This is why research and open source are important. And kudos to Adrian.
Back in my last job, I implemented a Java libconfig clone using Ragel. It was the most fun I ever had at that company.