475

How I Wrote a C++ Compiler 15 Years Ago

15 years ago, there was no Facebook. There was no C++ compiler with the diagnostic messages in Russian (my native language). Several C++ standards have been released since then, and technologies have made a huge leap forward in development. Today, having so many various frameworks, it doesn’t take too long to write a code analyzer or a programming language of your own. This post is about how I started my career and reached an expert level by means of self-development and writing a C++ compiler.
1,991

Asynchronous Programming Part 2: Teleportation through Portals

Finally, I have finished another article about asynchronous programming. It develops the ideas of the previous one [1]. Today we are going to discuss quite a difficult task that will reveal the power and flexibility of using coroutines in various nontrivial scenarios. At the end, we are going to consider two tasks on race-condition, and also a small bonus. By the way, the first article on asynchronous programming has become quite popular.
3,707

Asynchronous Programming: Back to the Future

Asynchronous programming… Hearing these words, programmers’ eyes begin to shine, breathing becomes shallow, hands are shaking and the brain is drawing multiple levels of abstraction… Managers’ eyes become wide, sounds become inarticulate, fists are clenched, and the voice switches to overtones. The only thing that unites these two groups of people is a rapid pulse. However, there are different reasons. While programmers are eager for the fight, managers are trying to look into the crystal ball and realize the risks, frantically trying to come up with reasons to extend the deadlines as mush as they can.
4,788

A Little E-Book: Learn from Real Examples How to Avoid Bugs

Here is a small e-Book for your attention: The Ultimate Question of Programming, Refactoring, and Everything. This book is intended for C/C++ programmers, but it could be of interest for developers using other languages as well. What makes the book peculiar is the descriptions of real, not theoretical cases at the base of it. Each chapter starts with a code fragment taken from a real application, and then the author gives various tips of how this bug could be avoided.
1,567

Celebrating 30th Anniversary of The First C++ Compiler: Let's Find Bugs in It

This article was originally published at viva64.com. Republished by the authors’ permission. Cfront is a C++ compiler which came into existence in 1983 and was developed by Bjarne Stroustrup. At that time it was known as «C with Classes». Cfront had a complete parser, symbol tables, and built a tree for each class, function, etc. Cfront was based on CPre. Cfront defined the language until circa 1990. Many of the obscure corner cases in C++ are related to the Cfront implementation limitations.
17,036

Lock-Free Data Structures. Exploring Queues

It was long ago since the last time we talked about lock free containers. I was planning to quickly write another article about queues, but there was one problem. I knew what I wanted to write about, but I had no implementation of those methods in C++. It was wrong to write about something I did not try out myself. That’s how I tried to implement new queue algorithms in libcds.
5,578

The Sunset of C and C++

Because not only CPU cycles count, but also developers’ time There are approximately 4 million C and C++ programmers in the world, probably the largest community, with about 20% of the market, which is comparable or even larger than Java (both C and C++ together). They are also by far the oldest languages of the current mainstream ones, used in key industries and even increasingly due to synergies with other fields as the IoT/embedded systems or robotics, in which these languages are important.
5,104

PVS-Studio for Visual C++

Many of our articles are concentrated on anything but the PVS-Studio analyzer itself. We tell our readers about projects we have checked, nuances of C++ language, creation of plugins in C#, running PVS-Studio from the command line… But PVS-Studio was first of all designed for Visual Studio users. We have done a lot to make their work with the tool as comfortable as possible. But this particular fact is very often left outside the frame.
3,549

A Non-Obvious Feature in the Syntax of Variable Declaration

Take a look at this innocent looking piece of code in C++. There are no templates, no virtual functions or inheritance, but the creators of this beautiful language hid a gift right in front of us. struct A { A (int i) {} }; struct B { B (A a) {} }; int main () { int i = 1; B b(A(i)); // (1) return 0; } Question: What is the type of variable b?
47,068

Lock-Free Data Structures. Yet Another Treatise

As you might have guessed, this article focuses on lock-free queues. Queues can be different. They can differ in the number of producers and consumers (single/multi producer — single/multi consumer, 4 variants). They can be bounded, on the basis of a pre-allocated buffer, and unbounded, on the basis of a list. They can either support priorities, or not. They can be lock-free, wait-free or lock-based, with the strict (fair) and not strict (unfair) conformance to FIFO, etc.
Show me more