Tuesday, September 13, 2011
I've been writing a course for Pluralsight that covers the fundamentals of C++ - types, expressions, basic syntax stuff, templates, pointers, polymorphism - and it has gone live
! During BUILD access to it is free. It uses Visual C++ Express, so you don't need to buy any tools to follow along. Lots of buzz at BUILD about C++, so if you want to see if it's a language you could use, here's a great way to find out.
I have more material coming on this, and some Windows 8 - specific material. This is just background. If you think you need to get up to speed on C++, here's how to do it. Let me know what you think.
Monday, August 29, 2011
For a long time now, whenever anyone asks me about support for particular C++0x (oh sorry C++11
) features in a given compiler, I've sent them to the list Scott Meyers maintains
. The format is kind of strange because it's exported from a spreadsheet, but the information is invaluable. If you'd like to see more compilers covered, try the wiki at apache
. Scott does gcc and Microsoft Visual C++; the wiki adds compilers from Intel, IBM, Oracle, and so on. You might be surprised to see the variations in coverage. Expect new versions to continue to add support as soon as possible.
Saturday, August 27, 2011
I was poking around on CodeProject looking at some developer interviews
(they've started these up again with some interesting subjects, so check the recent links) when I spotted An interview with Microsoft's new
Visual C++ .NET community liaison
- and in March 2002, nearly a decade ago, that was Herb Sutter. Isn't the Internet a handy attic? Check out some of these quotes:
I hope to make a noticeable mark in the product.
C++ continues to be relevant, dominant, and in widespread and still-growing
use. The C++ standard and standardization process also continues to be relevant [...] all the vendors, including
Microsoft, are there together actively working on the next-generation C++0x
standard whose work is now getting underway.
[...] the best numbers I keep seeing put the global
developer community at something like 9.5 million people, and those using C++ at
about 3 million of that. That's well ahead of Java in nearly all studies I've
seen, by the way, usually by a factor of 1.5-to-1 or 2-to-1. [...] The reports of C++'s demise have been, well,
C++ developers need power and know how to use it. I've always said you should
use the best language for the job, and I've used dozens of languages
professionally. Depending on how you count languages, I've probably used a dozen
professionally in the past year. People who want to write efficient, tight, fast
code often tend to choose C++ because it lets you get the job done with powerful
code but without sacrificing efficiency.
People who want mature, stable compilers and tools often tend to use C++
because it's been around a while and the tools and libraries are plentiful and
solid. Commercial client-side application development with more than a few
screens, most kinds of server-based software, and most kinds of libraries are
all done more often with C++ than with other languages, according to the best
numbers I've seen and according to my own experience as a developer and as a
consultant who shows up at other developers' shops.
Nine and a half years later, I see nothing but good stuff there. I hope all my interviews stand up as well (though I already know they wouldn't) and I'm impressed at the ability to set a goal and meet it. What will the next decade bring?
Thursday, August 25, 2011
The cone of silence that descended this summer is starting to fray a little. The Visual C++ Team Blog has an entry
talking about Productivity features in the IDE. They're willing to talk about:
- Semantic colorization - this is actually as much font face as it is colour, but anyway function parameters look different from locals, constants you #define'd look different from everything else, and so on.
- Reference Highlighting - you've seen this in other languages I'm sure - when the cursor is in a variable name, other places in the code with that same variable name are highlighted for you. It can be very helpful.
- Replacement Solution Explorer - I'm a huge Pro Power Tools fan, and if you've used Solution Navigator, you won't be surprised when you meet the new Solution Explorer. Combination Solution Explorer and Class View is the best way to explain it to a C++ developer.
- Aggressive IntelliSense - something else you may be familiar with from other languages. I like it.
- Snippets - oh, yeah!
Apparently there's still plenty more to come! Looking forward to it.
Tuesday, August 23, 2011
C++ is a great language for writing applications that will run on a number of platforms. There are compilers for many different platforms, and some powerful libraries you can use. Still, in the end your code needs to talk to the operating system, and that means that most cross platform applications have at least a few little corners where platform-specific code lives. The challenge is how to ensure that your Windows code runs on Windows, your Linux code runs on Linux, etc, without maintaining a number of different branches or hand-merging and splitting every time you deploy.
Being C++, an unspoken requirement in solving this problem is "be as fast as possible". Putting everything through a library and paying for extra indirection, looking up something that cannot change once the program has started executing, is not as fast as possible. You also want developer convenience and productivity. If you support five platforms, and something is the same on four and different on one, copying that code around for the four that are the same is not a productive way to behave. You would like a default behaviour, and then special code for special cases.
Michael Tedder has an intriguing approach using templates
. As he says:
Instead of declaring a base interface class with virtual
functions then deriving each platform with a different implementation, we
declare a class with one template parameter — a platform ID — then specialize it
to provide a different implementation for each platform. The template class is
typedef‘d to expose the specialization for the platform ID
being compiled to the application, allowing the implementation to be used
without any virtual functions and also allow for inlining of functions as
He has some pretty convincing armwaving about using this not for just Windows/Linux/Android but for any hardware differences even on the same operating system - like what kind of graphics architecture you have or anything else that can't change at runtime. It's a good example of how the power of templates makes things possible that would always incur a runtime cost in any other language, or a significant burden on a developer to move code around building custom versions of an application. Worth a read!
Sunday, August 21, 2011
Here's an interesting project I came across:
The game is Mastermind, which many people already know. What caught my attention is that it's done in C++ and XAML. To quote Tyler Whitney's blog post
The Mastermind code sample demonstrates how to create a simple Silverlight
storyboard in Expression Blend 3, and then provide the code for the state
transitions in Microsoft Visual Studio 2008. You can also see how to create
brushes programmatically and how to add a title bar to a Silverlight-based app.The code
is on the Microsoft Code Gallery (only Microsoft Employees can publish there) and Tyler has been updating the article over the summer. Nice way to see how to combine two technologies some people would never thought have combining.
Friday, August 19, 2011
I have talked about plenty of C++0x (soon to be known as C++11 or just plain C++) features over the last little while. Here's a nice summary by Danny Kalev
of the top features and why they matter. He covers lambdas, auto, the new ways to initialize instances (which hasn't been covered much elsewhere and contribute a lot to readability), suppressing default versions of functions (like constructors for example) or specifically requesting them (how cool is that?), nullptr (which I love because it eliminates a late night drinking argument about "what if someone #defined NULL to 3, would your code still work?", and rvalue references -- and those are just the language changes! His library coverage is super terse, but there are links in it if something (*cough* shared pointer *cough*) catches your attention.
There's no reason for a C++ developer to ignore C++11. This is big stuff, and reading these "what's new" lists from a variety of different people is essential for getting perspective on the changes. So read Danny's list!
Wednesday, August 17, 2011
Everyone knows that C++ is the language to use when speed matters. That's just a known fact. So here's a question: if you solved the same problem in both C++ and C#, using the generally available languages (the Standard Library for C++, the .NET Base Class Libraries for C#) and you didn't happen to know which parts of those libraries weren't implemented very efficiently, just wrote your apps -- which would come out faster and by how much?
Think you know? Of course, the answer is "it depends". Debug or Release builds? Laptop or handheld device? Whose implementation of the .NET Framework are you going to use - Microsoft or Mono? What chip are you running on? Oh, and to what extent are you deliberately setting C++ options that emphasize runtime speed? Also, did you choose an algorithm with a lot of generics or templates? C++ has a huge perf advantage there, but lots of benchmarks don't use generics or templates since they are solving one specific problem.An article on CodeProject
leapt into all of this feet-first and did some measuring. Along the way, "Qwertie" proved a universal rule of the internet: nothing will get you the answers you seek faster than posting the wrong answer. Want to know the exact date Bewitched switched Darrens? Find a place that discusses old TV shows and post your belief that there was only one, or that there were seven, or whatever, and people will correct you while the ads are still loading on their copies of the page. When Qwertie posted the first version of the benchmarking article, commenters were quick to say "but you made this mistake, and that mistake, and forgot this other thing" all of which led to a much better article.
Definitely worth a read. It gets you thinking about the things that truly affect performance. Absent-mindedly deploying a Debug build is going to cost you far more performance than your language choice ever will. Using a library in a performance-sensitive situation without understanding whether the library is high-performing or not will too. It's chock full of graphs like this one:
Don't read it to find out the answer to "is C++ faster than C#?" - we already know that. Read it to find out how to make your applications faster.
© Copyright 2022 Kate Gregory
Theme design by Bryan Bell
newtelligence dasBlog 2.3.9074.18820
| Page rendered at Tuesday, June 28, 2022 6:35:13 PM (Eastern Daylight Time, UTC-04:00)
On this page....
Pluralsight Free Trial