CPPCON2020 Session Review: Back to Basics: Class Layout

There are two types of knowledge: timely and timeless.

Knowing how your types are laid out onto physical hardware is programmer’s gold and it is timeless knowledge. It never leaves you. I would recommend strongly this talk if you work closer to the metal, or if you work with code bases that make use of object-oriented programming–and before you say that OOP is dead, consider digging (and I mean digging) into RocksDB, TensorFlow, and so many other successful open-source pieces of code where you’ll see how layout is important and the amount of OOP code in them.

I enjoyed this refresher on class layout by Stephen Dewhurst, and was pleased to see the use of no_unique_address attribute and the has_unique_object_representations type trait mentioned in the talk (and of course, you can find them in Spanish, no_unique_address and has_unique_object_representations)

But then again, I’m biased. I took a class with Stephen back in 2003 (and the other instructors were Dan Saks, Scott Meyers, Andrei Alexandrescu and Herb Sutter). Stephen has had a lot to do with the success of C++, but in particular, by being an educator and an evangelist.

I used to own his book Programming in C++, and still own C++ Common Knowledge, which I consult when relevant.

Last year, in CPPCON2019, I had a chance to talk to him and catch up. If you see him in a future CPPCON hanging out in the halls after a class or session, stop and say hi. He’s still the same easy going guy.

Posted in C++, C++17, C++20, programming languages, software | Tagged , , , , , , , , , | Leave a comment

CPPCON2020 Session Review: The Future of C++ Parallel and Concurrency Safety Guidelines

“I test, therefore I exist.”

Paraphrasing René Descartes, what do you do if you’ve been conditioned from your engineering “birth” to test, and test everything.

This session is a fit for you if you program systems that require safety as one of its most important features (think 911 Public Safety, Avionics, Automotive), if not the most important. Additionally, if you’ve worked on a company that has a development process compliant with ISO 9001, then this session is for you, too.

Having worked for two companies that implemented ISO 900x, I’m very familiar with the intricacies that are needed to implement even simple changes. Often times the issue is not the change, but what it triggers (e.g., a system recertification, or an infinite number of tests; in other words, change is expensive). On the other hand, I’m grateful that such standards exist and that companies follow it.

Michael Wong starts the session with testing this type of systems for parallel/concurrent/manycore/multicore/{add your term here} systems. How do you do it? Well, it’s a tough question to answer.

So, now that we’re trusting our lives to compute systems controlling our cars, planes and toasters, wouldn’t you want to know that such systems have been tested exhaustively and meet standards for safety? Me too.

Enter SIL (Safety Integrity Level), “bins for levels of safety based on effects if the fault is not mitigated”. Reminds me of the Titanic blueprints shown in the movie that water would spill into another level, and another, until it would become “uncontrollable”

Meet MISRA, too, a suite of software required guidelines that you can apply to C++ to develop systems that are SAFE to use.

The slide on Unintended Acceleration brought bad, related memories: we have a Nissan Armada that one good day my wife said it would not stop after she stepped on the brakes. Being the engineer, I said that most likely it was the ABS and there’s no need to step on the brakes repeatedly…until it happened to me, on the freeway. Sure enough, the problem was firmware and there was a recall. Researching on the Internet, I learned of other drivers that had had an accident due to that error (calling it a bug is very nice).

Michael starts with the C++ Core Guidelines, identifying a gap in the rules that have to do with concurrency. Quickly he moves on to rulesets/standards that make more sense–Joint Strike Fighter Air Vehicle C++, MISRA, Autosar.

Ilya takes care of the second part of the session, and he shared the document that they’re working on. That got me doubly interested.

In the past I’ve worked in what I consider large designs using UML, and making use of use cases, business rules, and so on. Having the formality of writing this type of guideline is a lot of work, and I appreciate that effort by Mike and Ilya and all that are involved, whether it is in providing feedback, the definitions and the implementations to detect whether the rules are correctly applied or broken when writing real software.

What I liked about this session is that it is for software that will be running for quite a few years–say, a decade? two decades? You’d be surprised the longevity that your written code may have. I have been, and I wish these types of guides and standards were around at the time.

A virtual “tip my hat” to Michael and Ilya.

Posted in C++, C++17, concurrent programming, software, software architecture | Tagged , , , , , | Leave a comment

CPPCON2020 Session Review: The Hidden Secrets of Move Semantics

I “virtually” attended this session and followed it fully, and went through it again to write this short session review. But then, I’m biased. I have been reading C++ Move Semantics – The Complete Guide, since Nico started publishing the first chapters, and recently posted a minor review for the book. Furthermore, I translated his best-seller, C++17 – The Complete Guide, to Spanish.

