Tech-Ed Barcelona 2007: Day 4

Yesterday evening I went to the local shopping mall to buy a present for my daughters. I had promised it, and I have to make sure that I am not going to be ‘bad daddy’ for leaving them alone for a week J


I have to admit that the conference is starting to weigh on me. As fun and valuable it is to be here, it is hard work.


TLA03-IS: Exploring the upcoming C++ standard C++0x and TR1


This session is hosted by Kate Gregory and Ale Contenti.


It is an open discussion where they will give a short overview of the upcoming release of TR1 and the more distant release of C++0x.


Originally, the name C++0x was used to indicate that it would be formalized sometime before 2010, but Steve Teixeira already indicated that x would be hex as well, in which case the name is still correct even if the standard gets approved in 2015.


Currently there are no plans to release TR1 for VC2005, even though it would work with current technology. C++ 10 will already include some C++0x features that are easy and don’t change anymore, and C++11 will then probably include the rest.


Concepts are a welcome new addition to template programming. They have the same goal as constraints in the .Net generic types: to insure that template arguments implement certain methods / operators. The syntax uses ‘concept’ and ‘requires’. The big difference with constraints however, is that everything is checked at compile time instead of runtime. So template code execution is just as blazing fast as before, but now there will be easy to understand compile time errors instead of the 50 line type name errors that all of us have learned to love.


The C++ language itself will get the notion of concurrency and threading primitives to declaratively insure atomicity of memory access.


Template syntax will be extended with the … syntax that allows for variable number of template parameters. This is great for scenarios where the number can change depending on how you use it. I actually know a way to use this in my current code, but I am not getting into it here because a) that would take me too much time and b) only experienced C++ programmers (like, all 3 who read this article, one of which is myself J) would understand and care.


Rvalue references are another addition. They are a bit like const references, but allowing you to change the parameter which could be a temporary value. Basically, with revalue references your function indicates that you don’t do anything usefull with the original value after the function was executed. This allows you to implement move semantics with compiler verification of what you are doing.


A great addition is that the ‘auto’ keyword finally gets a good use. It will do the same thing as the ‘var’ keyword in C#.


For example, if you have a variable like this
std::map<std::string, std::wstring> myVar;
and you want to have a local iterator, you can now declare it like this:
auto iter = myVar.begin();
instead of doing this:
std::map<std::string, std::wstring>::iterator iter = myVar.begin()


these are the little things that can save you a lot of time.


Decltype is a keyword that returns –at compile time- the return type of an operation. This seems silly, but you can use it to use templatize the return type of a function based on what it does.


For example, the result of short + short is another short, but for short + float it is float. Or even for short += short it will be int.


These things are notoriously hard to do with current template technology.


And then something I have wanted for a long time: lambda functions, aka anonymous functions. A lot of algorithms in the STL require you to define the beginning and the end of a data range, as well as pass in a function pointer for defining what the algorithm has to do precisely. A good example of this is the std::for_each() construct.


Currently you have to create a separate function for e.g. doing something like this:


void DoStuff(int i)
{
  cout << i << endl;
}
void foo(void)
{
  Std::vector<int> v;
  v.push_back(0);
  v.push_back(1);
  v.push_back(2);
  std::for_each(v.begin(), v.end(), DoStuff)
}


Now, the syntax for lambdas is not yet finalized so it might change, but it would be something like this:
void foo(void)
{
  Std::vector<int> v;
  v.push_back(0);
  v.push_back(1);
  v.push_back(2);
  std::for_each(v.begin(), v.end(), <>( int i, cout << i << endl));
}


It might seem unimpressive, but when you consider that you’d have dozens or more of these DoStuff functions in your project, it becomes a really nice feature to just not having to care about declaring and implementing these 1 or 2 line functions.


Finally, if you want to know more about TR1 and C++0x, this is the place to be:


http://www.open-std.org/jtc1/sc22/wg21/


this is the site where the C++0x committee reports and proposals are published.


