Stone Code

Inverse Dependency Makefiles

Wed, Oct 30, 2019, ~400 Words

When working in C or C++, I typically use GNU make as a build system. The C/C++ ecosystem has not really come to a consensus on a preferred build system, but this is not a post about why you might (or might not) choose make. However, one weakness is that make does not provide tools to help with discovery or setting build configuration. I recently found a simple trick that helps in this regard.

Tags: programming, make

Read more →

Convenience Functions for Testing in Go

Wed, Sep 4, 2019, ~800 Words

Go’s excellent tooling extends to support for testing. Nevertheless, there are quite a few packages that exist to make it easier to write tests. In particular, Go’s verbose (although accepted) handling of errors is a weakness here, as writing tests can involve a lot of boilerplate. Compare writing a test case using, for example, Catch2, with what would be required if using solely the standard library in Go. Unfortunately, I have not found a utility package for testing that meet my design criteria.

Tags: programming, Go

Read more →

Design Comments on sync.WaitGroup

Wed, May 15, 2019, ~800 Words

The goal of this post is to look at the design of sync.WaitGroup. This type is obviously subject to Go’s compatibility guarantee, so it won’t be changing. Nevertheless, the curious might be interested in a comparison with an alternate design, and those ideas might be useful elsewhere. This comparison is by looking at sync.WaitGroup as one type of executor.

Tags: programming, Go

Read more →

Testing Concurrent Code

Wed, Apr 17, 2019, ~200 Words

With concurrent code, non-determinism is often present. I knew this, but obviously did not internalize it. Tests of an optimization of sync.Once passed, but the code was incorrect. I got good feedback on the mailing list about what invariant I’d missed, but, additionally, I got feedback that the error could have caught by testing if I had run the test repeatedly.

Tags: programming

Read more →

Go's Code Coverage Resolution

Mon, Mar 25, 2019, ~900 Words

For C++ development, I developed GCovHTML to generate reports on code coverage. For Go development, I use the builtin tool to generate these reports. The HTML reports generated by Go are nice in that that are a single file, but they do not include as much detail. To evaluate whether or not it would be feasible to process the profile data from Go using my tool, I investigated the format of the coverprofile output files. This turned up an interesting comparison in how Go tracks coverage data, and what that means for reporting.

Tags: programming, Go

Read more →

Binary Asset Compiler Benchmarks

Tue, Feb 19, 2019, ~1300 Words

To learn parts of LLVM related to machine code generation, I decided to follow through on a comment that a binary asset compiler could be written in a few hundred lines of C++. The goal of the program would be to provide fast and portable compilation of binary assets. The term compilation is used loosely here, it is more to wrap the asset into an object file, which can then be linked into a library or program. This project turned into a bit of code golf, and I implemented a second separate binary asset compiler. What follows is a comparison of the performance of these tools with other options.

Tags: programming

Read more →

A criticism of std::embed (D1040) - Learned

Fri, Feb 8, 2019, ~400 Words

A few people responded to the criticism of D1040 on reddit, and clearly there are at least a few people who are keen to see std::embed move forward. The rebuttals were imprecise, which obviously makes understanding the commenters’ concerns more difficult. However, the discussion did clarify a few things for me.

Tags: programming, C++

Read more →