Therefore, I was very familiar with the material, and yet, enjoyed the session very much. A cursory review of move semantics–or better, get a copy of his book–will let you derive the most value from this session.

Nico picks up a simple class template where all you want to do is insert elements. Sure. Then he starts peeling away the different ways in which move semantics comes into the picture, what to use, what to avoid, and a number of do’s and don’ts at the end of the session. If you want to learn what the term temploid means, check this out. If you want to overload by a reference qualifier, check this out.

Still controversial for some is the use of universal reference, which I guess is one of those terms that we’ll get stuck with and generate polemic conversations when compared with forwarding reference. Consider the translation of email in some languages (courrier électronique, courriel, correo electrónico). Nah, simply say email. Same here. Unless you want to pick up another polemic term.

You can check forwarding references in cppreference or in Spanish in es.cppreference.

By publishing professional C++ books, Nico is an educator, and do we need more of those. So, if you’re wondering if it will be time well spent should you choose to watch it? You bet.

Posted in C++, C++17, C++20 | Tagged , , , , , | Leave a comment

CPPCON2020 Session Review: Collaborative Development with Visual Studio Code

Julia Reid walks through three main topics in this entertaining session about Visual Studio Code: the Visual Studio Code, CMake and vcpkg trifecta, remote development, including containers, and collaboration using LiveShare.

I did a review on a different session last year (link at the end of this post), and it’s great to see that VSC and CMake enjoy such a close collaboration, and vcpkg gaining ground as a package manager. All is welcome.

If you do remote development, particularly on headless, remote machines, this talk is for you. I’ve been using this feature over the last year and have been really happy–allows me to have a central dev machine and connect to multiple servers at once. Furthermore, this session tackles developing from containers, which I’ll definitely revisit. Oh, and also port forwarding!

Julia also covers pair programming à la mode; that is, virtual. I’ve used this feature once, and mostly to make sure it worked. But, if it floats your boat, go ahead.

What I liked about this session is that Julia peels away the complexity in setting up a development environment using Visual Studio Code that is complete, and covers every aspect of the development cycle, from setting up, compiling, building, debugging, and yes, SCM. As a side note, have you noticed that Compiler Explorer now seems to be using VSC under the hood? Couldn’t help but notice that the Find dialogs look exactly the same. Oh, well.

The C++ extension is now 1.0. Wow, it’s been some time in the making–four years, per the talk, but will check it out. It comes with support for Linux on ARM/ARM64, VC code formatting, and an extension pack, packed with goodies. Oh, and support for Doxygen comments. Will pick them up and show them. Nifty.

Sneak Peek: UI for vcpkg.

Ready to jump in? Enjoy the session.

Tara Raj did this session last year:

Posted in C++, C++17, C++20, programming languages, software | Tagged , , , , , , , | Leave a comment

CPPCON2020 Session Review: Back To Basics: The Structure of a Program

If you think that a “header-only” library is where you dump all of your code in a header file, this talk is for you.

Joke aside, this talk is at a level that I can give it to my daughter and she’ll get a big chunk of it. After all, it’s a Back to Basics, right?

Bob Steagall will walk you through the anatomy of a C++ program, explaining each of the parts. If you want to make sense of it all, check out this talk. You can also check Bob’s Blog.

Differentiate between source code tools, build tools, libraries, compilers, linkers, and so on. Do you want to know what a translation unit is? How many phases of translation are there? Do you program for Linux? Windows? macOS? Check this out. The talk is OS agnostic. Declarations and definitions? Linkage–external, internal, no linkage? Again, check this out. Furthermore, learn about the One Definition Rule (you could call it the Highlander rule–there can only be one), storage duration–automatic, dynamic, static, thread, and the mysterious ABI, name mangling.

Moreover, if you want to deepen your understanding , you can find additional documentation about the C++ language in bite-sized chunks of text with examples on cppreference, or in Spanish on es.cppreference.

Binge away and enjoy the session.

Posted in C++, C++17, C++20, programming languages, software | Tagged , , , | Leave a comment

CPPCON2020 Session Review: Back to Basics: The Abstract Machine

If you’ve been flirting with C++, and are past the customary “Hello, world!” program, have been programming for a few months, but want to commit to a serious relationship, then this talk is for you.

Bob Steagall masterfully walks you through the C++ abstract machine, and take you to the dance between the programmer, the compiler, the abstract machine, the machine code and the physical (or in today’s world, virtual) machine. You can also check Bob’s Blog.

