Publicaciones sobre croupier (publicaciones antiguas, página 1)
Croupier release v0.1.7 is out
Version v0.1.7
- Improve handling of tasks without outputs.
They now have an ID they can be referred by.
Full Changelog: v0.1.6...v0.1.7
New Project: Hacé, like Make but lame
Since my dataflow library Croupier is sort-of-functional, I needed a project where I could exercise it.
This is important, because it's how you know if the design of a library is good, extensible, and so on.
So, I decided to write a minimal make-like-thing.
Well, good news, that was easy!
In about 50 lines of code I could write a thing that will run shell commands in a dependency dataflow!
It's called Hacé (don't bother about how to pronounce it, I don't care) which is "imperative make, second person singular" in argentinian spanish, so it's an order to make.
I will spend a week or two making it into something semi-useful, since it has some advantages over Makefiles, such as reacting to file content and not file date, but its destiny is probably just to be a testbed for Croupier.
Croupier releases happened
A few releases of my Crystal task/dataflow library Croupier have gone out.
The main topic of work has been:
- Increase code quality (I am still learning the language after all)
- Make the API reasonable
- Remove restrictions
On the latter subject, Croupier will now happily handle tasks with zero or many inputs, with zero or many outputs, or task that share some or all of their outputs, even if their inputs differ.
In all those cases it will try to Do The Right Thing, but it is arguable whether it does or not.
So, the API and what it can do is changing often. However the example in the README only needed one change from the first release to now (because it's pretty simple)
I know nobody is ever going to use it, it's a niche library in a niche language, but I am having fun writing it, and the concepts are quite widely applicable, so it's educational.
New project: croupier
Intro to Dataflow Programming
This post is about explaining a new project, called Croupier, which is a library for dataflow programming.
What is that? It's a programming paradigm where you don't specify the sequence in which your code will execute.
Instead, you create a number of "tasks", declare how the data flows from one task to another, provide the initial data and then the system runs as many or as few of the tasks as needed, in whatever order it deems better.
Examples
Put that way it looks scary and complex but it's something so simple almost every programmer has ran into a tool based on this principle:
make
When you create a Makefile
, you declare a number of "targets", "dependencies" and "commands" (among other things) and then when you run make a_target
it's make
who decides which of those commands need to run, how and when.
Let's consider a more complex example: a static site generator.
Usually, these take a collection of markdown files with metadata such as title, date, tags, etc, and use that to produce a collection of HTML and other files that constitute a website.
Now, let's consider it from the POV of dataflow programming with a simplified version that only takes markdown files as inputs and builds a "blog" out of them.
For each post in a file foo.md
there will be a /foo.html
.
But if that file has tags tag1
and tag2
, then the contents of that file will affect the output files /tags/tag1.html
and /tags/tag2.html
And if one of those tags is new, then it will affect tags/index.html
And if the post itself is new, then it will be in /index.html
And also in a RSS feed. And the RSS feeds for the tags!
As you can see, adding or modifying a file can trigger a cascade of changes in the site.
Which you can model as dataflow.
That's the approach used by Nikola, a static site generator I wrote. Because it's implemented as dataflow, it can build only what's needed, which in most cases is just a tiny fragment of the whole site.
That is done via doit an awesome tool more people should know about, because a lot more people should know about dataflow programming itself.
So, what is Croupier?
It's a library for dataflow programming in the Crystal language I am writing!
Here's an example of it in use, from the docs, which should be self-explanatory if you have a passing knowledge of Crystal or Ruby:
require "croupier"
b1 = ->{
puts "task1 running"
File.read("input.txt").downcase
}
Croupier::Task.new(
name: "task1",
output: "fileA",
inputs: ["input.txt"],
proc: b1
)
b2 = ->{
puts "task2 running"
File.read("fileA").upcase
}
Croupier::Task.new(
name: "task2",
output: "fileB",
inputs: ["fileA"],
proc: b2
)
Croupier::Task.run_tasks
Why?
Because I want to write a fast SSG in Crystal, and because dataflow programming is (to me) a fundamental tool in my toolkit.
Anything else?
I will probably also do a simple make-like just as a playground for Croupier.