HookRace Blog     Posts     Feed     DDNet     Me

New Hardware and Hacks

In my latest post I showed some examples of how I ran mostly the same PC hardware over a period of 8 years. Today I finally finished setting up my new PC hardware in my new home, so I can report about what I did differently, my thought process, and some problems I encountered and hacks I did to solve them.

I'm not sure if this article is interesting for anyone, but I had some fun setting the new system up and felt like writing about it, so here we go:

Read the full post

Broken Hardware, Fixes and Hacks over 8 Years

After reading the feedback of my recent article about running DDNet, I noticed that people found it interesting how I'm trying to minimize money and resources. I also noticed that I had been doing something similar with my personal computing hardware setup for an even longer time.

I've mostly been using the same hardware for personal computation purposes over the last 8 years. In this article I want to talk about some of the hardware I've been using, how it broke and how I fixed the problems or worked around them. My goal was to be frugal about hardware, to keep using the same hardware for a long time and repair it when possible instead of simply buying new hardware.

Read the full post

Writing a 2D Platform Game in Nim with SDL2

In this article we're going to write a simple 2D platform game. You can also consider this as a tutorial for game development with SDL2 in Nim.

We will read in user input, display graphics and a tile map, and simulate simple 2D physics with collision detection and handling. Afterwards we will implement simple camera movement and game logic. To display some information we will render texts and develop a caching mechanism for said text rendering.

The final result will be a binary file that requires only SDL2 and can be easily distributed, perfect for games. If you're on Linux we will also present a simple way to cross-compile Nim programs for Windows.

Read the full post

Experiences of Running an Online Game for 3 Years

It's been roughly 3 years since DDraceNetwork (DDNet) started in the summer of 2013. Last year I wrote a non-technical History of DDNet. Today in this post we will dive into the technical side of what makes DDNet run.

For the uninitiated, DDNet is an open-source modification of Teeworlds, a retro multiplayer shooter. DDNet is a game in which you, instead of killing each other, cooperate with each other to work your way through challenging maps, trying to beat the map or get a better time than other teams.

Read the full post

Introduction to Metaprogramming in Nim

Introduction to the Introduction (Meta-Introduction)

Wikipedia gives us a nice description of metaprogramming:

Metaprogramming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyse and/or transform other programs, and even modify itself while running.

In this article we will explore Nim's metaprogramming capabilities, which are quite powerful and yet still easy to use. After all great metaprogramming is one of Nim's main features. The general rule is to use the least powerful construct that is still powerful enough to solve a problem, in this order:

Read the full post

DDNet Server Statistics with ServerStatus, RRDtool and Nim

About a month ago I set up statistics for the official DDNet servers. My motivations for this are:

  1. Monitor the servers more easily
  2. Get notified about server problems
  3. Have nice graphs to look at

The choices for the software used are mainly made to keep resource usage low, a general principle used for DDNet since we run on cheap VPSes all around the world and are limited in CPU and memory resources. In the rest of this post we will explore the 3 major tools used, their purpose in our solution as well as their performance impact:

  1. ServerStatus: Gather live server statistics
  2. RRDtool: Record and graph data
  3. Nim: Favorite programming language for performance and readability

Read the full post

More Photos in Europe

Some more photos of the last few months in Germany and Switzerland.

These image galleries are created with fgallery using fgallery -i -j 4 input-dir output-dir title to get the full images as well and to run the image conversion processes on a few cores in parallel.

Read the full post

Writing an Async Logger in Nim

Surprisingly I'm working on HookRace again. I might share a few interesting code snippets and thoughts in this blog along the way. I'm still going with Nim as the programming language.

For an easy start let's write a logging module that can be used everywhere in the game's server as well as client. There are mostly three aspects that I care about:

Follow along if you want to witness how fun it is to write code in Nim!

Read the full post

DDNet Live: Twitch spectates an online game

Last night I had an idea and implemented it, soo let's see what will happen. But first, the idea:

Have a livestream [1] of DDNet running non-stop [2] that always shows some interesting [3] players on the server.

The resulting livestream is running on Twitch. All the scripts are on Github

Read the full post

Travelling through Europe, Photos 3/3

This should be my last post about my travels. I wrote short texts for the highlight photos on imgur, which should deal better with high traffic.

I also made a clickable imagemap for the full photos:

Read the full post

Travelling through Europe, Photos 2/3

I'm done with the second half of my Europe travels. Here's the photos:

Read the full post

Travelling through Europe, Photos 1/3