TLA409: Empowering developers: x86 and x64 Performance considerations when using Visual Studio 2008


This session was hosted by Robin Maffeo.


It started off with the same boring stuff that was in the previous AMD session (hardware changes and pictures of dies.


And then it got more boring.


I had expected to attend a session about things you have to watch out for when coding for x64, and I had expected it to be an advanced session (given that it was level 400). You know, I expect to learn something despite being an experienced programmer.


Instead, there were some general explanations of the different .NET garbage collectors and threading stuff. Like: use locks to solve concurrency, and lock as little as possible… DUH. This is a level 400 session. If you didn’t know that in advance you had no business coming to this session. Even for a level 300 session this would have been basic stuff.


The fact that a lot of people left the session halfway through proves that I was not the only one who thought this.


Then there was a short list (no demo) of the same C++ compiler things that were mentioned in the previous session.


At least this session gave me enough time to write up my report of the 9 AM C++ talk.


And Mr. Mafeo: if you insist on making fun of the competition with the claim that your CPU is a ‘real’ quad core while ‘the other one’ is only 2 dual cores glued together, you should also mention that said ‘pretend quad core’ has been handing your ‘real quad core’ its virtual ass on a plate for a long time, performance wise.


Nuff said.


INF308: Top 10 mistakes developers make


This session is hosted by David Aiken.


Originally I was going to Win312: Vista for managed developers: Besides .NET3.x but when I read the description, I discovered that the topics were the same that Kate had already covered in her talk about C++/CLI and Vista : a natural fit.


And in that talk I learned that the features covered in WIN312 are much more easily accessed from C++/CLI so I decided to skip it.


Use the right tool for the job. If I have to remove a splinter, I’d rather use a razor sharp scalpel than a spoon. Just because the spoon is safer does not mean that it is a better tool. Conversely, I would not eat soup with a scalpel. And – speaking as a moderator of the straightrazorplace forum – I can state with some confidence that my razors are sharp.


The idea about this session is that there are 10 things to do which are very easy, to make the life of an ITPro more bearable.


Why do we care about ITPros.?


Well, we don’t, but they are our biggest customer, and if they complain we have to stop our interesting work and fix their boring problem before we can back to our real work.


  1. Install.
    1. I don’t care if it works on your machine, we’re not shipping your machine. So mistake 1: Ad hoc configuration or making installation changes manually.Make a script so that everything is repeatable.
    2. Mistake 2: Don’t make assumptions about security. File io, firewall settings, creating perf counters. Run and test applications with standard user rights.
    3. Mistake 3: XCOPY install. XCOPY deploument really means XCOPY and then add registry entries, enable file permissions, create databases, create user accounts, open firewall settings, ..
    4. Mistake4: Uninstall = Format c:\ always create and test an uninstaller.
    5. Mistake 5: It is not good if an upgrade means a reinstall or worse. Create patch installers.
    6. Mistake 6: your patch breaks everything else. Make sure you unittest your changes so that your patch has no side effects.
    7. Mistake 7: your app comes without admin tools. Do provide admin tools. Instrument your app with WMI because ITPros can use that to configure the worls and its dog across a network already, and you get all the power for free. Also if your app needs to be configured, provide a powershell commandlet that does all these things. They can be used from MMC so you get that for fre as well.
  2. Health.
    1. Mistake 8: Your app is dead and nobody knows why. Create a health model for your app that provides useful information to the outside world. The upcoming health model will make this a lot easier to do.
    2. Mistake 9: Provide a way for admins to test if your app works OK and use synthetic transactions. This means have a way to tag an operation as a test but let it be handled normally. The other end then knows that it was a test and can ignore it.
    3. Mistake 10: Test your app in multiple scenarios. Apparently the feedback system at a previous PDC sucked so bad it had to be rewritten overnight. If more than a couple people used it at the same time it literally crashed the network.

This session was very interesting session. Even though my software will never run in ITPro environments, the points remain valid.


TLA407: Dealing with Concurrency and Multi-Core CPUs with today’s development technologies


This session is hosted by Joe Duffy.


The talk is about the different performance and responsiveness issues with parallel programming.


The first half of the talk was about showing what it means to use threads or a thread pool or a background worker.


Despite the fact that it was a good talk I found it all very basic, but I have been writing multithreaded apps since a long time. This was new stuff for a lot of people, and there are still lots of misconceptions about threading and CPUs.


For example, one person asked the following question: ‘If I have a 64 bit quad core system, can it run 8 32 bit threads at the same time’.


No question is stupid and it is not an unreasonable question to ask if you are a novice, but it shows that if you are experienced at parallel programming, you should know that a lot of people don’t.


There was a good demo in C# to show some parallel task for calculating a Fibonacci sequence.


The second half of the talk was about locking, and what you should do if you use locking. Monitor and lock were explained, as was the new ReaderWriterLockSlim. Kernel objects were mentioned as being less efficient, but useful for interop.


Other mechanisms mentioned were Monitor. Wait, Pulse, PulseAll and EventWaitHandle.


There was also mention of memory reordering (which the CLR prevents), the fact that native pointer sized reads and writes are always atomic if they are properly aligned.


I probably should have attended the session on new features in PowerShell 2.0, but that was a level 200 session and I should be able to flip through the powerpoint slides and get the gist of it.


INF307: Windows Server 2008 for developers: transactional NTFS


This session is hosted by Jason Olson.


The other sessions do not look that appealing to me, and I know nothing about transactional NTFS, so there is a good chance I’ll learn something new.


Jason is a great guy and he is currently doing evangelism for Windows Server 2008. He also has a development background and once Windows Server 2008 is kicked out of the door into the cold hard world of IT, he will be doing stuff in the parallel programming experience for .NET.


The meat of the session is: What is TNTFS (or TxF as it is called), Whys should I use it, and How do I do that.


If an NTFS transaction is started, you can create files via that transaction, and they will remain invisible to the entire system until they are committed. A rollback instead would remove those files and the system would never know that they even existed.


This session was all code and demo and no powerpoint. It was very interesting, but I could not take much notes and pay attention at the same time.


What was very interesting is that most of the code was in C++/CLI, and for a very god reason. All of the transaction stuff is in COM, and only after you set up the COM stuff can you do transaction File IO.


These things are pretty ugly if you have to do them in C# or VB.NET, so C++/CLI is a natural fit in this situation where you can do everything like He intended use to.


Not all hpe is lost for the managed programmers though. There are community projects underway to provide managed wrappers for the new Vista functionality. One of these projects is ‘Vista Bridge’ which bridges the new Vista APIs to the managed worlds.


Btw, Vista and Windows 2008 server are sharing the same code base so these wrappers will work on both.


There still a couple of teething problems with transactional NTFS for Vista but these should be solved in Vista SP1 or Windows 2008 server.


Also interesting to note is that more than half of the people in the audience were C++ programmers. (I’d say 60% or so).


Afterthoughts


You can hardly call me unbiased, but I think C++ has a great future ahead of itself. A Lot of work is going on to make C++ easier to learn, and easier to use productively (like adding regex, shared_ptr and notions of concurrency.

It will take several more years before we are there, but the most important thing is that all of this is happening.

I also managed to pick up a couple more free t-shirts, one of which simply says ‘geek’ in white on black. To get it I had to prove at the learning booth that I am an MCP (Microsoft Certified Profesional).


However, I have long lost my MCP card, and the web app that would check my MCP status based on my hotmail address crashed halfway through.


The lovely looking hostess then called a nice guy who decided to use the ‘Challenge based approach’ to verify my status. I had to list my certs, he chose one and then asked me : ‘Ok so what was on the exam’.


‘Uhhh’ since that was several years ago I had to think for a second (Windows 2000 Professional) and then was able to fire off enough exam content to convince him.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>