5 ms·
On my free time, I make demos in less than 64kB (sometimes 8kB). I use many of the advices described in this article, except that I work on Windows with Visual
by laurentlb 3y ago
On my free time, I make demos in less than 64kB (sometimes 8kB). I use many of the advices described in this article, except that I work on Windows with Visual Studio (I'd like to compare with other compilers in the future). In particular, I disable exceptions, I compile without any standard library, and I avoid virtual methods. These are the most important things, in my experience.
Regarding compression, demoscene tools like kkrunchy, Squishy (https://logicoma.io/squishy/ https://logicoma.io/squishy/), and Crinkler can give much better results than UPX. They come with their own downsides, e.g. made for Windows, decompression can be slow, outputs might trigger antivirus systems, etc.
Another important advice is to check the binary size regularly. It can be difficult to predict how a code change will affect the binary (especially after compression!), so you need to test it often.
> If it's feasible, rewrite your C++ code as C.
Many C++ features are just free syntactic sugar, so I've decided to use them (e.g. namespaces, classes without virtuals).