news
Programming Leftovers
-
Geir Isene ☛ Proving a process
Lean checks the process on paper. It can’t check that people follow it.
But a process with holes on paper has holes in real life. People fill them with guesses. Or some creative moves.
-
Sharon Rosner ☛ Introducing Project Steadfast
Recently I wrote about an idea that’s been floating around in my mind for a long time - the ability to do metaprogramming in Ruby by manipulating Ruby ASTs, similar to the macro capabilities of languages such as Lisp or Elixir. The use of eval (in its different variations) is a common metaprogramming technique in Ruby that consists of generating code at runtime from dynamically constructed strings. This is often done for performance reasons: ERB compiles templates into optimized code by generating pieces of Ruby source code then putting them together and calling eval; In Rails, the same technique is used for implementing features such as associations, or scaffolding. With eval, we can avoid paying the performance overhead that’s often associated with using DSLs in Ruby.
-
Jo Turk ☛ How hard could implementing DTLS 1.3 possibly be?
I wanted to write down the lore of how this happened, and also explain DTLS the way I wish someone had explained it to me. So this is both, with interactive demos you can poke and break along the way.
-
Ben Joffe ☛ A faster Easter date function
Computing the date of Easter faster is not going to matter in any real application. Even in places where it might seem to matter, like high frequency trading applications, it is probably better to just use an in-memory lookup table for holiday dates...
However, no "Fast Date" series would be complete without some mention of this classic problem.
-
Ben M Andrew ☛ What is malloc doing, anyway?
malloc has a very nice and simple interface: you ask for a certain amount of memory, and you’re given a void pointer to your block of contiguous bytes that’s been magicked into existence. Once you’re done with it, you call free with the same pointer and the memory disappears into the ether.
But what’s actually happening here? Obviously, as we’re running as a userspace program, malloc must be asking the kernel for the memory through syscalls. However, we may be allocating many small blocks, and syscalls are expensive (575 ns for an empty one, as measured below), so some bookkeeping is done in the background. We’ll demonstrate this on GNU libc (glibc) with the program snippet below, which calls malloc(16) a thousand times.
-
Mythic Beasts Ltd` ☛ PHPocalypse
We have tooling that allows us to quickly find all managed servers where a given package is installed, send out notifications and automatically apply the updates.
-
Daniel Lemire ☛ Telling your number parser what to expect
Our fast_float library parses numbers such as -731.51 into binary floating-point values. It is part of GCC’s C++ standard library, among others. It is fast: often a few nanoseconds per number. Parsing a number means making decisions.