(a bit of) whitespace

Has someone just said “lowlevel”?

On Tests and Types

Much has been said on the virtues of testing and type systems. However, I say that neither of them ultimately matters. Your codebase could be pure PHP, using exclusively goto for control flow, have no tests, comments, or variable names whatsoever—if you are rightfully sure that it is correct (for any possible input, produces valid output with limited use of resources), the codebase is perfect.

The big question, of course, is “how can we be sure that it is correct?” There have been impressive advances in the field of authomatic theorem proving, e.g. Coq and CompCert. Unfortunately, we neither able nor should put a scientist behind every menial programming job; even if we could, undecidability means that we could only get a definite answer for a subset of interesting problems.

The only available option is to rely on human judgement. Any tools or methods a programmer would employ are only useful as long as they enable a deeper understanding of the program, as they rightfully convince her that the program is indeed correct. If you don’t make an error, don’t test for it.

Invariably, people do not all think alike. There is no single way of reasoning about programs and their behavior; there could be no single technique that enables writing nicest possible code. Thinking that the way that suits you most is the superior of them all is just arrogance. We can do better than that.

I’m not saying that all languages and methods are born equal. They are not. But let’s reason about them in terms of how easier they make it for a human to analyze the code, for it is the only thing that matters, and not peculiarities of syntax or the big names behind.

I’m also not saying that all code must be perfect. It doesn’t matter if a few pixels in a cat picture have the wrong color. But you better be sure they do not get executed.

A Guide to Extension Points in OCaml

Extension points (also known as “-ppx syntax extensions”) is the new API for syntactic extensions in OCaml. The old API, known as camlp4, is very flexible, but also huge, practically undocumented, lagging behind the newly introduced syntax in the compiler, and just overall confusing to those attempting to use it.

Extension points are an excellent and very simple replacement introduced by Alain Frisch. In this article, I will explain how to amend OCaml’s syntax using the extension points API.

XCompose Support in Sublime Text

Sublime Text is an awesome editor, and XCompose is very convenient for quickly typing weird Unicode characters. However, these two don’t combine: Sublime Text has an annoying bug which prevents the xim input method, which handles XCompose files, from working.

What to do? If Sublime Text was open-source, I’d make a patch. But it is not. However, I still made a patch.

If you just want XCompose to work, then add the sublime-imethod-fix PPA to your APT sources, install the libsublime-text-3-xim-xcompose package, and restart Sublime Text. (That’s it!) Or, build from source if you’re not on Ubuntu.

However, if you’re interested in all the gory (and extremely boring) details, with an occasional animated gif, read on.

Page Caching With Nginx

For Amplifr, I needed a simple page caching solution, which would work with multiple backend servers and require minimal amount of hassle. It turns out that just Nginx (1.5.7 or newer) is enough.

Foundry Has Been Cancelled

Two years ago on this day I started working on Foundry, and I developed some nice things, including prototypes of both the language and the compiler. Today I’m cancelling the project.

The reason is simple and technical. The idea behind Foundry was to take the convenience Ruby offers, and transplant it to a statically typed language. My chosen implementation path involved global type inference in every interesting aspect of it. While powerful, this technique makes writing closely-coupled, modular code hard, separate compilation impossible, and error messages become even more cryptic than those of C++.

Simply put, this is not a language I myself would use. Also, I could not find a way to get rid of global type inference which didn’t involve turning the language into a not invented here version of C#, Rust or what else.

Lessons? Don’t design a language unless you have a very good reason to. By all means, do design a language if your idea is fancy enough. And don’t use global type inference, it sucks.

Now go and check out Rust. It gets better every day.

Metaprogramming in Foundry

The language I’m working on, Foundry, is developed as a practical alternative to widely used systems programming languages, in particular C, C++ and variants of Java. As such, it is statically typed, can elegantly expose machine-specific details when required, and is tuned to provide predictable and efficient (in that order) space and time behavior.

In this article, I present a way to add dynamic, Ruby-style metaprogramming facilities to a statically compiled language with an ML-derived type system.

The Next Web

The Web has grown out of JavaScript, HTML, CSS and HTTP. It is evident that the whole technological stack must change, yet the direction is unclear. In this post I present a few draft ideas for a next generation of web browsers.

Let’s Play With Ruby Code

Are you tired of aligning those pesky equality signs by hand? Do you obsess over using (or not using) and, do and then? Do you want to enforce your corporative style guide without fixing all the indentation by hand?

All of the above, and without accidentally breaking code structure and unrelated formatting?

Parser has you covered.

Unmentioned Features of Ruby 2.0

It has been a while since the release of Ruby 2.0, and a lot of comprehensive guides to the new 2.0 features were written. However, I feel that some of them are still left in obscurity. The justice shall be served.