Now over at my github account: a minimalist implementation of parser combinators. Parser combinators provide an easy yet powerful way of implementing parsers, without the need of understanding compiler theory or formal grammars (though it can't hurt, of course). They also form the basis for my Koopa project, precisely because you can easily extend this technique to fit your needs.
This minimalist implementation may be slightly too minimalist, though. It only tells you whether something can be parsed or not. There is no way to extract anything useful while doing so —yet.
"The universe is not required to be in perfect harmony with human ambition."
Carl Sagan (1934 - 1996)
Showing posts with label mnmlst. Show all posts
Showing posts with label mnmlst. Show all posts
April 10, 2014
April 01, 2014
Minimalist Entity/Component System
I just uploaded a new addition to the minimalist code series. This time it's a minimalist version of an Entity/Component System. An ECS is a bit of a specialized architecture for modeling complex systems of dynamic objects. The origins for such systems come from the gaming world, but it has made its way into very different kinds of applications (the LightTable IDE is a great example here). If you're interested, the Entity Systems Wiki is a great resource for going deeper.
Javascript makes it really easy to set up such a system. In fact, the example I added is way more complex and took much longer to write than the actual engine itself. I was debating with myself whether or not to go for a more fluent API than what I provided now, but I was somewhat worried that I would be explaining the fluent part more than the actual ECS principles. If anyone is still interested in a more fluent version, though, let me know and I'll spend some time on that.
Javascript makes it really easy to set up such a system. In fact, the example I added is way more complex and took much longer to write than the actual engine itself. I was debating with myself whether or not to go for a more fluent API than what I provided now, but I was somewhat worried that I would be explaining the fluent part more than the actual ECS principles. If anyone is still interested in a more fluent version, though, let me know and I'll spend some time on that.
March 15, 2014
Minimalist Dataflow Engine
I'm really enjoying these minimalist literate programming exercises, so here is another: a minimalist dataflow engine named "dfntly". It is very loosely inspired by the excellent Knockout library, but obviously has much fewer features. I would like to add some support for observable arrays, for example, and for asynchronous calculations where the dataflow engine only calculates further when the reply comes in. But that's something for another day.
In the meantime, if you feel like it, give it a go!
In the meantime, if you feel like it, give it a go!
February 22, 2014
Minimalist Asynchronous PVM
So adding support for asynchronous tasks turned out not to be so difficult. With a little help of Q's promises and support for composing them all it took was a minor rewrite of the main tick function...
Anyway, this version of the minimalist PVM can be found here, together with an example which queries the OpenWeatherMap API.
Note that in the process of doing this I also added some minor tweaks to the basic version of the PVM; the most useful of which is the ability to define a starting runtime state for the process upon activation. I extended the examples there as well to showcase this.
Anyway, this version of the minimalist PVM can be found here, together with an example which queries the OpenWeatherMap API.
Note that in the process of doing this I also added some minor tweaks to the basic version of the PVM; the most useful of which is the ability to define a starting runtime state for the process upon activation. I extended the examples there as well to showcase this.
February 18, 2014
Minimalist Literate Programming
As a quick follow-up to the minimalist PVM you can now find a very simple literate programming tool over at my github. It's a single Perl script which converts source code into a Markdown document. It does this by extracting the text from the comments in the source code, and wrapping the code itself in code blocks. Want an example of the output ? The README.md for the tool is exactly that. (Self-documenting code FTW!)
February 15, 2014
Minimalist Process Virtual Machine
Over at my github account (see, I do have one) I just added a minimalist implementation of a Process Virtual Machine (PVM).
Wait, what ?
Let's start with what a PVM is. You can find a thorough description of it here, but in brief it is an engine which can drive automated business processes and workflows. It actually forms the core of JBPM and Activiti. (If you really feel like geeking out on workflow engines you should definitely head over to Joram Barrez's blog, which has all sorts of Activiti craziness in it.)
I really wanted to figure out what makes such an engine tick, and while I can look at the source code for JBPM and Activiti they were never meant as an educational example. These engines have real work to do, and so come with usual amount of hardening and boilerplating. Rather than deep-diving through all that I wanted to see what a minimalist implementation could look like.
When it comes to minimalist implementations a lot depends on your choice of language. Ideally you want something which is really flexible without imposing a lot of structure. Prototype-based languages are a great fit and, as it so happens, Javascript is a popular example of one.
So that's where I went. I've got a minimalist PVM capable of running in a Node.js environment. As you'll see there's very little code to it; and I actually spent most of the time getting everything into the form of a literate program.
Because it is very minimalist there are certain features it does not (yet) have. The big ones are wait states (e.g. for human interaction), asynchronous tasks (e.g. for doing IO or REST calls), and persistence. In a future version I'll see if I can add those in a minimalist way as well, but for now this will do to satisfy my curiousity.
If you like, let me know; and feel free to experiment further.
Wait, what ?
Let's start with what a PVM is. You can find a thorough description of it here, but in brief it is an engine which can drive automated business processes and workflows. It actually forms the core of JBPM and Activiti. (If you really feel like geeking out on workflow engines you should definitely head over to Joram Barrez's blog, which has all sorts of Activiti craziness in it.)
I really wanted to figure out what makes such an engine tick, and while I can look at the source code for JBPM and Activiti they were never meant as an educational example. These engines have real work to do, and so come with usual amount of hardening and boilerplating. Rather than deep-diving through all that I wanted to see what a minimalist implementation could look like.
When it comes to minimalist implementations a lot depends on your choice of language. Ideally you want something which is really flexible without imposing a lot of structure. Prototype-based languages are a great fit and, as it so happens, Javascript is a popular example of one.
So that's where I went. I've got a minimalist PVM capable of running in a Node.js environment. As you'll see there's very little code to it; and I actually spent most of the time getting everything into the form of a literate program.
Because it is very minimalist there are certain features it does not (yet) have. The big ones are wait states (e.g. for human interaction), asynchronous tasks (e.g. for doing IO or REST calls), and persistence. In a future version I'll see if I can add those in a minimalist way as well, but for now this will do to satisfy my curiousity.
If you like, let me know; and feel free to experiment further.
Subscribe to:
Posts (Atom)