Emil Hernvall

I'm Emil, a developer based in Stockholm, and currently working as an engineer at AWS. As of writing, I've been programming for 25 years, and professionally for the past 20. Since 2018, I've been working mostly in rust, which remains my favorite language.

I'm currently not looking to change jobs. If you are a recruiter thinking of sending me a message anyway, be aware that I'm unlikely to consider any position which isn't about rust.

Articles

Writing a DNS Server in Rust (2018)

Based on my Hermes project, I wrote a guide which explains in some detail how to implement a simple DNS Server.

Talks

A debugging carol (2021)

A discussion about some of the influences of functional programming that has made it into mainstream languages, expressed as a parody of A christmas carol.

What Rust Borrowed (2020)

A talk I gave at the Func Prog Sweden meetup on the functional influences in rust.

A Restful Service using Warp (2019)

An overview of how we used an early version of warp to build a control plane at Imperva.

Patents

Projects

This is an incomplete list of things I've done throughout the years. It's not representative of my professional work, but does convey a good picture of my interests. The major themes are graphics programming, network programming and programming languages.

Trip or Treat (2020)

A display for showing the subway times in Stockholm, built using a raspberry pi and a custom designed 3d printed case. This project includes the rust source code of the display and the STL files for the case.

Bubblespinner (2017)

The objective is to hit bubbles of the same color. If you hit a group of two or more with a bubble of the same color, they'll fall off. Once you've cleared them all, you move to the next level.

The original version of this game has been a pastime of mine for many years, and I've been looking to write my own implementation for a long time. There's a bit of physics-simulation going on here (notably the conservation of angular momentum to calculate rotation speed), which made it a bit extra fun to work on. I've put some extra effort into making the source code readable.

HostIMG (2017)

I've built many different image galleries throughout the years, and most of them has generated thumbnails on demand, which causes a lousy user experience when the gallery is first loaded. A better solution, I believe, is to detect new images and do the work in the background immediately. HostIMG is such a server written in Rust. Given a directory, it'll use inotify to watch for changes, and automatically generate thumbnails. A built-in web server serves up the images in the directory.

Pacman (2017)

A pacman clone in javascript. Originally conceived as a way to explore the utility of immutable state representation in a stateful application like a game.

Cesium (2016)

Version control of database schemas has always been a pain, and the existing solutions aren't very satisfactory. Furthermore, they don't usually work well with multi-branch workflows in git/hg.

Cesium was an attempt at a solution. It uses a git-inspired patch-based structure, where small sql patch files are chained together. The key idea of Cesium is the built-in sql parser: it can understand the patches without talking to a server. This enables comparison of different branches without talking to a server, comparison of on-disk patches to a running server, and so on.

It was a successful experiment, which demonstrated the power of the concept. I eventually lost interest as I migrated away from using MySQL as a database.

Hermes (2016)

A DNS server written in Rust, with a built-in web server for managing zones. Written as an exploration of the language as well as the details of the protocol. Quite an extensive project, which supports most of the features expected in a DNS server except for spoofing mitigation. Neither heurestic mitigation nor DNSSEC is currently supported, although I'll likely resume development at some point.

expiler (2014)

This is an experiment with generating java bytecode. After playing around with the asm library for a bit and gaining a better understanding of java bytecode, I decided to implement a simple program which parses mathematical expressions and converts them into executable java classes.

Ray tracer (2013)

A simple experiment and learning project, written in C++. Uses the phong reflection model to shade objects, with full support for reflections. The source code only depends on libgd2. I used this project to render the picture of earth at the top of this page.

This is to some extent just a C++ port of the Amiga Juggler reimplementation, which kinda shows from the structure of the code, but there's a few enhancements of my own. For instance, support for multiple lights. Further work on this project will probably attempt to introduce an acceleration data structure, and some way of loading scenes from disk.

UglyLang (2012)

Toy programming language. It's currently implemented in Java, but I dream of bootstrapping it eventually. Current all execution is interpreted. The language as such is characterized by its static type system, which guarantees type safety. It's a cross between the functional and imperative paradigms. The current lack of support for generic programming combined with the strict type safety limits its usability, although I'm hoping to resolve that eventually.

Tregmine (2011)

Plugin for the bukkit minecraft server, that provides most of the features needed to run an economy/survival server. It's a collaboration with a number of other developers, for the Tregmine minecraft server.

3D Engine (2011)

Experiment with software rasterization. Written mostly as a learning project, and horrendously unoptimized. When I started out with this, I had no experience whatsoever in 3d programming, and thus I spent some time documenting my research as a diary, which is available in the repository. (I did have a solid understanding of basic linear algebra, though.)

