<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on vitaut.net</title><link>https://vitaut.net/posts/</link><description>Recent content in Posts on vitaut.net</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sat, 02 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://vitaut.net/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Every float on one page</title><link>https://vitaut.net/posts/2026/every-float/</link><pubDate>Sat, 02 May 2026 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2026/every-float/</guid><description>In my previous post about Żmij, a high-performance binary-to-decimal floating-point conversion library, I drew a small diagram of a rounding interval around a single floating-point value. That worked well enough for the local picture, but it doesn&amp;rsquo;t say much about the global one. Where do the irregular intervals at powers of two come from? What does the subnormal range actually look like? And how do the binades (the $[2^e, 2^{e+1})$ slices of the real line on which all FP numbers share an exponent) fit together?</description></item><item><title>Faster double-to-string conversion</title><link>https://vitaut.net/posts/2025/faster-dtoa/</link><pubDate>Sat, 13 Dec 2025 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2025/faster-dtoa/</guid><description>There comes a time in every software engineer’s life when they come up with a new binary-to-decimal floating-point conversion method. I guess my time has come. I just wrote one, mostly over a weekend: https://github.com/vitaut/zmij.
It incorporates lessons learned from implementing Dragon4, Grisu and Schubfach along with a few new ideas from myself and others. The main guiding principle is Alexandrescu&amp;rsquo;s &amp;ldquo;no work is less work than some work&amp;rdquo; so a number of improvements come from removing things from Schubfach (conditional branches, computations and even candidate numbers).</description></item><item><title>to_chars or not to_chars?</title><link>https://vitaut.net/posts/2025/to-chars/</link><pubDate>Fri, 05 Dec 2025 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2025/to-chars/</guid><description>I was recently adding my Schubfach double-to-string conversion algorithm implementation to dtoa-benchmark and noticed that std::to_chars was notably missing from that benchmark. So I decided to add it and see how well it compares to other methods.
And it did pretty well! This particular implementation from libc++ was 17 times faster than sprintf and almost 2 times faster than double-conversion. Considering that std::to_chars has been available since 2017, I think it&amp;rsquo;s time to retire double-conversion.</description></item><item><title>The smallest state-of-the-art double-to-string implementation</title><link>https://vitaut.net/posts/2025/smallest-dtoa/</link><pubDate>Sat, 29 Nov 2025 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2025/smallest-dtoa/</guid><description>Converting floating-point numbers to their shortest decimal representations has long been a surprisingly challenging problem. For decades, developers relied on algorithms such as Dragon4 that used multi-precision arithmetic. More recently, a new generation of provably correct and high-performance algorithms emerged, including Ryu, Schubfach and Dragonbox.
In my earlier post, double to string conversion in 150 lines of code, I explored how compact a basic implementation can be while still maintaining correctness.</description></item><item><title>double to string conversion in 150 lines of code</title><link>https://vitaut.net/posts/2024/simple-dtoa/</link><pubDate>Fri, 27 Sep 2024 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2024/simple-dtoa/</guid><description>My previous blog post gained some attention on Hacker News (discussion), and as someone deeply interested in floating-point formatting, I couldn&amp;rsquo;t ignore the following comment:
It&amp;rsquo;s kind of mindblowing to see how much code floating point formatting needs.
If you want it to be fast. The baseline implementation isn’t terrible[1,2] even if it is still ultimately an &amp;gt; implementation of arbitrary-precision arithmetic.
[1] https://research.swtch.com/ftoa
[2] https://go.dev/src/strconv/ftoa.go
The linked algorithm seemed clearly unsuitable for anything beyond teaching purposes, but I decided to give it a try anyway.</description></item><item><title>Honey, I shrunk {fmt}: bringing binary size to 14k and ditching the C++ runtime</title><link>https://vitaut.net/posts/2024/binary-size/</link><pubDate>Fri, 30 Aug 2024 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2024/binary-size/</guid><description>The {fmt} formatting library is known for its small binary footprint, often producing code that is several times smaller per function call compared to alternatives like IOStreams, Boost Format, or, somewhat ironically, tinyformat. This is mainly achieved through careful application of type erasure on various levels, which effectively minimizes template bloat.
Formatting arguments are passed via type-erased format_args:
auto vformat(string_view fmt, format_args args) -&amp;gt; std::string; template &amp;lt;typename... T&amp;gt; auto format(format_string&amp;lt;T.</description></item><item><title>Optimizing the unoptimizable: a journey to faster C++ compile times</title><link>https://vitaut.net/posts/2024/faster-cpp-compile-times/</link><pubDate>Sat, 06 Jan 2024 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2024/faster-cpp-compile-times/</guid><description>In this post I&amp;rsquo;ll talk about bringing compile times of the {fmt} library on par with the C standard I/O library (stdio).
First some background: {fmt} is a popular open-source formatting library for C++ that provides a better alternative to C++ iostreams and C stdio. It has already surpassed stdio in many areas:
Type safety with compile-time format string checks available by default since C++20 and as an opt in for C++14/17.</description></item><item><title>std::print in C++23</title><link>https://vitaut.net/posts/2023/print-in-cpp23/</link><pubDate>Sun, 24 Dec 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/print-in-cpp23/</guid><description>I just realized that 2023 is almost over and I haven&amp;rsquo;t posted about the most important feature of C++23. Which feature is that, you might ask? Unlike C++20 which had a bunch of massive new features like modules, concepts and the third one, C++23 feels incremental.
The C++23 feature I am referring to is, of course, std::print, modeled after fmt::print from the {fmt} library. It feels deceptively small but it took ~3 years to get through the C++ committee and it changes the most important aspect of C++, the way we write Hello World:</description></item><item><title>Measuring clock precision</title><link>https://vitaut.net/posts/2023/measuring-clock-precision/</link><pubDate>Sun, 17 Dec 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/measuring-clock-precision/</guid><description>I&amp;rsquo;ve been reading Operating Systems: Three Easy Pieces, which is a great book BTW, and one of the questions in the TLB section is
For timing, you’ll need to use a timer (e.g., gettimeofday()). How precise is such a timer? How long does an operation have to take in order for you to time it precisely? (this will help determine how many times, in a loop, you’ll have to repeat a page access in order to time it successfully)</description></item><item><title>ChatGPT-driven development</title><link>https://vitaut.net/posts/2023/chatgpt-driven-development/</link><pubDate>Thu, 14 Dec 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/chatgpt-driven-development/</guid><description>In the vast, often inexplicable universe of C++ programming, I found myself staring into the digital abyss of a peculiar problem: how does one effectively compare format_as with the venerable formatter specialization? This question was as intriguing as it was esoteric, much like pondering the number of Vogon ships in the Galactic Fleet. But fear not, for my quest was not solitary. I had a companion, an AI of improbable intelligence and wit: ChatGPT.</description></item><item><title>Printing double aka the most difficult problem in computer science</title><link>https://vitaut.net/posts/2023/printing-double/</link><pubDate>Sun, 04 Jun 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/printing-double/</guid><description>A few years ago I discovered this StackOverflow question: How do I print a double value with full precision using cout? I was shocked to see how wrong most of the answers were so I answered it myself back then. Recently I stumbled upon it again and decided to write this blog post explaining the problems with some of the top answers.
Consider the (now removed) top answer with almost 500 upvotes.</description></item><item><title>Simple usage of C++20 modules</title><link>https://vitaut.net/posts/2023/simple-cxx20-modules/</link><pubDate>Mon, 17 Apr 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/simple-cxx20-modules/</guid><description>In my previous post I showed how to compile {fmt} as a C++20 module with clang. Although taking only two commands, ideally it&amp;rsquo;s not something you should be doing manually. So in this post, I&amp;rsquo;ll talk about module support in CMake, everyone&amp;rsquo;s favorite not a build system.
My first attempt was to use the CMake&amp;rsquo;s built-in functionality advertised in &amp;ldquo;import CMake; C++20 Modules&amp;rdquo;. And after some struggle I made it to work with clang but unfortunately it was very limited.</description></item><item><title>C++20 modules in clang</title><link>https://vitaut.net/posts/2023/cxx20-modules-in-clang/</link><pubDate>Mon, 10 Apr 2023 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2023/cxx20-modules-in-clang/</guid><description>Out of three headline C++20 features (modules, coroutines and the third one), modules are, in my opinion, by far the most important for the daily use. Modules aim to replace the legacy header system inherited from C and based on primitive textual inclusion with a more scalable, hermetic and fine-grained system.
There has been slow but steady progress on implementing modules in various compilers and build systems. I recently read a blog post &amp;ldquo;import CMake; C++20 Modules&amp;rdquo; and, among other things, learned that Clang 16 supports modules out of the box.</description></item><item><title>Migrating to a safer API with {fmt} 8.x</title><link>https://vitaut.net/posts/2022/migrating-to-safer-api/</link><pubDate>Sat, 29 Jan 2022 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2022/migrating-to-safer-api/</guid><description>We recently migrated a large codebase from {fmt} 7.x to 8.1.1 and in this blog post I&amp;rsquo;ll show some of the fun issues discovered thanks to improved diagnostics in the new version of this library.
Let&amp;rsquo;s start with this piece of questionable code:
std::string format_error( std::uint_least8_t squishiness) { static const std::string format = &amp;#34;Invalid squishiness: {}&amp;#34;; return fmt::format(format, squishiness); } It looks relatively innocent but there are multiple problems with it:</description></item><item><title>iOS SSID format string bug is preventable</title><link>https://vitaut.net/posts/2021/preventing-format-string-bugs/</link><pubDate>Tue, 22 Jun 2021 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2021/preventing-format-string-bugs/</guid><description>After joining my personal WiFi with the SSID “%p%s%s%s%s%n”, my iPhone permanently disabled it’s WiFi functionality. Neither rebooting nor changing SSID fixes it :~)
— Carl Schou (@vm_call) on Twitter
The SSID format string bug in iOS WiFi service has been making rounds on social media. This blog post nicely pinpoints the root cause to concatenating the SSID with a string and passing the result to a logging method that uses it as a format string.</description></item><item><title>A quest for safe text formatting API</title><link>https://vitaut.net/posts/2021/safe-formatting-api/</link><pubDate>Wed, 16 Jun 2021 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2021/safe-formatting-api/</guid><description>Since the introduction of format strings in Fortran in the 50s pretty much all major programming languages used them in their text formatting and I/O APIs:
printf-based: C, Haskell, Java/JVM languages, PHP and others Python-format-based: Python, Rust, C++ (starting from C++20) NIH-based: C#/.NET One notable exception is C++ iostreams that use operator overloading and per-stream state manipulation to control formatting. At this point stateful APIs have pretty much proved to be a failure in terms of usability and performance and many C++ programmers prefer *printf instead.</description></item><item><title>Writing files 5 to 9 times faster than fprintf</title><link>https://vitaut.net/posts/2020/optimal-file-buffer-size/</link><pubDate>Tue, 04 Aug 2020 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2020/optimal-file-buffer-size/</guid><description>The value of BUFSIZ has been chosen at random in 1989 and can no longer be changed because that would break ABI.
— Peter Dimov (@pdimov2) on Twitter
I recently added a new unsynchronized file output API to the {fmt} library. Together with format string compilation, zero memory allocations and locale-independent formatting by default this gives you a high performance file output from a single thread.
Here&amp;rsquo;s a small example demonstrating the new API:</description></item><item><title>Converting a hundred million integers to strings per second</title><link>https://vitaut.net/posts/2020/fast-int-to-string-revisited/</link><pubDate>Sat, 13 Jun 2020 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2020/fast-int-to-string-revisited/</guid><description>Almost 7 years ago I wrote a blog post comparing performance of different methods of converting an integer into a string. A lot of things have changed since then so I decided to write a follow-up post and see how much progress has been made over the years.
First of all let&amp;rsquo;s look at the benchmark itself. It is based on Boost Karma int_performance benchmark ported to Google Benchmark to make the results more reproducible.</description></item><item><title>Reducing {fmt} library size 4x using Bloaty McBloatface</title><link>https://vitaut.net/posts/2020/reducing-library-size/</link><pubDate>Thu, 21 May 2020 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2020/reducing-library-size/</guid><description>When it comes to comparing different software solutions, speed is often the main if not the only factor considered. This is not the case in the {fmt} library which tries to find a good balance between speed, binary size and compile times by default and give you an option to get maximum performance in cases that matter.
A lot of effort has been put into making binary code at the usage site very compact, comparable to that of printf.</description></item><item><title>std::format in C++20</title><link>https://vitaut.net/posts/2019/std-format-cpp20/</link><pubDate>Tue, 23 Jul 2019 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2019/std-format-cpp20/</guid><description>I&amp;rsquo;m happy to announce that the Text Formatting proposal (std::format) made it into the C++20 Committee Draft at the Cologne meeting, just in time before the feature freeze. This concludes a three-year long design, implementation, and standardization effort.
Here&amp;rsquo;s a brief history of the proposal aka &amp;ldquo;what took you so long?&amp;rdquo;:
2016-08-17:
posted on Reddit floating the proposal idea 2016-08-27:
committed the initial proposal draft on GitHub 2017-07-10 to 15, Toronto, Canada:</description></item><item><title>Formatting floating point numbers</title><link>https://vitaut.net/posts/2019/formatting-floating-point-numbers/</link><pubDate>Mon, 11 Feb 2019 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2019/formatting-floating-point-numbers/</guid><description>Is floating-point math broken?
&amp;ndash; Cato Johnston (Stack Overflow)
Formatting floating-point (FP) numbers is a surprisingly complicated task. While you can probably write a decent integer to string conversion in a matter of minutes, a good FP formatting algorithm deserves a paper in a scientific journal. One such algorithm, or rather a class of algorithms, called Grisu was published in the paper &amp;ldquo;Printing floating-point numbers quickly and accurately with integers&amp;rdquo; by Florian Loitsch in 2010.</description></item><item><title>ISO C++ standards committee meeting in Rapperswil</title><link>https://vitaut.net/posts/2018/iso-cpp-meeting-rapperswil/</link><pubDate>Fri, 15 Jun 2018 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2018/iso-cpp-meeting-rapperswil/</guid><description>Last week I attended the ISO C++ standards committee meeting in beautiful Rapperswil and here are some highlights biased towards what I’m interested in and what I had a chance to attend (mostly text formatting, modules, and various library evolution stuff). For a more comprehensive report see 2018 Rapperswil ISO C++ Committee Trip Report (Contracts for C++20; Parallelism TS v2 published; Draft Reflection TS).
Text Formatting Revision 2 (zero-based, obviously) of my paper, P0645R2 Text Formatting, was reviewed on Wednesday.</description></item><item><title>Text Formatting at the ISO C++ standards meeting in Jacksonville</title><link>https://vitaut.net/posts/2018/text-formatting-jacksonville/</link><pubDate>Sat, 17 Mar 2018 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2018/text-formatting-jacksonville/</guid><description>This week I attended the ISO C++ standards committee meeting to present the second revision of my paper P0645R1 Text Formatting, based on the {fmt} formatting library. The first revision was reviewed by Library Evolution Working Group (LEWG) in June 2017 in Toronto and there was a lot of feedback, particularly I&amp;rsquo;ve been asked to
investigate compile-time format string processing, look at using or explain why not to use an output iterator, use string_view, allow pre-computation of output size, add benchmarks.</description></item><item><title>Improving compile times of C++ code</title><link>https://vitaut.net/posts/2017/improving-compile-times/</link><pubDate>Sat, 09 Dec 2017 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2017/improving-compile-times/</guid><description>In the previous blog post I described how to catch errors early at the cost of somewhat increased compile times. In this one, I&amp;rsquo;ll explore the other direction and discuss reducing compile times, again using the fmt library as an example.
Use variadic templates judiciously Variadic templates are awesome, they enable natural function-style APIs where we previously had to get by with, often confusing, operator overload. For example, compare</description></item><item><title>Compile-time format string checks</title><link>https://vitaut.net/posts/2017/compile-time-format-strings/</link><pubDate>Sun, 05 Nov 2017 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2017/compile-time-format-strings/</guid><description>Note: the API described in this post is outdated, please use the one documented in Format string compilation instead.
Compile-time validation of format strings in various forms is one of the most requested features in the fmt project on GitHub (#62, #166, #295, #467, #492, #544, #546) and a major request from the C++ standards committee after the review of my formatting paper. In 2015 I came up with an unsatisfactory solution to this problem that only worked with printf syntax and involved macros.</description></item><item><title>Format API improvements</title><link>https://vitaut.net/posts/2017/format-api-improvements/</link><pubDate>Sun, 20 Aug 2017 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2017/format-api-improvements/</guid><description>It&amp;rsquo;s been a while since my last post. Two important things happened in the meantime to the fmt project: revision 0 of the formatting paper has been submitted to the standards committee and version 4 of the library released (thanks to Jonathan Müller for putting the new release together). In this post I will describe the recent work in the std branch of the library that is an implementation of the standards proposal.</description></item><item><title>Reducing printf call overhead with variadic templates</title><link>https://vitaut.net/posts/2016/reducing-printf-call-overhead/</link><pubDate>Sat, 05 Nov 2016 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2016/reducing-printf-call-overhead/</guid><description>A few days ago I learned about a cool new project called printpp which is a printf format string preprocessor. It rewrites format strings from brace-delimited format into printf format at compile time. Although the project mentions Python formatting, the only thing they seem to have in common is delimiters.
Great thing about this approach is that it doesn&amp;rsquo;t add any overhead to printf. For example, the code
int main() { pprintf(&amp;#34;{} hello {s}!</description></item><item><title>Pokémon GO attack party optimization</title><link>https://vitaut.net/posts/2016/pokemon-go/</link><pubDate>Tue, 19 Jul 2016 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2016/pokemon-go/</guid><description>We designed distributed architectures, highly available and resilient systems, reactive interfaces &amp;amp; what are they for? Catching Pokemons ;(
— Mario Fusco (on Twitter)
Pokémon GO, an augmented-reality mobile game recently released by Niantic, has been generating a lot of hype since it went public in the beginning of July. I was caught in it myself a few days ago and, already bored with choosing a good gym attack party by hand, I decided to apply optimization methods to this important task.</description></item><item><title>reStructuredText vs Markdown for documentation</title><link>https://vitaut.net/posts/2016/rst-vs-markdown/</link><pubDate>Thu, 16 Jun 2016 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2016/rst-vs-markdown/</guid><description>In this post I am going to share my experience of using Markdown and reStructuredText (RST) for technical documentation. As a library developer I have to write a fair amount of it, for example, the fmt library documentation, and I&amp;rsquo;ve used both languages extensively. In fact, I&amp;rsquo;m writing this blog post in Markdown.
At first sight RST and Markdown look very similar. Both are lightweight markup languages that emphasize plain-text readability.</description></item><item><title>Giving up on Julia</title><link>https://vitaut.net/posts/2016/giving-up-on-julia/</link><pubDate>Fri, 13 May 2016 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2016/giving-up-on-julia/</guid><description>When I first learned about the Julia programming language, I became very enthusiastic about it. Just look at the feature list from their website:
Multiple dispatch: providing ability to define function behavior across many combinations of argument types Dynamic type system: types for documentation, optimization, and dispatch Good performance, approaching that of statically-compiled languages like C Built-in package manager Lisp-like macros and other metaprogramming facilities Call Python functions: use the PyCall package Call C functions directly: no wrappers or special APIs Powerful shell-like capabilities for managing other processes Designed for parallelism and distributed computation Coroutines: lightweight “green” threading User-defined types are as fast and compact as built-ins Automatic generation of efficient, specialized code for different argument types Elegant and extensible conversions and promotions for numeric and other types Efficient support for Unicode, including but not limited to UTF-8 MIT licensed: free and open source Other than the dynamic type system, what not to like about this?</description></item><item><title>Working with optimization problems in .nl files</title><link>https://vitaut.net/posts/2016/working-with-optimization-problems-in-nl-files/</link><pubDate>Mon, 07 Mar 2016 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2016/working-with-optimization-problems-in-nl-files/</guid><description>In one of the previous posts I have described an API for reading .nl files. The NL reader API is now stable and documented at http://ampl.github.io/nl-reader.html. Also you can find a few examples of using it in nl-example.cc. It is still the way to go if you want to process .nl files in the most efficient way. However, if you want to load the complete optimization problem and work with it, the NL reader will require you to manage the data structures that represent the problem yourself.</description></item><item><title>Solving the GCHQ Christmas Challenge with AMPL and a CP solver</title><link>https://vitaut.net/posts/2015/solving-gchq-christmas-challenge-with-ampl/</link><pubDate>Sun, 13 Dec 2015 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2015/solving-gchq-christmas-challenge-with-ampl/</guid><description>The GCHQ&amp;rsquo;s Christmas Challenge puzzle shown in the picture below has been making rounds on social media and in the news so I decided to try modeling it in AMPL and solving with a constraint programming solver.
Here are the rules of the puzzle:
In this type of grid-shading puzzle, each square is either black or white. Some of the black squares have already been filled in for you.
Each row or column is labelled with a string of numbers.</description></item><item><title>C++ Format packages for Linux and OS X</title><link>https://vitaut.net/posts/2015/cppformat-packages-for-linux-and-osx/</link><pubDate>Mon, 26 Oct 2015 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2015/cppformat-packages-for-linux-and-osx/</guid><description>Ease of use has always been one of the main features of C++ Format. You only need to add two files, format.h and format.cc to your project in order to start using the library. And now C++ Format is available on major Linux distributions and Homebrew on OS X so you can install it on your system with a package manager. Here is a possibly incomplete list of supported systems:</description></item><item><title>Compile-time checking of printf arguments in C++ Format</title><link>https://vitaut.net/posts/2015/compile-time-checking-of-printf-args-in-cppformat/</link><pubDate>Wed, 22 Apr 2015 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2015/compile-time-checking-of-printf-args-in-cppformat/</guid><description>Update: See Compile-time format string checks for a better solution that doesn&amp;rsquo;t involve macros.
As an author of C++ Format, a library that implements safe Python-like and printf-like formatting, every now and then I hear questions whether it supports compile-time checking of format strings and arguments. Until recently I didn&amp;rsquo;t know any way to do this, but then it occurred to me that it is possible to have some compile-time checking based on GCC&amp;rsquo;s format attribute described here.</description></item><item><title>Reliable detection of strerror variants</title><link>https://vitaut.net/posts/2015/reliable-detection-of-strerror-variants/</link><pubDate>Fri, 13 Mar 2015 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2015/reliable-detection-of-strerror-variants/</guid><description>One of the challenges of writing portable code is dealing with variations of APIs that are supposed to be standard. In this post I&amp;rsquo;ll talk about strerror and friends which turned out to be particularly interesting to detect.
First, why not just use strerror which is defined in the C and POSIX standards? Unfortunately, quoting one of the standards:
The strerror() function need not be thread-safe.
which is a bit of a non-starter.</description></item><item><title>Comparison of C++ Format and C library's printf</title><link>https://vitaut.net/posts/2015/comparison-of-cppformat-and-printf/</link><pubDate>Thu, 26 Feb 2015 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2015/comparison-of-cppformat-and-printf/</guid><description>I was recently asked on GitHub why would someone use fmt::printf, which is a part of the C++ Format library, over the standard C library printf. This is a fair question and so I decided to write this blog post comparing the two.
Disclaimer: I&amp;rsquo;m the author of C++ Format, so this is all very biased =).
Whenever I mention printf without a namespace in this post I mean the whole family of printf functions from the C standard library, including sprintf and fprintf.</description></item><item><title>Using C++ Format with Biicode</title><link>https://vitaut.net/posts/2014/using-cppformat-with-biicode/</link><pubDate>Tue, 30 Dec 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/using-cppformat-with-biicode/</guid><description>As a first experiment with Biicode, a C/C++ dependency manager, I decided to publish C++ Format there and this short post is about my initial experience with the service and how you can use the library with Biicode.
First of all, I really like the idea of a dependency manager for C++. This is something I&amp;rsquo;ve been looking for a long time after using such systems in other languages, namely PyPI/pip in Python and Maven in Java world.</description></item><item><title>Reading .nl files</title><link>https://vitaut.net/posts/2014/reading-nl-files/</link><pubDate>Fri, 19 Sep 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/reading-nl-files/</guid><description>The .nl format is possibly the most widely used format for representing mathematical optimization problems you&amp;rsquo;ve never heard of unless you are a solver developer. The reason it is not very well-known is because .nl is a low-level format designed for efficient machine input and output unlike algebraic modeling languages that are designed for human readability (at least some of them) and unlike MPS which is neither particularly human readable nor efficient.</description></item><item><title>Connecting a solver to AMPL</title><link>https://vitaut.net/posts/2014/connecting-solver-to-ampl/</link><pubDate>Fri, 11 Jul 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/connecting-solver-to-ampl/</guid><description>I&amp;rsquo;ve been planning to write this post for a while, but it was hard to choose the right solver. Most mainstream solvers already have AMPL interfaces and I din&amp;rsquo;t want to reimplement them. At the same time I didn&amp;rsquo;t want to use an obscure solver noone heard of.
Finally, I&amp;rsquo;ve found a good candidate for my post. The solver I&amp;rsquo;m going to use is called LocalSolver and it is a relatively new one (see Constraint Programming History) based on local search techniques.</description></item><item><title>Safe low-overhead alternative to printf</title><link>https://vitaut.net/posts/2014/low-overhead-safe-alternative-to-printf/</link><pubDate>Thu, 22 May 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/low-overhead-safe-alternative-to-printf/</guid><description>In posts Making string formatting fast and Fast integer to string conversion in C++ I have shown that safe alternatives to printf and sprintf such as the C++ Format library can perform on par and even outperform their unsafe C counterparts.
But speed is not the only parameter that may be of interest to us. Another important parameter is the size of compiled code or &amp;ldquo;code bloat&amp;rdquo; and this is what the current post is about.</description></item><item><title>Reporting system errors in C++ made easy</title><link>https://vitaut.net/posts/2014/reporting-system-errors-made-easy/</link><pubDate>Wed, 30 Apr 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/reporting-system-errors-made-easy/</guid><description>Reporting system errors in C++ is a daunting task. By system errors I mean errors returned by standard C library functions, POSIX or Windows API. In an ideal world you&amp;rsquo;d have a nice C++ API with errors reported as exceptions. But often you need to use this nasty C function that indicates failure by a special return value and sets errno. Or even worse, you have to call a Windows API function and the error code returned by GetLastError needs to be converted to a readable form via FormatMessage that will only appeal to you if you like functions with 7 arguments with meaning of some of them depending on values of the other.</description></item><item><title>NEOS statistics for 2013</title><link>https://vitaut.net/posts/2014/neos-statistics-for-2013/</link><pubDate>Thu, 02 Jan 2014 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2014/neos-statistics-for-2013/</guid><description>2013 is over so it&amp;rsquo;s time to report the annual NEOS Server statistics again.
The results are very different from the previous year. AMPL is now used in almost 90% of all submissions, a large increase from ~57% in 2012. The use of low-level formats such as MPS decreased to less than 4%, down from ~10% the year before.
Top three positions in the solver category are now occupied by nonlinear solvers, MINOS, MINLP and KNITRO.</description></item><item><title>Fast integer to string conversion in C++</title><link>https://vitaut.net/posts/2013/integer-to-string-conversion-in-cplusplus/</link><pubDate>Sat, 07 Sep 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/integer-to-string-conversion-in-cplusplus/</guid><description>An updated version of this post is available here: Converting a hundred million integers to strings per second.
In this post I compare the performance of several methods of integer to string conversion in C++:
sprintf std::stringstream std::to_string from C++11 boost::format from the Boost Format library boost::lexical_cast karma::generate from the Boost Spirit Parser framework fmt::format_int, fmt::format, fmt::format_to and fmt::compile from the {fmt} library Public-domain ltoa implementation decimal_from function suggested by Alf P.</description></item><item><title>Modern Benders decomposition in AMPL</title><link>https://vitaut.net/posts/2013/modern-benders-decomposition-in-ampl/</link><pubDate>Sun, 01 Sep 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/modern-benders-decomposition-in-ampl/</guid><description>I was thinking of how to implement Benders decomposition in AMPL in the way Paul Rubin calls &amp;ldquo;modern approach&amp;rdquo; in his great blog post, Benders Decomposition Then and Now. And experimenting with smpswriter, a program I recently wrote to convert deterministic equivalent problems written in AMPL into stochastic programming (SP) problems in SMPS, I realized that it can already be done and this is what this post is about.
As it often happens in mathematics, one thing is a special case of another or we can somehow reduce the problem to another one we know solution for.</description></item><item><title>Using Eclipse CDT in Ubuntu</title><link>https://vitaut.net/posts/2013/using-eclipse-cdt-in-ubuntu/</link><pubDate>Thu, 29 Aug 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/using-eclipse-cdt-in-ubuntu/</guid><description>One of the first IDEs that I used was Visual Studio 6.0 (shudder). It was a daunting experience, both the IDE and compiler were buggy, I remember having to reformulate perfectly valid programs to avoid internal compiler errors, standard compliance was something unheard of. I&amp;rsquo;m not sure how I didn&amp;rsquo;t give up programming altogether. The reason I used it despite all the problems is that I didn&amp;rsquo;t know about anything better at that time and due to the work requirements.</description></item><item><title>Visualizing geographical AMPL data using IPython and Google Charts</title><link>https://vitaut.net/posts/2013/visualizing-geographical-ampl-data-using-ipython-and-google-charts/</link><pubDate>Thu, 27 Jun 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/visualizing-geographical-ampl-data-using-ipython-and-google-charts/</guid><description>In this post I'll describe how to get geographical data from AMPL and display it in IPython using an interactive Google Chart. I'll use a simple map coloring problem implemented with AMPL constraint programming extensions.
First install the ampl extension for IPython also known as iampl if you haven't done this already. The extension is now available in the Python Package Index so you can use standard Python tools such as pip or easy_install to install it.</description></item><item><title>Solving a puzzle with AMPL and Gecode</title><link>https://vitaut.net/posts/2013/solving-a-puzzle-with-ampl-and-gecode/</link><pubDate>Fri, 08 Feb 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/solving-a-puzzle-with-ampl-and-gecode/</guid><description>Here&amp;rsquo;s an interesting little puzzle posted by Ryan Ng on Google+:
A 5 digit number is written on a whiteboard. Ron erases one of its digits and adds a newly constructed number to the original one. The result is 41751. What is the original number?
It can be easily solved with constraint programming and I&amp;rsquo;ll demonstrate how to do it using AMPL and Gecode. The model is very simple, it&amp;rsquo;s just a few lines of code:</description></item><item><title>AMPL magic: using IPython as an interface to AMPL</title><link>https://vitaut.net/posts/2013/ampl-magic-using-ipython-as-an-interface-to-ampl/</link><pubDate>Tue, 08 Jan 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/ampl-magic-using-ipython-as-an-interface-to-ampl/</guid><description>In this post I will give an introduction to iampl, a project which implements AMPL magics for IPython. IPython is a Python-based interactive environment with additional capabilities for visualization, rendering formulas, scientific computing, data introspection, etc. With iampl it is possible to use IPython as an interface to AMPL and do modeling, data processing and visualization in one rich environment. This post itself is also written using IPython.
You can download the latest version of iampl from here.</description></item><item><title>NEOS statistics for 2012</title><link>https://vitaut.net/posts/2013/neos-statistics-for-2012/</link><pubDate>Tue, 01 Jan 2013 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2013/neos-statistics-for-2012/</guid><description>With the start of a new year I think it&amp;rsquo;s about time to look at the NEOS Server statistics for 2012. So I wrote a small IPython notebook that extracts the information from NEOS Solver Access Statistics and here are the results.
Gurobi has become number one solver on NEOS in 2012 which is not surprising (for me). Interestingly, top NEOS solvers are either nonlinear or mixed integer or both. Modelling languages continue to dominate as in a similar report made by Erwin Kalvelagen in 2009, with AMPL being the most widely used input format.</description></item><item><title>Does string formatting boost karma?</title><link>https://vitaut.net/posts/2012/does-string-formatting-boost-karma/</link><pubDate>Fri, 21 Dec 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/does-string-formatting-boost-karma/</guid><description>If you&amp;rsquo;ve read any of my recent posts about string formatting (A better string formatting library for C++, Making string formatting fast or I can’t believe it’s not Python) I apologize for bringing this topic up again.
Today my attention was drawn by Boost Karma, which is a less-known Boost library for output generation. The authors of this library claim that it is much faster than printf, std::stream and boost::format, so I decided to have a look at it.</description></item><item><title>I can't believe it's not Python</title><link>https://vitaut.net/posts/2012/i-cant-believe-its-not-python/</link><pubDate>Mon, 17 Dec 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/i-cant-believe-its-not-python/</guid><description>I&amp;rsquo;ve been recently experimenting with a new string formatting library for C++ and realized that it can be used for converting objects to strings à la Python&amp;rsquo;s str function. In fact the implementation of such function is almost trivial:
template &amp;lt;typename T&amp;gt; std::string str(const T &amp;amp;value) { return fmt::format(&amp;#34;{}&amp;#34;, value); } See this post to learn more about fmt::format.
The str function, unlike sprintf, can work with any type that has appropriate std::ostream inserter operator &amp;lt;&amp;lt;.</description></item><item><title>Making string formatting fast</title><link>https://vitaut.net/posts/2012/making-string-formatting-fast/</link><pubDate>Sat, 15 Dec 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/making-string-formatting-fast/</guid><description>In one of the previous posts I&amp;rsquo;ve introduced C++ Format, a new formatting library for C++ and briefly described its API on a few examples. In this post I&amp;rsquo;ll compare its performance with other libraries and discuss some design aspects that make it fast.
To measure performance I used a benchmark by Chris Foster, the author of tinyformat library. I changed the benchmark to include my new formatting library and ran it three times taking the best time for each method:</description></item><item><title>Migrating from Blogger to GitHub Pages</title><link>https://vitaut.net/posts/2012/migrating-from-blogger-to-github-pages/</link><pubDate>Fri, 14 Dec 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/migrating-from-blogger-to-github-pages/</guid><description>I&amp;rsquo;ve just migrated from Blogger to GitHub Pages. This is the first post that I&amp;rsquo;m writing using the new platform.
The main reason for migration was that I wanted to write my posts in a lightweight markup language such as Markdown or reStructured Text. In Blogger I had to either use a WYSIWYG editor which is OK for simple posts but not for advanced stuff such as code snippets or formulas, or an HTML editor.</description></item><item><title>A better string formatting library for C++</title><link>https://vitaut.net/posts/2012/a-better-string-formatting-library-for-cplusplus/</link><pubDate>Wed, 12 Dec 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/a-better-string-formatting-library-for-cplusplus/</guid><description>When I started learning C++ I kind of liked the IOStreams library. It was safe, extensible and could work with user-defined types. This compared favorably with the printf family of functions. However, as I started using C++ more and more in my daily job I found out that IOStreams had serious flaws. This answer on Stack Overflow nicely summarizes several issues with IOStreams:
Poor error handling Poor separation between formatting and I/O Poor support for i18n The popular Google C++ Style Guide even restricts the use of streams only to logging.</description></item><item><title>Constraint Programming in AMPL</title><link>https://vitaut.net/posts/2012/constraint-programming-in-ampl/</link><pubDate>Tue, 09 Oct 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/constraint-programming-in-ampl/</guid><description>AMPL has supported constraint programming since early 2000s when the paper Extending an Algebraic Modeling Language to Support Constraint Programming was published. This work has been recently resumed with an update to ilogcp, the AMPL driver for IBM ILOG CPLEX CP Optimizer (yes, that's how it is called), and more work in this direction is underway. In this post I will show how to build the ilogcp driver and use it with AMPL to solve constraint programming models.</description></item><item><title>Cooking traditional Belarusian cold soup</title><link>https://vitaut.net/posts/2012/cooking-traditional-belarusian-cold-soup/</link><pubDate>Thu, 27 Sep 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/cooking-traditional-belarusian-cold-soup/</guid><description>For a change, I decided to write about something other that software, because previous posts might have given an impression that I am a complete nerd and I want to dispel it. So in this post I am going to write about food, in particular, I am going to give simple instructions (algorithm) to cook a traditional Belarusian cold soup called kholodnyk (Russian spelling is "холодник" which literally means "</description></item><item><title>Three months of AMPL development in one minute</title><link>https://vitaut.net/posts/2012/three-months-of-ampl-development-in-one-minute/</link><pubDate>Mon, 13 Aug 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/three-months-of-ampl-development-in-one-minute/</guid><description>It&amp;rsquo;s been three month since I created the AMPL GitHub repository which is based on AMPL material from Netlib with some changes. The following video shows the change history:
The video was created using Gource:
$ gource -1280x720 --title AMPL --hide filenames,mouse \ --seconds-per-day 0.55 --date-format &amp;#34;%Y-%m-%d&amp;#34; -o - | \ ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec \ libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 ampl.</description></item><item><title>Using SCIP with AMPL</title><link>https://vitaut.net/posts/2012/using-scip-with-ampl/</link><pubDate>Tue, 07 Aug 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/using-scip-with-ampl/</guid><description>In this post I will describe how to build recently released SCIP version 3.0.0 with AMPL support on Linux. I am using Ubuntu 12.04, but the process should be similar on other distributions with apt replaced with whatever package manager available there.
1. Download the archive containing the source code for SCIP Optimization Suite and extract its content:
$ tar xzf scipoptsuite-3.0.0.tgz 2. Install the dependencies:
$ sudo apt-get install g++ zlib1g-dev bison flex \ libgmp-dev libreadline-dev libncurses5-dev 3.</description></item><item><title>Testing derivatives using numerical differentiation</title><link>https://vitaut.net/posts/2012/testing-derivatives-using-numerical-differentiation/</link><pubDate>Tue, 17 Jul 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/testing-derivatives-using-numerical-differentiation/</guid><description>I've been working recently on the AMPL interface for the GNU Scientific Library. Adding a function to AMPL normally requires providing first and second partial derivatives for it. Computing the derivatives is straightforward and there are plenty of tools, such as Wolfram Alpha, that automate this. However, transferring this to code is a tedious and error-prone process.
For example, consider the function gsl_sf_bessel_I0_scaled(double x) which is defined as \(e^{-|x|} I_0(x)\), where \(I_0(x)\) is the regular modified cylindrical Bessel function of zeroth order.</description></item><item><title>Comparing methods of downloading software from Netlib</title><link>https://vitaut.net/posts/2012/comparing-methods-of-downloading-software-from-netlib/</link><pubDate>Mon, 25 Jun 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/comparing-methods-of-downloading-software-from-netlib/</guid><description>Netlib is a repository for mathematical software such as BLAS, LAPACK and, most importantly =), AMPL Solver Library (ASL). The software can be retrieved using a number of protocols and as I found out the download speed can vary greatly. For example, it took me 10 minutes to retrieve entire ASL by FTP using wget while other options can reduce this time to tens of seconds. This was the reason why I decided to do this small comparison of different methods to retrieve software from Netlib.</description></item><item><title>Installing Buildbot in Ubuntu</title><link>https://vitaut.net/posts/2012/installing-buildbot-in-ubuntu/</link><pubDate>Sat, 16 Jun 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/installing-buildbot-in-ubuntu/</guid><description>Buildbot is a continuous integration (CI) system for build and test automation. It is successfully used by many well-known projects such as WebKit, Chromium and LLVM. My particular interest in Buildbot is in using it for building and testing AMPL solvers on different platforms.
While the Buildbot documentation is good in general, information about installing this CI system in Debian-based distributions is somewhat spotty. So in this post I am going to give minimal instructions for setting up Buildbot 0.</description></item><item><title>Beautiful math in Javadoc</title><link>https://vitaut.net/posts/2012/beautiful-math-in-javadoc/</link><pubDate>Sat, 14 Jan 2012 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2012/beautiful-math-in-javadoc/</guid><description>A formula like a picture is often worth a thousand words. Working on software for mathematical optimization, I've been wondering how can I embed math in my API documentation generated by Javadoc. Recently I had some time to explore this problem and this post is devoted to my findings.
As Javadoc generates output in HTML format, MathML is the obvious candidate for embedded math. However, I am not paid for the number of lines of code I write, so MathML doesn't really appeal to me.</description></item><item><title>Ubuntu on a SONY VAIO VPCS11J7E laptop</title><link>https://vitaut.net/posts/2011/ubuntu-on-a-sony-vaio-vpcs11j7e-laptop/</link><pubDate>Thu, 08 Dec 2011 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2011/ubuntu-on-a-sony-vaio-vpcs11j7e-laptop/</guid><description>Today I finally got my SONY VAIO VPCS11J7E laptop delivered after a warranty repair. They replaced a few parts and thoroughly cleaned the laptop. Now it looks as new apart from a small crack on flimsy plastic around the hinges (I rejected their generous offer to replace the plastic for 200 quid.)
I immediately wiped out Windows 7 and (other) junkware that they had put on my laptop eating up a huge chunk of my precious SSD space, and installed Ubuntu Oneiric Ocelot.</description></item><item><title>First experience with Xtext</title><link>https://vitaut.net/posts/2011/first-experience-with-xtext/</link><pubDate>Sat, 03 Dec 2011 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2011/first-experience-with-xtext/</guid><description>In this post I describe my experience with the recent version (2.1) of Xtext, a framework for developing domain specific languages (DSLs).
The main input for Xtext is a grammar file written in an elegant little language. The grammar language uses a variation of Extended Backus-Naur Form to define rules for both terminals and nonterminals. So far this is very similar to parser generators like GNU bison or ANTLR which can create parsers out of similar grammar definitions.</description></item><item><title>User-defined keyboard shortcuts in Nautilus</title><link>https://vitaut.net/posts/2011/user-defined-keyboard-shortcuts-in-nautilus/</link><pubDate>Fri, 18 Feb 2011 00:00:00 +0000</pubDate><guid>https://vitaut.net/posts/2011/user-defined-keyboard-shortcuts-in-nautilus/</guid><description>In this post I describe how to add arbitrary keyboard shortcuts to the Nautilus file manager using its extension API. I really like Nautilus, it has a clean interface and lots of features under the hood. One of the things I was missing coming from the world of orthodox file managers was an embedded terminal which can be shown/hidden with a simple keyboard shorcut. Recently there appeared an extension called Nautilus Terminal that provides exactly this.</description></item></channel></rss>