The personal weblog of Martin Donath, professional web developer, technology ninja and design enthusiast based in Cologne, Germany.

Building Web Applications in Golang With Gulp and LiveReload

Gulp and LiveReload are two awesome tools that greatly ease web application development by streamlining the build process.

Gulp is a modern build system designed around the idea of streaming a set of input files down a pipeline of tasks for automated processing, e.g. concatenation, sourcemap generation, minification, revisioning and many more. LiveReload automatically reloads your application when detecting changes to the source and consists of two parts: a client, implemented as a browser extension (available for Chrome, Firefox, and more) and a server counterpart (we’ll use gulp-livereload, an elegant Gulp integration).

There are many tutorials on setting this up to work with Node.js projects (for starters see here, here and here), but nothing on getting it to work with compiled languages like Golang, so I thought I share my setup.

A Generic Linked-in Driver for Interfacing Erlang and C

This is an attempt to provide a lightweight and clean implementation of a generic linked-in driver for communication between Erlang and C/C++ programs. It was designed from the ground up to support multi-threaded, non-blocking operations, has the ability to hold state across calls and is entirely customizable. The rationale behind this generic driver is to provide a default and clean implementation for communication between those two languages and to minimize the need to write boilerplate code.

Of course there is the Generic Erlang Port Driver (GEPD), which lets you generate a driver tailored to your needs by specifying function bindings via C macros. However, this generic linked-in driver implementation takes a different approach and provides the programmer with an easy to use interface without the need to generate any code and without any external dependencies. Additionally, the name of the driver is set via compiler flag, so that multiple instances of the same driver can be compiled and identified by different names without the need for code duplication. This is very handy if you design your program to be configured during compilation and need different configurations.

There’s an example linked-in driver included with the source which demonstrates the features of this implementation. You can dive into the code right away or keep reading for a detailed reference of features and a simple how-to.

Awesome Client-side MVC With Coffeescript and Composer.js

Developing modern and complex Web 2.0 applications, one is always faced with the problem of structuring and dividing the frontend Javascript code in a way that is maintainable, reusable and easy to be extended. Frameworks like jQuery and MooTools battle cross-browser compatibility issues but don’t provide any high-level structuring mechanisms. Meanwhile, most applications use the Model-View-Control (MVC) pattern in their backends, so why not also use it in the frontend?

At the time of writing, there is quite a range of open source Javascript MVC frameworks, including Backbone, SproutCore and Spine just to name a few. Unfortunately, almost all of them are tightly coupled with jQuery. Since I’m a big fan of the strictly object-oriented approach of MooTools, I searched the web for an alternative and found a new and promising MooTools-based framework: Composer.js.

Adding Mooml as a client-side templating engine and Coffeescript for syntactic sugar, I will discuss my current approach of building complex and maintainable web frontends. This article assumes that you are familiar with the basic concepts of Javascript, have written some code in MooTools and Coffeescript and are used to the MVC pattern.

Strange Attractors

The beauty of strange attractors has been fascinating me for a long time. Beside their visual appeal it is stunning that they are the result of really simple mathematical equations producing practically unpredictable numbers over a long period of time.

In this article I introduce and discuss a very simple and compact Processing.js script which is based on a two-dimensional quadratic map and a fractal pattern – a sequence of 12 letters – delivering the coefficients for the quadratic map.

Actually, I am not a physicist – I just like strange attractors from an aesthetic point of view. Okay, I am a bit of a math addict, too. However, it’s not as complicated as it may sound in the first place.

The Power of Sorted Grep

In the process of mining the data collected for my diploma thesis, I ran across a very useful tool called sorted grep which offers significant speed improvements over the common unix tool grep when it comes to very large pre-sorted files.

Traditional logfiles seem to be the first use case one can think of, as they are naturally growing large and have an inherent chronological order. However, there are other cases where sorted grep might be the weapon of choice, as it offers binary search packed in a very reasonable way.

This article will walk you through the setup and usage of the powerful tool sorted grep and give you some ideas where and how to use it.