Recently, with all the crazy stuff happening in the world, I decided to play around with something fun for a change. I can't control the outside world, but at least I can control what I do for fun. Which is why I decided to play around with LÖVE2D . It's a, really easy to pick up, game development framework based on top of a couple of C libraries (e.g. SDL ) and exposed using Lua (via luajit ). As…
Analyzing multi-gigabyte JSON files locally with serde
Recently I've read a very interesting article about running queries over large json documents in an almost interactive way. As is often the case, I immediately thought about doing the same in rust (RIIR syndrome?). I was curious how fast (or slow) will be the 'default' way of doing it in rust. This is obviously quite pointless since the approach in the article is nice and easy. Read on only if you…
Cost of using unbuffered io
It's easy to think that when using compiled languages like rust or c++ we get high performance almost for free. But sometimes it's easy to lose all of that speed for trivial reasons. One such example is using various convenience functions when doing I/O. Let's take as an example parsing json file using serde_json : fn main() -> Result<()> { let opt = Opt::from_args(); let file =…
Advent Of Code 2018
As usual this time of a year I'm attending Advent of Code. Since I'm learning CL this time I will try to solve all tasks in CL. In this post I will document my findings and failures and you can always check code here. Day 1 - Chronal Calibration First part of day one essentially asks us to sum list of integers. If we know how to parse input (you will see in a moment that I failed to do that…
My introduction to Common Lisp
So I want to finally learn some Lisp. Today there are many languages claiming to be lisp, but as far as I can tell there are only 5 really active dialects. The oldest one is Scheme which started it's life in 1975. The nice thing about Scheme is that it's a very small language. Next one is Common Lisp which started almost 10 years later - in 1984. The nice thing about Common Lisp is that it is very…
Type level programming
While watching Typelevel Programming 101: The Subspace of Scala I was reminded of Peano numbers. It’s a way to encode natural numbers which is derived from Peano axioms . Which got me thinking - since I don’t know how long I had a feeling that there is almost mechanical translation from subset of Haskell programs to C++ meta programs. Specifically I had in mind programs which use only natural…
Strong types and testing
This is reimplementation of Haskell code from bitemyapp , which itself was inspired by levinotik . Obviously Go has much simpler type system and some of the constructs in Haskell are not possible to express in it. The most important of those are sum types and purity. Yet it is still possible to express quite a lot in Go. bitemyapp starts with declaring simplest structure to express email, and…
Go Caves!
Quite recently Cogmind alpha was released. As it happens I am also playing Brogue from time to time for last couple of months. This once again made me want to write my own roguelike , which reminded me that I’ve already seen two nice tutorials on how to write roguelike: Original by Trystan Caves of Clojure port of Trystan’s tutorial to Clojure by Steve Losh Adding another one might be fun…
Joy of c++
#include <type_traits> decltype(auto) foo1() { int x; return x; } decltype(auto) foo2() { int x; return (x); } int main() { static_assert(std::is_same<decltype(foo1()),int>::value, ""); static_assert(std::is_same<decltype(foo2()),int&>::value, ""); }
λ vs ≫= code size
Comparison of 3 different ways for binding functions with parameters in c++. What is of interest here is vast difference (>2x) between lambdas and binds in default (rtti + exceptions) case, and even bigger when both rtti and exceptions are disabled (~3.8x). See listing for files needed to reproduce this locally. Calling generate.sh will produce every file seen in stats_* directories. All results…
Cat in different unices
As per sloccount: gnu_cat.c Total Physical Source Lines of Code (SLOC) = 486 Total Estimated Cost to Develop = $ 12,665 freebsd_cat.c Total Physical Source Lines of Code (SLOC) = 270 Total Estimated Cost to Develop = $ 6,832 netbsd_cat.c Total Physical Source Lines of Code (SLOC) = 260 Total Estimated Cost to Develop = $ 6,567 apple_cat.c Total Physical Source Lines of Code (SLOC) = 247 Total…
Cost of includes
For each src/.cc file there is detailed log in logs/.cc.txt with: strace summary of syscalls times and number of executions wall clock time it took to compile number of header locations which whare tried number of opened (not unique) headers number of headers according to gcc -M Compilation was done with -Os using g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Summary: src/all.cc % time seconds usecs/call…