The Dongola Times

(Anachronistic) Dispatches from the Kingdom of Makuria.
19th of November, 2014

The Next Language for the Next Muse-ic

Some months ago, I wrote me a small music streaming application, complete with a sweet web front end. I called it Muse-ic; as in “in the manner of a muse.” I was satisfied with it, but now I want to extend its capacity in a fierce way, and such things I never do in Ruby. It was a work of Ruby for the streaming component, with Rails in particular doing the web front-end. This is what happens when I start out trying to make a small, simple toy, and then it becomes too cool to keep at that level.

The old version was developed on GitHub, as is the case with other toys. The new version may be, at least at first, developed away from the public, as is fitting for serious work. I am going to try to avoid the Second System Syndrome, but the main new feature I want to incorporate is a very fine-grained randomisation/mixing. At present, the mixing is simple, and such simple things can be done in Ruby. The stuff I want to do next is complex enough to require an alternative language; but I seem to have settled on just two languages, as I slide deeper into old age: Ruby and Haskell.

I do not have time for scripting languages that are not fun; because if I am scripting, I want to have fun. If I am scripting, I am doing a toy of some sort. Ruby is the best way to have fun without firing up a Smalltalk image. But if I am not toying about, then Haskell is all I use. This is actually where it gets interesting, because I have just re-discovered Yesod, some Haskell web framework that seems able to replace even Rails in my normal work.
It has turned out, then, that the two components of Muse-ic can be (re-)implemented in Haskell, and that is what I am going to be doing with the next Muse-ic.

It is perhaps a good thing that I hate all the music players I end up having to use, primarily because I cannot mix deterministic playing of a playlist with finely-controlled randomisation. If it is an idiosyncracy, then fine; good thing I can code my itch away. I find that I often want to delicately mix audiobooks (or the like), which should not be absolutely random, with general music, which should be randomised very had; I find that I want, for instance, three back-to-back chapters to be separated by one or more randomly-selected songs. This kind of functionality is already there, but not in the way I want to do it. It is clearly a complex list traversal, which I would like to specify with some mathematical rigour; hence Haskell.

The plan is to get to where Muse-ic 1 (the Ruby one) has arrived so far—which is pretty far—and then start there with the new feature. The problem is that I am going to be learning a lot of new stuff, in Haskell (besides just the web framework), so it may drag on a bit. But I hope that my desire to power through some books may inspire more work on my part. I think, as part of the work, I will reconcile myself to only ever getting through my pending reading list (and maybe learning the language I am working on) by use of this system. After all, if there is such a well-implemented mixing, then all such things are not just possible, but outright easy. —On a web interface!

So, Muse-ic 1 was Ruby, with Rails doing the web part. The next will be Haskell, with Yesod doing the web part.