The major feature I never got around to would be texture mapping, which will probably be added at some point. Still, it'd be hard to argue that this project is suited for any real life applications, even after that's done.

SassyBarista (2011-2012)

A java implementation of the SASS language, which is a superset of CSS. Based on a JavaCC grammar. See link for a more complete description.

FatCat (2010-2011)

A java implementation of an irc server. It was designed in a way that would make it easy to add other protocols, with a core that simply manages the server state. The only other protocol that I ever tried adding was minecraft support, by embedding it in bukkit, and wrapping the mc-related state in a protocol handler. It worked pretty well, and turned out really cool.

fatcat has a completely asynchronous network thread using java.nio. There's currently no support for linking other servers, and also no services. I have some wild ideas about expanding fatcat with distributed linking support, and using something like vector clocks to synchronize state, but I'm not sure when I'll get around to that.

Candify (December 2010)

A visualizer framework for spotify, using the official libspotify. Includes some simple FFT-based visualizers, that doesn't work nearly as well as I'd hoped. This is entirely due to my severely lacking understanding of signal processing. The addition of some type of online filter would probably result in a lot more recognizable beats. It does look pretty nice, though. Uses the windows DirectDraw API.

Collapsible (October 2010)

Horrendously ugly tetris clone. WinApi and DirectDraw. My first and final attempt at doing game graphics.

Cropper (August 2008)

Simple program to crop images quickly. Written using WinApi and GDI+. I wrote this to optimize my photo editing workflow, since it felt a bit too painful to launch a full image editor every time I simply wanted to crop an image. This is my attempt to solve that specific problem in a really lightweight way.

Mosaic (2008)

A small unix program that constructs an image mosaic from a source image and a collection of smaller images (mosaic bricks). There's a few major issues with this program:

  1. It does not attempt to avoid putting identical tiles next to each other.
  2. It's O(n) in the number of tiles. A better idea would be to use something like kd-trees to quickly find a tile close to a pixels color in 3d RGB space.

ImageRetarget (2007)

An implementation of the seam carving algorithm I did back when it was first released. I was absolutely fascinated by the paper, and implemented it in both PHP and Java. This repository contains only the java-version, which has some interesting quirks. For instance, I'm calculating the energy of the image using a literal interpretation of the method in the paper rather than using a simple sobel transform. This involves interpolating the pixels as a cubic equation and calculating the partial derivatives. As far as I can tell, this has no real advantages over the sobel approach, but it's a rather beuatiful over-complication.

Experiments and snippets

Smaller projects and experiments I've done, of somewhat varying quality.

HoffProxy
An old practical joke, on my coworkers. A transparent HTTP proxy that manipulates images by inserting a picture of David Hasslehoff. I used an iptables rule on the office router to pass all HTTP traffic through this proxy.
mod_hmacauth
mod_hmacauth is an apache 2.2 module that provides hmac-md5 based authentication of requests. Apache configuration can be used to specify which files require authentication, and the requester then have to provide a timestamp and a secret as part of the querystring.
PlaylistCopy
Very small program for copying the contents of a .m3u playlist to a specified target directory.
Quad Tree in Java
An implementation of a Quad Tree, originally written for use in a Minecraft Server. Optimized for efficiently looking up which of a set of rectangles that a point in 2d space belongs to. Only supports a sub set of operations right now.
HQX bindings for PHP
The HQX library provides an algorithm for scaling pixel graphics with superior quality compared to standard interpolation methods.
Sudoku Solver in C
Using the naive substitute-and-permute approach.
Date diff implementation for PHP
Decoder for the EA .big-format
Used it to retrieve the videos for Red Alert 3. A really basic format, that was quite simple to reverse engineer.
Base64 encoder and decoder in Java
Finding the most popular word in a file
Using linked lists and merge sort (C)
Using a hash set (C)
In Java
Some different implementations of a word counter that I wrote as part of an argument with a friend.
Some basic code for parsing and generating wave-files
Parser in C
Tone generator in C
Recursive mkdir in C
Tiny java/swing app for language learning
Indexing spellchecker in PHP
Find a way to reverse a hand of five cards by moving three cards
setuid() to another user and give group members write permission to files with certain extensions.
Prime Sieves
Basic
Smart
Experiment with encoding data as sound
Transforms a data file to a series of beeps of different frequencies, that can be decoded back into the original file.

Contact

You can get in contact with me using my gmail. My username is emil.hernvall.