This post from last year caught my eye:
Programming language popularity: C++ bounces back at Python’s expense

Now, C++ and Python are different tools for different problems, and I see them as complementary–just check TensorFlow, which harmonizes both languages beautifully. The key point is that C++ usage is growing. If you want to be part of this growth, check this talk.

Bob starts with the language goals, and focuses on performance-critical software, and no room for a lower level language, and no, this is not a conspiracy to “dislodge” C. How does C++ meet such goals? Well, dig in and learn about the abstract machine

You will learn about the differences between programmer’s concerns vs. the compiler’s concerns, expressions, definitions of what an abstract machine for C++ is, its parametrization, what a well-formed program is, and so on. Bob covers nondeterminism, implementation-defined behavior, unspecified behavior, undefined behavior (the dreaded UB, and nope, it’s not Ultra Biolet, where Biolet is a not a biological product, and…but I digress).

So, if you’re serious about your relationship with C++, or simply want to review the basics, I invite you to check this talk. Since none of us like reading standardese (well, some do), you can find additional documentation about the C++ language in bite-sized chunks of text with examples on cppreference, or in Spanish on es.cppreference. A parting quote from Bob’s talk:

When we write C++ code, we are writing to the C++ abstract machine

Thus Spoke Bob Steagall.

Posted in C++, C++17, C++20, programming languages, software | Tagged , , , , | Leave a comment

CPPCON2020 Session Review: Template Metaprogramming Type Traits (Part 1 and Part 2)

I attended this pair of sessions by Jody Hagins, and then went back and watched them again at unholy hours in the morning.

Note: As an attendee, I can munch on the sessions before they’re officially posted on the YouTube CPPCON Channel, in case you’re wondering why you can’t access them Once they’re availlable, munch away!.

These sessions are easy going, with a ping back to Walter Brown’s “seminal” pair of corresponding talks, Modern Template Metaprogramming: A Compendium: Part I and Modern Template Metaprogramming: A Compendium: Part II, both given during CPPCON2014 and at the end of this post for your enjoyment. If you have half a day to spend munching on metaprogramming, this set of four talks should get you going on the road to master template metaprogramming, grasshopper.

Before you start munching, you can find the Type Traits referred in these talks in cppreference, or, if you prefer Spanish, you can find them in es.cppreference,

Holy Cow, the Book of Coplien!

Couldn’t help but smile when Jody pulled out a copy of the “Purple Book” of Advanced C++. That’s where I learned the word “functor”. Used to keep a copy–along with a copy of the C++ ARM (when ARM was an acronym for Annotated Reference Manual) but alas, both have been lost in time.

With the homage to Coplien and Boost Type Traits, pioneers and base for what we now see in C++ type traits, correspondingly, Jody digs in.

Part 1

