News

CppCon 2014 0xBADC0DE--Jens Weller

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

0xBADC0DE

by Jens Weller

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

My motivation for this talk is my own expierence as a freelancer and trainer. I have seen a lot of good and bad code in different places. As a freelancer I often had to deal with different, unknown and often large codebases. This talk tries not only to show examples of bad code, but also to analyze why it exists in the first place, and how to deal with it or fix it. I'll visit anti-patterns, but this talk is not about anti-patterns, as that would only spotlight one of the many problems.

CLion 1.0, cross-platform C/C++ IDE, has finally arrived

CLion 1.0 is out.

JetBrains has finally released CLion - cross-platform IDE for C and C++ developers

By Anastasia Kazakova

From the article:

CLion is a full-featured IDE for developing in C and C++ on Linux, OS X or Windows. It's deeply integrated with the well-known CMake build system and GDB debugger, as well as with many popular Version Control Systems. CLion provides productivity boosting features, including smart editor, one-click navigation, reliable refactorings and on-the-fly code analysis with quick-fixes, to keep your C/C++ code high-quality.

C++11 is the second "most loved" language/technology on StackOverflow according to the survey

In case you missed it, an interesting data point about how much programmers appreciate the improvements in C++11 (and 14) compared to C++98. As Stroustrup frequently says, C++11 feel like a new language. Note “love” means in the sense of “enjoy programming in”… more people are willing to say they enjoy programming in modern C++, and C++11 truly was a turning point and progress is continuing:

C++11 is the second "most loved" language/technology on StackOverflow according to the survey

Quick Q: Can I do something like range-for with a counting loop?

Quick A: Yes. Start with boost::irange.

Recently on SO:

Can I do something like range-for with a counting loop?

Actually this are two related questions.

I know there is new syntax in C++11 for range based for loops of the form:

//v is some container
for(auto &i: v){
   // do something with i
}

First question: how can I infer at which iteration I am in this loop? (Say I want to fill a vector with value j at position j).

Second question: I wanted to now if there also is some other way to write a loop of the form

for(int i=0; i<100; i++){ ... }

I find this way of writing it a bit cumbersome and I do this so often and I would love to have a more concise syntax for it. Something along the lines:

for(i in [0..99]){ ... }

would be great.

For both questions I would like to avoid having to use additional libraries.

Quick Q: How is “=default” different from “{}” for default constructor and destructor?

Quick A: The "= default" keeps the type trivial.

Recently on SO:

How is “=default” different from “{}” for default constructor and destructor?

I originally posted this as a question only about destructors, but now I'm adding consideration of the default constructor. Here's the original question:

If I want to give my class a destructor that is virtual, but is otherwise the same as what the compiler would generate, I can use =default:

class Widget {
public:
   virtual ~Widget() = default;
};

But it seems that I can get the same effect with less typing using an empty definition:

class Widget {
public:
   virtual ~Widget() {}
};

Is there any way in which these two definitions behave differently?

Based on the replies posted for this question, the situation for the default constructor seems similar. Given that there is almost no difference in meaning between "=default" and "{}" for destructors, is there similarly almost no difference in meaning between these options for default constructors? That is, assuming I want to create a type where the objects of that type will be both created and destroyed, why would I want to say

Widget() = default;

instead of

Widget() {}

?

I apologize if extending this question after its original posting is violating some SO rules. Posting an almost-identical question for default constructors struck me as the less desirable option.

Boost.Spirit + Flatbuffers + Catch + Biicode + CLion + Github--Max Galkin

Come see a nice product review:

Boost.Spirit + Flatbuffers + Catch + Biicode + CLion + Github

by Max Galkin

From the article:

This weekend I’m test-driving several new technologies. OK, OK, maybe not so new for everyone else, but new for me. I’m trying to write a parser for the Flatbuffers IDL grammar using Boost.Spirit, I’m referencing Boost using Biicode, I’m testing the code using Catch, I’m editing the project in CLion, and I’m pushing the results to Github yacoder/flatbuffers-with-spirit!

Oral History of Bjarne Stroustrup

Oral History of Bjarne Stroustrup

About the interview:

In a substantial interview with Paul McJones, Bjarne Stroustrup discusses his youth, his education at the Aarhus University and the University of Cambridge, and his career at AT&T Bell Laboratories, Texas A&M University, and Morgan Stanley. Also covered are his early experience with a variety of programming languages including Simula and BCPL. Finally, the interview focuses on his work on C++ and its predecessor C with Classes, including his goal of combining good abstraction mechanisms with direct access to the hardware. Specific language features discussed include value semantics, templates, concepts, the Standard Template Library, and highlights of the C++11 and C++14 standards.

CppCon 2014 Pragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern--Zach Laine

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Pragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern

by Zach Laine

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

There are numerous, serious OOP design problems that we have all encountered in production code. These include, among others: - object lifetime/ownership - how to make classes from different class hierarchies conform to a common interface - writing classes that can present multiple interfaces - separating interface and implementation - how to write virtual functions so that subclasses override them properly - the virtual inheritance "diamond of death"

Proper use of type erasure can mitigate, or outright eliminate, these and other problems, without sacrificing performance.

This talk will cover the OOP design problems above and more, and will cover hand-rolled and library-based type erasure approaches that solve those problems. Performance metrics will be provided for the different approaches, and source code will be available after the talk.

CppCon 2014 Embind and Emscripten: Blending C++11, JavaScript, and the Web Browser--Chad Austin

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Embind and Emscripten: Blending C++11, JavaScript, and the Web Browser

by Chad Austin

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Emscripten compiles C or C++ source code into JavaScript so it can run in a web browser. Emscripten is commonly used to port games to the web with no download or plugin required.

Embind is a C++11 binding library that makes it easy to expose libraries written in C++ to JavaScript. This allows JavaScript applications to take advantage of existing bodies of C++ code. In addition, C++ compiled into the asm.js subset of JavaScript is often faster than hand-written JavaScript, so Embind makes it convenient to accelerate JavaScript applications by writing high-performance functionality in C++.

With several motivating examples, this lecture will cover the design of embind, how variadic templates and constexpr facilitate interesting optimizations, and how embind minimizes its impact on the size of the generated JavaScript.