Learning Elm

I’ve not done a lot of front-end web work. Well, at least not in the last decade or so, so I’m a bit out of touch. I recently stumbled on Elm, a Haskell-like language that compiles to JavaScript. About the same time, I had an idea for a site that I wanted to try out. It seemed like a good time to put both into action.

Did I also mention I have a 5-month-old baby at home? Yeah, sounds like a great time to start a new project… sigh

First and foremost, the thing I love most about Elm is its attitude to getting started. When trying to learn what to do with AngularJS it felt like I had to do about a million things before I could see anything, which was a bit overwhelming. Elm, on the other hand, encouraged a “do the simplest thing that might work & build from there” approach that was not quite so daunting. This was a real positive when coding is limited to what feels like a 15-minute window between the kids’ bed time and falling asleep myself.

The second thing I love is that it has all my favourite characteristics of a language: strong, static typing, pattern matching, immutable data, etc, etc. The Elm compiler also has the best & most useful error messages I have ever seen. Seriously. They’re fantastic.

The third thing I love is that there is a well-defined pattern for building applications in Elm that is simple enough to illustrate with sane basic examples. In so many cases, examples have stuff that makes no sense in context but is required if you want your app to grow or they illustrate a simple concept in such a way that will cripple your program as it gets larger.

Having an architecture that encourages you to do the obviously right thing at any point and having that choice remain the right thing even after your program grows is a fabulous help.

I fully expect that initial hump that I experienced with Angular is just that – a hump that disappears once you’ve gotten properly started. Unfortunately my available time didn’t allow for any ramp up, so I probably didn’t give it a fair go. Also, I have a bit of a background with Haskell, so it’s entirely possibly that I’ve simply paid for that hump with Elm back in my freewheeling, child-free days.

Anyway, I like it. Check it out.

Go Plugin Framework, Part III

The story so far:

In Part I we defined the goal – to try and figure out how to implement a plug-in framework in Go – and learned how to launch & monitor a child process.

In Part II we learned how a child process can register itself with a parent process using Go’s built-in RPC channels.

In this episode we will look at defining the plugin API in more detail, and
invoking code in the child process.

Continue reading “Go Plugin Framework, Part III” →

Go Plugin Framework, Part II

In the last episode I started trying to write an image-processing plugin framework in Go using RPC & shared memory. In this part I will be showing how I organised the code, and got the various moving parts talking to each other.

Note: the code that follows is edited for exposition, rather than for being a ready-to-run system. If you want to see code that I know works, have a look at this repo up on github.

Continue reading “Go Plugin Framework, Part II” →

Go Plugin Framework, Part I

I wanted to see if was possible to build a dynamically-loadable plugin system in Go, for a photo processing tool that I have in mind (which will probably never get off the ground, but I can dream…). Now, Go is brilliant at a lot of things, but dynamically loading code is not one of them – which makes a “traditional” DLL/Shared Object approach to plugins a bit tricky.

Continue reading “Go Plugin Framework, Part I” →

Code as a Literary Form

Once upon a time, I tried to describe what it’s like to write a program to someone who had never done so, and couldn’t.

Not the nuts and bolts of the write/compile/test loop, nor the exercise in problem solving, nor any of the minutia of actually getting the thing to run; these activities have pretty good analogs in writing prose: think spell checks, proof reading, understanding your audience, editors, etc. What I really couldn’t explain was just how it felt to write a program as an expression of an idea, rather than as a mundane sequence of instructions for getting something done.

In the end, the best analogy I could think of for programming-as-literature is as a kind of highly stylised poetry. When programming – as in poetry – you have to reduce your ideas to their bare essence, and you’re constrained by the rules of your programming language in a similar way to a poet being constrained by the form they use. Of course, the analogy doesn’t bear too close inspection – when programming you have to explicitly clarify your ideas (which is hardly a requirement of poetry), and a near-sonnet can be almost as good as a sonnet, whereas a near-program is nowhere near as useful as an actual program.

Also, when programming, you can (and should) dump chunks of explanatory prose into the flow – which would somewhat defeat the purpose of poetry.

But I think the analogy holds up, except where it doesn’t.

Revisiting “Revisiting Go”

It’s been a long time between drinks on this blog – nearly 3 years since the last post. A lot has happened in that time. I became a dad (hence the absence of activity here). My day job has moved from C++ on Windows to Python on Linux. I’ve also learned a few more programming languages (Rust, D, Elixir), and spent some more time with a few old favourites (Common Lisp, Racket, F# and Go).

Continue reading “Revisiting “Revisiting Go”” →

Revisiting Go

A little over 6 months ago I wrote a post about Go’s idiosyncratic error handling, but abandoned Go soon afterwards. I’ve always had a lingering feeling that I hadn’t given it a fair shake, and so I decided that the release of Go 1.0 was as good a reason as any to give it another try. After hacking away at a simple server for a week or so I’ve found a few things to like, but a lot that leaves me profoundly unsatisfied.
Continue reading “Revisiting Go” →

Higher-Order Functions in C++

As you’ve probably guessed, I’m a big fan of functional programming. However, my current daytime gig is in C++, and whatever C++’s strengths may be, having an easy mapping for a functional programming style isn’t one of them.

I specifically miss higher-order functions. I find them to be a fantastically useful abstraction and find myself constantly reaching for them when they’re not there. So I’ve been experimenting with ways of implementing a higher-order style in C++, and it turns out that yes, you can do it. It just requires a lot of mucking about with templates.
Continue reading “Higher-Order Functions in C++” →

On Code As Communicaton

The older I get, the more problems I have that come from code I’ve written in the past. There’s nothing special about this – it’s just the way the world works. I have more code behind me now, so there’s more of it to bite me on the arse. What it does mean, though, is that I’m becoming more fastidious about how I format, structure and comment my code because I can see the rewards of explaining myself in greater detail.
Continue reading “On Code As Communicaton” →