basics

Revisiting the BlackBerry 10 NDK

I've been looking at the BlackBerry 10 NDK the last weeks, and did write about it to share some thoughts and results.

Revisiting the BlackBerry 10 NDK

by Jens Weller

From the article:

The last few weeks I did look again at the BlackBerry 10 NDK, as a client had asked for help and training. I offered to adapt my Qt Introduction course to the BlackBerry plattform, and offered my advice...

Before I start, a short paragraph about Apps and C++. People coming from Java or .NET often don't understand the need to make Apps in C++...

A Glimpse into C++14: Combine Flexibility and Performance with Dynamic Arrays and... -- Danny Kalev

cpp14-target.jpgDanny Kalev wrote a nice article yesterday about a new C++ feature -- actually, two related C++14 features -- that were just added to the draft Standard in April and will be coming to real compilers in the near future.

A Glimpse into C++14: Combine Flexibility and Performance with Dynamic Arrays and Runtime-Sized Arrays

by Danny Kalev

From the article:

C99 introduced the notion of variable length arrays: stack allocated built-in arrays whose size is determined at runtime. C++ lacks a similar feature, to the discontent of many a programmer. However, two recent proposals for adding dynamic arrays and runtime-sized arrays to C++14 are closing the gap at last. Learn how to use these new features to imitate C99’s variable length arrays in C++...

GotW #7a Solution: Minimizing Compile-Time Dependencies, Part 1—Herb Sutter

The solution to the latest GotW problem is now available. In this Item, the focus is on analyzing and managing compile-time dependencies.

    GotW #7a Solution: Minimizing Compile-Time Dependencies, Part 1

    by Herb Sutter

From the article:

Managing dependencies well is an essential part of writing solid code. C++ supports two powerful methods of abstraction: object-oriented programming and generic programming. Both of these are fundamentally tools to help manage dependencies, and therefore manage complexity. It’s telling that all of the common OO/generic buzzwords—including encapsulation, polymorphism, and type independence—along with most design patterns, are really about describing ways to manage complexity within a software system by managing the code’s interdependencies.

When we talk about dependencies, we usually think of run-time dependencies like class interactions. In this Item, we will focus instead on how to analyze and manage compile-time dependencies. As a first step, try to identify (and root out) unnecessary headers.

Guideline: Never #include unnecessary header files.

Guideline: Prefer to #include <iosfwd> when a forward declaration of a stream will suffice.

Guideline: Never #include a header when a forward declaration will suffice.

Continue reading...

Overload 116 available

overload-116.PNGOverload 116 is now available. It contains the following articles, and more:

 

Overload 116

Auto -- A Necessary Evil? Part 2 -- Roger Orr

When is the use of auto good, and when is it evil?

Dynamic C++, Part 2 -- Alex Fabijanic

Alex Fabijanic and Richard Saunders continue to explore dynamic solutions in C++.

Portable String Literals in C++ -- Alf Steinbach

How hard can it be to make a file in C++ with international text literals in its name? Alf Steinbach shows us how to write a file called π.recipe.

Hard Upper Limit on Memory Latency -- Sergey Ignatchenko

How low can latency really get?

 

... and more!

An Important Move Optimization Is Nearly Invisible -- Andrew Koenig

Today in Dr. Dobb's:

An Important Move Optimization Is Nearly Invisible

by Andrew Koenig

From the article:

Last week, we looked at subtle differences between copying and moving a container (a string in this example) in the context of passing arguments to functions. Curiously, one of the biggest differences between copying and moving happens in code that we don't write. ...

The improvements in robustness and functionality that stem from moving instead of copying are, in my view, at least as important as the optimization. ...

GotW #94 Solution: AAA Style (Almost Always Auto) -- Herb Sutter

The solution to the latest GotW problem is now available:

GotW #94 Solution: AAA Style (Almost Always Auto)

by Herb Sutter

From the article:

4. When declaring a new local variable x, what advantages are there to declaring it using auto and one of the two following syntaxes:

(a) auto x = init; when you don’t need to commit to a specific type? (Note: The expression init might include calling a helper that performs partial type adjustment, such as as_signed, while still not committing to a specific type.)

(b) auto x = type{ init }; when you do want to commit to a specific type by naming a type?

Why Would You Ever Pass a Container By Value? -- Andrew Koenig

From the desk of ARK:

Why Would You Ever Pass a Container By Value?

by Andrew Koenig

From the article:

Consider two fundamental features of C++: functions and references. Which shall we teach first?

If we teach references first, there is the problem of coming up with interesting example programs that use references but completely avoid user-defined functions. This is hard to do because the most common use of references is as function parameters — so it's probably easier to teach functions first.

However, if we teach functions before we teach references, then every function we write must accept its arguments by value — references not yet being available as an alternative...