- Blind mode tutorial
lichess.org
Donate
Journal and Pen

Aaron Burden

Why Develop Free Software?

Software DevelopmentChess engineChess bot
Writing code is work, so why do it, and why share it with others?

Frequently I hear people express mild enthusiasm for developing their own game, their own web site, their own chess engine, etc., but why do we not hear similar calls for, "I want to write a book?" Why write code and then give it away for free? What even is software freedom?

First, let me disclaim that not everyone who claims to have an interest in writing is actually interested in writing. Some people become excited about technology then immediately have no desire to learn more about the technical aspects of it, but just want to be able to do things with technology. I'm reminded of an anecdote where a grandparent getting a new computer wanted to know if the new operating system still contained the "knitting program" (a spreadsheet program where one could color cells to produce a knitting pattern). If people were rational, few misadventures would occur where people accidentally learn things about themselves.

One reason to write code is to be able to collaborate with other people, either on a particular project or in general. Many of us have heard (and many have not heard) about GNU/Linux and other free software projects. If a project has 90% of the features you like but does not contain your particular feature, and if that project lacks a funding model where you can pay someone else to add your desired feature, you can add that feature yourself! If in turn you think other people would enjoy the same feature, publish your code in order to receive others' feedback and they might even contribute code to your project!

In 2014 I noticed that Lichess lacked an engine for analyzing and playing King of the Hill and other variants; rather than repeat my previous experiment of designing an engine from scratch, I would take a short-cut and fork Stockfish to add victory conditions and trivial evaluation functions for the few variants Lichess implemented at that time. I reached out to Thibault over IRC inquiring whether Lichess would be interested in deploying such an engine if I should maintain it, and so began my collaboration not only on Stockfish but also on Lichess variant code (written in Scala, a language the Lichess team learned while teaching me and other developers).

But OK, say that you lack some selfish motive about getting your key feature into the software; can the exercise of code-writing be entertaining? Tom7 and Code Bullet often embark upon massive projects fully exploring good and bad ideas, but upon further reflection... no sane person enjoys writing code merely for its own sake. Aristotle's virtue ethics seems to support my conclusion: writing code (or doing any other activity) in abundance is vicious, even if one proudly calls oneself a "coder". Likewise being unwilling to attempt writing code (e.g. "but I'm not a coder, I don't know how so I can't learn", etc.) can be vicious in circumstances when trying to learn might better serve one's purposes.

But what, you ask, of scientists in videos and TV programs who claim to enjoy doing science for its own sake? Well, yes, learning can be fun, but let's not delude ourselves: any sort of methodological science is work and is often hard work. Writing your own game or chess engine from scratch the first time is brutal, especially if you don't use your favorite search engine to ask for directions and never discover the Chess Programming Wiki but decide to do everything by yourself in a vacuum (or regularly beg other developers for help writing it for you). It's even more difficult if you fail to reinvent successful methods, for example iterative development.

If during or after writing your first project you find that you have some skill for the trade, you might consider uploading your source code not just for your own benefit but also so other people can benefit from your original work. When uploading, please also select a free software license so other people have some expectation over whether they can safely reuse your work; even the best projects, when poorly licensed, quickly atrophy since developers such as myself often refuse to collaborate on projects without permission. I have collaborated with some engine developers to automate tests and fix bugs; sadly, Community BOTs does not highlight which bots are free software (and which free software license they use) so discovery and collaboration are difficult.

Lately I have turned my attention toward other free software projects such as world champion shogi player YaneuraOu, which are easier to discover and collaborate upon despite a language barrier. Perhaps I will write more about recent projects in some future blog entry, who knows.

So why write code?

What is software freedom?

As linked above, the Free Software Foundation makes a distinction between Open Source(TM) versus Free Software. Stallman is correct in identifying software freedoms:

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

Under U.S. copyright law, simply uploading content to the internet doesn't revoke your copyright. This is why web sites and services (such as mobile apps) have terms of service which require you to give permission to publish your content, so you cannot prevail in a law suit against site owners who you gave your permission. Likewise, corporate entities publishing source code or software without granting permissions for the freedoms above fail to promote the progress of the sciences and useful arts. You might recall a recent Lichess blog post about one notable example.

To choose a free software license, take a look at what other developers have done, or consult a glossary or search engine; you can add additional licenses at any time, but ordinarily licenses are not revokable (it would be bizarre to give others permission to copy, redistribute, etc. then try to undo that permission grant).

Please by mindful when asking questions both of yourself and of others. It can be easy to get swept up in the excitement of your first project, but if your first project is, "I want to make a chess engine!" try to consider whether simpler projects (either easier games, or putting your own spin on someone else's code; there are thousands of chess free software projects!) might make you equally happy. By knowing what you want, you can avoid costly XY Problems. Also do a few minutes of research before doing a few days of coding, since chances are your project isn't so unique that it would be impossible to learn from others' successes and mistakes.

Advent of Code is coming, in case you want to get some idea of whether you find joy in writing and sharing code, or simply bask in the joy other people share. This year I think I may do the latter.

Image provided by Aaron Burden

Disclaimer: pirating others' work (e.g. video games) out of a desire to collaborate doesn't necessarily make that legal. There are plenty of free software games, so why not pick one of those instead?