C++ Programming

Millennials Are Killing The Modules TS

In my previous post, I mentioned that I have serious issues with the current Modules TS as it is written. I have wanted to say more on the subject since my tweets, posts, and general comments are missing quite a bit of context for why I think the implementation is wrong, and will be more trouble than they are worth.

Part of this is due to what the community (as found on /r/cpp, and other subreddits) seem to think modules are and how they work, how some members on the committee would like modules to work, and the reality of how modules actually work. None of these understandings are the same, and they barely even overlap.

From what I understand, there will be a competing modules proposal from several Clang developers that tries to solve some of these issues. However, we will not see this until January/February and the upcoming vote to turn the modules proposal into a full fledged technical specification is coming up in November. Something needs to be done.

Read more »

CppCon 2017 Trip Report

It's been a few days since I got back from CppCon 2017. As a millenial, I easily cave to peer pressure and because everybody else is doing it, I figured I might as well write a trip report too.

This was my third CppCon, and now that several attendees recognize my face, they no longer feel threatened and break eye contact when I ask them where I can score some weed. As C++ improves as a language, I'm pleased to see that the community grows with it. I was able to meet and chill with a variety of people whose work I respect at both the conference and in unrecorded discussions. I'm definitely of the opinion that CppCon inspires collaborative work and important discussions about the future and direction of the language, tooling, and community.

I'll be mentioning the content of some of these discussions because I am a vapid diva looking for attention now that I'm on a platform where I've thrown off the shackles of Twitter's character limits. More importantly, as the conference continued and I spoke with various people, I came to the conclusion that the Modules TS needs more scrutiny and is in dire need of fixing, or we're all going to regret it.

Read more »

Implementing Concepts in C++14

I haven't posted in quite some time. For now, I want to show some cool stuff.

CppCon 2016 just ended. I had a wonderful time at the conference this year. There were some very interesting talks and panels (which I recommend you watch on YouTube, once they are uploaded). The ones that stood out to me were the coroutines talks. I also got to participate in SG14 and I started writing my first proposal for an intrusive smart pointer, which will hopefully be sent in before the Issaquah mailing deadline. There was quite a bit of interest from SG14, as well as Gor Nishanov from Microsoft. On Wednesday night, I decided to ask if there was a slot left for a thursday lightning talk and I was able to get myself squeezed in. The talk was originally titled No Concepts Beyond This Point, but I later wanted to call it Sic Semper SFINAE. Effectively, I showed a brief example on how to implement concepts (at least, the compile time interface constraints) in C++14. I ran out of time, however, so I decided to write this post to explain it a bit better and to show it off. It's not perfect; Extra work is required for placeholder types (assuming it is even possible). However, in today's post I'll be showing you how to implement them yourself. I'll be using the code I wrote before my lightning talk as a base. I only had 5 minutes to explain everything in my talk, so I'll be able to go into more depth and explain show it working.

Read more »

An Attempt to Explain Monads in C++

Last time, I spoke about some potential continuations that someone can do in C++ with optional types. I briefly stated, in regards to the Boost.Expected proposal:

This is all well and good, however I noticed that these choice of words 'map' or 'bind' aren't what I think when reading.

Someone pointed out to me that the 'map' call comes from one of the three operations one can perform on a monad. The other two being 'join', and 'return'. After digging into the Boost.Expected proposal some more, I finally had that epiphany where one understands what a monad is. As such, I want to keep with the time honored tradition of trying to explain it to others, and continuing to confound the congregation of programmers who haven't yet grokked it. However, I'll explain it in the context of C++, rather than trying to explain Haskell, and how some of its features map to C++. And while burritos are delicious, I won't be referencing them at all.

Read more »

Optional Types and Lightweight Continuation Passing in C++

MNMLSTC Core is starting to near its 1.2 release target, and this will most likely be the last version that targets C++11 and may be the last non-bugfix release for the 1.x series. There are many reasons for this, but the primary one is the difficulty that exists in implementing C++17 proposals without C++14 language features. Before I move on to begin work on 2.0, I'm going to add be adding several extensions to the proposals that Core alrady implements. Specifically, I'll be adding extensions to the optional types. As of right now, the match member function that is provided for core::variant<Ts...> is now available for all the optional types that Core provides (optional<T>, expected<T>, and result<T>). However, this post is about a different feature that I'll be adding and it may be one that doesn't exist beyond the 1.x series. Please note that this post makes extensive use of C++14 library features that are implemented in MNMLSTC Core, as well as the extensions MNMLSTC Core provides (namely result<T>). In addition, the code contained within is not 100% correct, and should be approached as though it were pseudo code.

Read more »

C++ Needs Better I/O Facilities

C++ is not well liked by a large number of non-C++ programmers. One of the arguments that has stood the test of time against C++ is the streams library. It's even a point of contention within the C++ community. The main arguments against the entire streams library are usually:

  • Overloading operator <<
  • Performance
  • 'God Objects'

We're going to ignore that first bullet point, however, because it is entirely opinionated. Developers can argue about overloading operators and what should and should not be overloaded all day (and they usually do).

Read more »

RValue Reference Implications In C++11

There are several implications that one has to realize when it comes to using rvalue references in C++11 APIs. For starters, requiring an rvalue reference as a parameter to a function implies the following:

  • The object being passed in may be mutated
  • The object being passed in may exist until program exit
  • You (the caller) no longer own the object being passed in

This is fairly large in terms of writing an API. In days of yore, before the existence of rvalues and move semantics, one might have used a pointer, or non-const reference to designate that an object would be mutated. They may have gone a step further and passed the object in by value to show that a deep copy would be made as the object passed in was no longer your concern. But none of these implied one very important feature that C++ technically lacks.

Read more »