/images/p1.jpg

Hi, I'm Tomasz

I'm a professional C++ software engineer with over a decade of hands on development experience with variety of technologies (mostly Linux & embedded systems). This is my blog.

Find me on social media

Experimenting with parser combinators in non-functional languages

Functional parsing and parser combinators Recently, on my routine round through YouTube and social media, I’ve came across a video from Ashley Jeffs regarding a message broker he’s the author of called Benthos. Benthos itself is very interesting and I recommend to learn more about it, but what especially caught my interest was a different video from Ashley, regarding bloblang - a configuration language for Benthos written using parser combinators. Frankly, this was the first time I’ve heard that term and, intriguing as it sounds, I wanted to learn all about it.

Three C++ misconceptions from C programmers

In this post I’ll try to clarify some of the misconceptions about C++ which I often find in various code bases. People have their habits C++ is a complex language. Part of this complexity stems from legacy. With legacy comes source code which is often bad. Code that is difficult to maintain, which relies on false assumptions. These assumptions have been reinforced in programmers’ minds early on when the language was in its peak popularity (which was probably like 20 years ago) or (even worse) have been adopted from C world by people who still think that C++ is just C with classes.

Manipulating /proc files as structured data

/proc provides essential data about the operating system on which the program is running. Often there’s a need as well to alter system’s configuration using /proc files as an interface. Now, you may ask yourself, why should you care? After all, there are already well established solutions like i.e. procfs or containerd allowing for convenient dealing with proc files, cgroups… and I agree. Sometimes though you just don’t want to suck in a huge dependency like containerd and it’s much easier to write something smaller that is better tailored to specifics of the problem at hand.

Golang method expressions

What are method expressions? Coming from a C++ background, I’ll allow myself to use a C++ example. If you know C++, Golang’s method expressions are very similar to member pointers. The code is relatively simple and even if you’re not a C++ enthusiast it should be possible to understand the intentions Here’s a short C++ recap: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 class Foo { public: std::string foo() { return "foo"; } int bar(int i) { return i; } }; using FooPtr = std::string (Foo::*)(); using BarPtr = int(Foo::*)(int); int main(int argc, const char *argv[]) { Foo f{}; FooPtr fooPtr = &Foo::foo; BarPtr barPtr = &Foo::bar; std::cout << (f.

I wrote my own argument parser in C++20

Why? Well, it kind of happened by accident, if I’m honest. While working on a different project, where I’m building a set of utilities (assembler, disassembler, debugger, simulator) for a custom programming language, I needed a parser to create some basic CLI interfaces. I wanted to limit the amount of dependencies and thus didn’t want to reach for Boost’s program_options. Another reason is that I don’t really like it that much.

Quickest way to learn is to be inquisitive about everything!

It starts with “how?” std::variant is a new addition to C++ standard library adopted from ominous boost libraries. Just as a reminder, std::variant is a type safe union with a very cool visitor interface, thanks to which handling its state is very convenient. The type itself wouldn’t be very special to me until I stumbled upon this sentence on cppreference As with unions, if a variant holds a value of some object type T, the object representation of T is allocated directly within the object representation of the variant itself.

Interview question: merging intervals

Let’s write a calendar app Recently I stumbled upon a very common interview question (I think it can be found both in AlgoExpert database as explained in this mock interview) and CoderPad examples database. The gist of the problem is that you’re asked to write a calendar app, which given two calendars will return a list of free time slots between the two. Each calendar is a list of meetings.