Hunter, C++ package management made easy
In a previous post, I detailed involved and frustrating process I needed to go through to compile OpenCV as part of my application. You can see the post in this link.All the trouble I describe there could have been avoided by using Hunter - a CMake based package manager for C++ projects. The idea is to have a sort-of repository of configuration and install scripts for different packages that would handle configuring 3rd-party dependencies (and their dependencies) for your project. Kinda like NuG ...
OpenCV + Visual Studio + CMake = Adventure time
In theory, configuring a popular library like OpenCV in CMake should be easy. In practice, sadly, it is anything BUT easy. Why? Let me show you…
Note that I am not very knowledgeable in CMake, so it is possible I am doing something stupid. If so, it is even worse - as far as I understand the intent behind CMake, it should make developers lives easier, not harder.
This post is documentation of a frustrating journey of performing what should have been a trivial task - make dependency compile as ...
Hello ANTLR (writing parsers is easier than you think!)
After playing around with the awesome ANTLR for a while (it is a parser generator, in case you are not familiar with it), I decided to write something that could have helped me before I started looking into parsers. This post assumes you have heard of parsers but never actually wrote one.
A word (or two) on what parsers areWhen you have a text with known syntax, be it structured logging, programming language or configuration files and you want to parse it with an application, you can use a parse ...
Even simple stuff, like C# TPL can surprise you!
What do you think would happen if you run this code? Can you guess without actually running it?Now try running it and see what happens. It might actually surprise you…
I know I was surprised by this, it took me a minute or two and a glimpse into relevant documentation page to understand what happened here.The backgroundTask in the above code is actually a continuation task, and not the background worker. Since the background worker runs successfully, the continuation task is canceled, as it ...
Yet Another (Cryptic) CMake Error
I like CMake. I really do. But sometimes… it is frustrating.The samples found online are understandable and easy to follow and everything compiles fine until you try something non-trivial.Like having an external project compile as part of your own so including and linking can be done easier.I have created a new CMake project, then added sources of OpenCV with as a git submodule.The resulting CMake file looked like this:
123456cmake_minimum_required (VERSION 3.13)project ("[some project name ...
Adventures of a C# dev in C++ land - dependency injection
I stumbled upon Boost.DI by accident and was instantly intrigued: for a developer used to C#, dependency injection during compilation time sounds crazy.
Boost.DI uses C++ template metaprogramming to implement its functionality. If you are not familiar with it, take a look here.
Dependency InjectionResolves dependencies during compilation sounds great as an optimization. The biggest problem with DI libraries in C# is performance.Just take a look at IOC/DI library benchmarks!
In case you ...
Synchronization primitives + async/await = trouble
Recently, my colleague was investigating an interesting issue. A ReaderWriterLockSlim was sometimes throwing the following exception when releasing a read lock.
1System.Threading.SynchronizationLockException: 'The read lock is being released without being held.'
The code looked fairly straightforward and it should have worked properly, but after some meditation on the mysteries of C# and the universe, he noticed something interesting. An await call between taking the lock and releasin ...
Listening to data changes in PostgreSQL and C#
To poll or not to poll?Nowadays, fast, responsive UI that reacts to data changes is pretty much a given (well, not always, yes, but often enough to talk about it!). If it is an application with just one user it is not that hard to implement, but what if there are multiple users in a system that affect each other?The answer would be… not to poll if you can, because more often than not there is another, better way. Many databases, both NoSQL and RDBMS offer functionality to push events to the conn ...
Hello World with multiple microservices
A friend of mine was having trouble finding simple but working example of microservices that he could tinker with, finding instead either buzzword-heavy theoretical articles or just samples in weird languages. I decided to prepare a simple project so it can be understood in short amount of time.
The sample project is modeling a “Starbucks-style” coffee ordering process with a cashier, barista and order pick up counter with the following flow:
sequenceDiagram
participant Customer
parti ...
Middleware implementation in ASP.Net Core is weird
This might seem like a clickbait-y article, but… it really looks this way! Allow me to explain.For one of my pet projects, I considered implementing REST endpoints using Nancy, a nice and low ceremony web framework that I like.To my surprise, in order to host it in .Net Core, as evident from the example here, I would need to use Microsoft.AspNetCore.Owin as a “mediator” between Kestrel and Nancy. Seeing this as an excuse to write something in the area I haven’t looked into yet, I looked into imp ...