In short, the first session , convention for type traits that yield a ::value, that yield a ::type, value metafunctions (those using a _v suffix), type metafunctions (those using a _t suffix; Jody peels away the mystery of std::integral_constant and ventures into the is_void as an example on how to remove cv-qualifiers.

Part 2

Part 2 picks up with a review of the different categories of type traits (primary, composite type, type properties, etc.). Template specialization will be used abundantly, so be ready. A cursory review will help.

Now, in case you wondered, SFINAE is not a cursing word in Spanish–or any other language for that matter, but, along with CRTP, and RAII, it’s one of those acronyms that once you’ve spent time in C++, you’ll learn by heart.

How About those Other Talks?

Walter Brown’s Talks can be found here:

Posted in software | Tagged , , , , , , | Leave a comment

Boutique C++

This year I’ve enjoyed two excellent C++ books: C++ Move Semantics – The Complete Guide, by Nico Josuttis, and C++ Lambda Story, by Bartłomiej Filipek, both members of the C++ Standards Committee.

Updated on September 9, 2020
For a printed copy on Amazon, USA, click the following link: C++ Move Semantics – The Complete Guide

After reading each of the books–and like pulp fiction novels, were written in installments–I had this feeling of having enjoyed the books very much, and learned so much in the process, and kept wondering why that was.

The reason, as I describe it, is a boutique approach to writing. That is, focus on one topic, and exhaust the topic to the end. I live in an area in Southern California rich in vineyards, and it is common to find boutique wineries that specialize in one specific kind of grape or wine, and couldn’t help but compare the approach that both Nico and Bartek have taken.

Sure, who hasn’t heard or learned about move semantics, with the original proposal here–and initial attempts with Andrei Alexandrescu’s Mojo library way back when. I go back to a white paper/blog post by Stephan T. Lavavej many, many moons ago, or the sessions about lambdas by Herb Sutter in the Microsoft Build conferences, and of course, paying homage to Scott Meyers Effective Modern C++ and universal references.

One problem, as I see it, is that often times you don’t have time to keep up with the new and evolving language features. Living in a polyglot world, you have to pick up different tools for the job, from C++ to Python to Java to Go to TypeScript to…you get the idea. Furthermore, although new features are great, by the time you get to them, well, a new Standard is out. I bet that the next CPPCON will be talking about C++23. Just get that feeling.

If you’re like me, you read maybe a couple of books during a given year–and I mean read, as in end to end. The challenge that I have is always the time available for such activity. Alas, there’s a family to attend to, and weekends I own the kitchen. So, what do you pick? I like the King Kong size references that I trust and I can always go back to, munching on them a little at a time, but I found myself going back to these books for more. The reason? They’re filled with details, examples that you can whip up in a few seconds or in a few minutes, and quality material. It is easier on the author, too, because she/he can concentrate on a specific topic.

So saying that, and hoping to encourage more authors, if I had my druthers, I’d like to see a boutique book on:

  • Concepts (and type traits in the process)
  • Coroutines

Any takers?

And yes, se habla C++.

Posted in software | Tagged , , , , | 3 Comments

HOME: Habitations and Observations for Moon Exploration

How would you go about developing a habitat for five people to survive six months on the Moon?

You may be familiar with Artemis, whose goal is to “land the first woman and the next man on the Moon by 2024, using innovative technologies to explore more of the lunar surface than ever before”.

These past weeks I’ve been following the progress of a team of summer interns for NASA, our daughter being one of the members, as they designed such a system. Alas, it will come to an end after they present their design in a couple of days

NASA provided two outstanding mentors, as well as resources, interviews, and challenged the interns to come up with fresh ideas. One of the presenters was Jerry Woodfill, who has been working for NASA for over 50 years and had an entertaining and eye opening session explaining all the things that went wrong and right with the Apollo 13 mission.

It has been such a joy to see how the team coalesced and converged on a design after many weeks of work, and it gives you an idea of what a multi-discipline team can do.

So, if you enjoy a focused presentation and pushing the next generation of engineers, go ahead and check their presentation on YouTube.

Luna, luna,
dame una tuna,
la que me diste
cayó en la laguna.

–Rima popular

Posted in software | Tagged , , , | Leave a comment

The Whole Enchilada: A C++ Template Recipe

Tortilla press / Prensa para tortillas

Most likely you’ve had enchiladas, but have you ever heard of entomatadas? They’re a great alternative for those that don’t like “fire in the belly” during/post eating enchiladas and they follow the same process, except that instead of chili you use fresh tomatoes.

The secret to a good plate of enchiladas/entomatadas is in the sauce. While at home we use home-made corn tortillas, you’ll be just fine with regular corn tortillas. If you leave nearby a Mexican food market (such as Cardenas in Southern California), or a corn-tortilla factory, the tortillas will be of better quality. Just saying.

The following are two recipes that you can enjoy at home without spending too much or going out. Accompany with Mexican rice and refried beans (recipes not included).

And of course, there’s some C++ involved.



  1. Two bags of dry Anaheim or Pasilla red-chili peppers with approx. 10 chili pods will give you a good 10 enchiladas
    Make sure they’re not the skinny chilis (chile del árbol), those are very, very hot. You’ll thank me.
  2. Cheese to you heart’s content.
    Monterey, cheddar/monterey mixed, queso fresco, grated cheese
  3. Olive oil or any oil of your preference. As you may have heard in a movie, “olive oil caresses your insides, leaving nothing but its essence.”
  4. A teaspoon of flour
    The flour will be used to cook the chili sauce and help it thicken. Don’t use corn starch.


  1. Grate the cheese, set it aside.
  2. Trim the stem of the chili pods, take out the seeds by simply shaking the chilis and wash them.
    Sometimes chilis have some dust on them.
  3. Soak the chilis in warm water for approximately 1 hour
    This softens the inside of the chili and it let’s out its “meat”.
  4. Blend the chili in a blender with a little bit of the water used to soak the chilis.
    Make sure you don’t use too much water in the blender, otherwise you will end up with watery sauce. You’ll have to guess how much water to use, but it’s best to start with a little bit.
  5. Strain the sauce in the blender with a fine strainer. Place the strained sauce in a container.
    If you don’t use a fine strainer, you may end up with chili husk in the sauce.
    Press the chili in the strainer with a spoon to get as much sauce as possible.
    If there is still sauce that can be extracted, return the chili husks to the blender, add a bit of water to the blender, and repeat the previous step, then strain again.
  6. Heat a teaspoon of oil in a sauce pan to medium heat. Then add a teaspoon of flour and cook it until it’s light brown. Add the enchilada sauce and cook in low heat until it comes to a boil, then set aside.
    The sauce pan has to be large enough where for you to soak a corn tortilla through the pan.
  7. Add oil to a skillet or pan where you can fry the corn tortillas.
    You need to have enough oil to deep-fry a few corn tortillas.
  8. Fry the tortilla (15-20 seconds per side)
    Make sure it’s neither too soft nor too hard. If it’s too soft, it’ll come apart in the sauce pan. If it’s too hard, you can “soften” it by leaving it some extra time in the sauce pan or reheating in the microwave once it goes through the sauce.
  9. Extract the tortilla and soak it in the sauce.
  10. Place in a large plate and add cheese on top.
  11. Repeat from step 8.

Enchiladas Montadas

You may have heard of enchiladas montadas. It’s basically a topping of your choice. Typical choices are an over-easy egg (huevo estrellado) or tuna with lemon/lime juice and tiny bit of salt.

Simply top your stack of enchiladas with one of those toppings.



  1. 4-6 fresh, medium steak tomatoes will give you a good 10-12 entomatadas.
  2. A small can (1 cup) of tomato sauce for color and thickness.
    Make sure it’s not tomato paste.
  3. Cheese to you heart’s content.
  4. Olive oil or any oil of your preference.
  5. A teaspoon of flour
    The flour will be used to cook the chili sauce and help it thicken. Don’t use corn starch.


  1. Grate the cheese, set it aside.
  2. Boil the tomatoes until they’re soft. Usually a few minutes after they come to a boil.
    Don’t wait until they come apart from over-boiling.
  3. Peel the tomatoes and blend them with a little bit of salt.
    Unlike the enchiladas recipe, you don’t need to add water. Tomatoes are already watery.
  4. Heat a teaspoon of oil in a sauce pan to medium heat. Then add a teaspoon of flour and cook it until it’s light brown. Add the sauce in the blender and the tomato sauce and cook in low heat until it comes to a boil, then set aside.
    The sauce pan has to be large enough where for you to soak a corn tortilla through the pan.
  5. Add oil to a skillet or pan where you can fry the corn tortillas.
    You need to have enough oil to deep-fry a few corn tortillas.
  6. Fry the tortilla (15-20 seconds per side)
    Make sure it’s neither too soft nor too hard. If it’s too soft, it’ll come apart in the sauce pan. If it’s too hard, you can “soften” it by leaving it some extra time in the sauce pan or reheating in the microwave once it goes through the sauce.
  7. Extract the tortilla and soak it in the sauce.
  8. Place in a large plate and add cheese on top.
  9. Repeat from step 6.


If you like your entomatadas spicy, just boil one or two jalapeño chilis along with the tomatoes and blend them together. Furthermore, you can also have entomatadas montadas by adding the toppings mentioned above.

Given the ingredients and procedure, it is evident that once you’re done with the sauce, the procedure is the same. Let’s add a function template for the algorithm to cook the enchiladas/entomatadas:

#include <chrono>
#include <stack>

// T is either chili or tomatoe. No time to use enable_if
template<typename T, typename Oil, typename Cheese>
std::stack<T> make_it(std::stack<corn_tortilla> tortillas, Sauce<T> sauce, Oil oil, Cheese ch) {
  static_assert(cheese.is_grated(), "Grate the cheese, por favor!");
  std::stack<corn_tortilla> plate;

  stove s{}; // generic stove

  // Sauce and oil act on objects imbued (stove, pan),
  // that way we can refer to "heat the oil"
  sauce.heat(heat_level::none); // turn off the heat


  while (!tortillas.empty()) {
    tortilla = tortillas.top();

    using namespace std::chrono_literals;
    tortilla.fry(oil, 15s);
    tortilla.fry(oil, 15s);
    sauce.soak(tortilla, 10s);
    plate.push(tortilla);     // move the enchilada/entomatada to the stack
    add_cheese(tortilla, ch); // implementation-defined
} // Oil object will call heat(heat_level::none) in the dtor.

Enjoy. Stay safe. Stay healthy.

Posted in software | Tagged , , | Leave a comment