This is my first non-technical post. I'm currently travelling Europe for 1 month after just finishing my CS master. Right now I'm back at home, but will be flying around again in a few days. I've never had a photo camera before, so not sure if the photos are good. This was my route so far with photos:

Read the full post

Nim binary size from 160 KB to 150 Bytes

The size of binaries in the Nim programming language seems to be a popular topic recently. Nim's slogan is expressive, efficient, elegant, so let's examine the efficient part in this post by exploring a few ways to reduce the size of a simple Nim Hello World binary on Linux. Along the way we will:

The full source code of this post can be found in its repository. All measurements are done on Linux x86-64 with GCC 5.1 and Clang 3.6.0.

Read the full post

Porting a NES emulator from Go to Nim

Let me get this straight. We have an emulator for 1985 hardware that was written in a pretty new language (Go), ported to a language that isn't even 1.0 (Nim), compiled to C, then compiled to JavaScript? And the damn thing actually works? That's kind of amazing.

Summary by haberman

Read the full post

NimES: a NES emulator in Nim

Since today Nim 0.11 has been released, I guess it's a good time to release this as well: NimES is a NES emulator written in Nim. More info in the GitHub repository and the JS demo.

Discussion on Hacker News and Reddit.

Read the full post

Make a Lisp in Nim

I spent the last weekend working through the amazing guide for Make a Lisp, writing a Lisp interpreter in Nim. The final result just made it into the repository.

Running the Nim version is pretty simple. You need the Nim compiler from the devel branch and nre which can be installed through nimble. After installing those you can build and run the MAL interpreter:

$ cd nim
$ make
  # OR
$ nimble build
$ ./stepA_mal
Mal [nim]
user> 12
12
user> (+ 2 3)
5

Read the full post

How I Start: Nim

My most recent post goes in another direction (no, it's still about Nim): How I start a new Nim project. Check out the article on howistart.org. Comments on Hacker News and Reddit as always.

Read the full post

Conclusion on Nim

In my last two posts, "What is special about Nim?" and "What makes Nim practical", I forgot the important conclusion - why I personally have decided for Nim in favor of Rust, C++, Python and Haskell:

Nim is not the fastest language, it's not the easiest language to write in and it surely has some flaws that should be fixed. Nim has no single "killer feature" like go's goroutines or Rust's memory management. But Nim doesn't need a killer feature. Instead it strikes a reasonable balance that makes it the most efficient language for me:

Read the full post

What makes Nim practical?

In my last post I showed what makes the Nim programming language special. Today, let's consider Nim from another angle: What makes Nim a practical programming language?

Binary Distribution

Programs written in interpreted languages like Python are difficult to distribute. Either you require Python (in a specific version even) to be installed already, or you ship it with your program. This even causes some to reconsider Python as a teaching language.

How does Nim work around this problem? For starters your program gets statically linked against the Nim runtime. That means you end up with a single binary that depends solely on the standard C library, which we can take for granted on any operating system we're interested in.

Read the full post

What is special about Nim?

Russian Translation by frol, Chinese Translation by JiyinYiyong

The Nim programming language is exciting. While the official tutorial is great, it slowly introduces you to the language. Instead I want to quickly show what you can do with Nim that would be more difficult or impossible in other languages.

I discovered Nim in my quest to find the right tools to write a game, HookRace, the successor of my current DDNet game/mod of Teeworlds. Since I'm busy with other projects for now, this blog is now officially about Nim instead, until I find time to continue developing the game.

Easy to get running

Ok, this part is not exciting yet, but I invite you to follow along with the post:

for i in 0..10:
  echo "Hello World"[0..i]

Read the full post

Nim Adventures

To learn some Nim I held a talk about it at the GPN14 (in German, Slides).

Afterwards I started solving Rosetta Code tasks in Nim to get a better feel for the language and standard library. That also made me discover some rough edges in the language, but luckily the community, albeit small, is active and competent. All the small code pieces I wrote are now on Github too.

What I noticed is that most problems are as easy to solve as in Python, but much more performant. I'm now more confident that this language is the right choice for writing HookRace in.

Read the full post

What is HookRace?

I have been running DDraceNetwork for 1 year, which started out as a little server of a Teeworlds modification called DDRace. It has turned into the biggest project within Teeworlds, offering servers in 6 countries with thousands of players and dozens of mappers. We also offer a custom server and client (Windows, Linux, OS X, Android).

Now it's time to start something new. I'm working on a new game called HookRace, which will be the successor to DDraceNetwork. It will be its own game, not based on Teeworlds.

Some of the plans I have so far for HookRace:

Read the full post