Tech Ed 2011 Summary
Tech Ed was great this year. Already mentioned a few topics that were of great interest. Here’s some more topics that deserve further attention.
Ever heard of functional programming or a functional language? No? Not surprised. It is one of several categories that language designers use to identify languages. Functional languages have their basis in mathematics so they look and act like math expressions (functions). What makes functional programming so useful is that data is generally passed one function to another. In fact the data is generally just defined in terms of the function it performs. This makes these languages great for mathematical processes. It also solves one of the more difficult problems of multi-threaded programming – shared data. Normally with MT programs you have to use locks to protect shared data. With a functional language this isn’t necessary because each functional data feeds into the next like a pipeline. Even more important is that most functional programming involves arrays/lists of items. Functional languages can parallelize these values, do some processing and put it all back together without the programmer even worrying about a lock. Needless to say functional languages are great for parallel processing.
F# happens to be a functional language. Written by the folks at Microsoft, it runs on the .NET framework. It has actually been out a couple of years but most people haven’t been exposed to it until now. In fact if you have VS2010 it is already on your machine. You can use the F# Interactive tool window to start playing around with it. It comes with some great tutorials as well. However functional programming is as far beyond procedural programming as procedural is beyond English writing. Therefore it will take time to understand. You probably will never be creating your UIs in a functional language but it is likely that one day you’ll be using a parallel library that is itself written in F#. So now may be a good time to take a look at it. Here’s a starter link: http://www.tryfsharp.org/Default.aspx. If you are running VS 2010 then you already have the necessary tools.
Honestly I wrote this off as yet another tool for wannabe programmers. After hearing more about it I realize that it may very well be the future IT programing tool. Today most IT groups use Access or Excel for creating simple apps they need to get their work done. Who hasn’t had to deal with crazy UIs and hacked together VBA? LS will change that albeit with a slightly higher learning curve. LS allows non-developers to create the same types of apps (minus the reporting) but using modern tools and the entire .NET framework. When such an app eventually winds up in the hands of the “real” devs we won’t want to shoot ourselves over the limitations of some scripting language. We’ll be working in VB/C# and the framework!!
LS does have a higher entry requirement than existing tools. It is designed for 2 or 3 tiers. The client application is Silverlight hosted via IIS. The back end can be SQL Server (any edition), WCF services or whatever. The IIS requirement (I believe it ships with Cassini) is probably going to be the biggest headache but it’ll be worth it. Who hasn’t had someone call them and complain about a bug in some Access app. When you ask what version they’re running they say Office 2007. “No, what version of the app? I don’t know. Argh!!!” SL removes the deployment/update issue while still allowing it to run just about anywhere.
LS is still in beta but a GoLive license is available so companies can begin using it today. Here’s the MSDN for LightSwitch: http://www.microsoft.com/visualstudio/en-us/lightswitch/
Talk to any C++ developer and you’ll hear grumblings about the lack of features and support in later versions of VS. Well that’s changing. In VS2010 RTM Intellisense was completely rewritten. It is now fast, accurate and reliable. In SP1 the C++ team has added some basic editor features that were either not fully baked in RTM or missing altogether. vNext problems to bring C++ back up to par with the existing .NET languages. Exactly what those updates will be we’ll have to wait and see.
Another area with VS2010 really advanced C++ is with the new C++ 0X standard that should be approved this year. C++ now has better support for parallel processing and the VS2010 version already supports this. Here’s some of the C++ standard changes already in VS2010:
- shared_ptr – Updates to this type (introduced in VS2008) make it easier to work with and reliable.
- Concurrency runtime – Adds support for parallel processing in C++. This is different from openmp which is about multithreading an app. ConcRT works and is easily added to existing apps just by including ppl.h (for the most part). It will make the process of optimizing existing code to take advantage of multiple cores easier.
- Anonymous types – Ever heard of the auto keyword? Most people haven’t but it was in the original C++ spec. It’s purpose was to allow a programmer to optimize code generation by telling the compiler some additional information about variables. Nobody really used it and it was deprecated. However in order to support newer constructs this keyword has been changed to represent something completely different – anonymous types. An anonymous type is really just a type where the compiler figures out the underlying type based upon usage rather than a programmer specifying it. We aren’t losing any of the strong type checking support C++ is known for. All we’re doing is telling the compiler to figure it out. Here’s an example.
SomeObject* someVar = new SomeObject;
It really is redundant to specify the type twice. The compiler knows what the type is and so do we. Therefore we can replace the above with the following and everything will work exactly the same.auto someVar2 = new SomeObject;
Now to be fair overuse of the auto keyword can cause problems and make maintaining the code harder. But in the example above and another case it makes code easier to read and understand. So limited use of this keyword is good. What’s the other case? Well that would be…
- Lambda expressions – Lambdas can be hard to explain for those that don’t work with them. Basically though a lambda is an anonymous function that you declare and use in one specific place. The compiler is responsible for generating the underlying boilerplate code to create the real function and hook everything up. The main benefit of lambdas is that it allows us to replace one-use functions with a lambda expression that is defined where we actually use it (sort of like a nested function, but not really). A full discussion of lambda is beyond this post so refer to the link above.
Where do anonymous types come in? Well the underlying type of a lambda expression is managed by the compiler so if you want to create a lambda variable you can’t really find a type that would work. This is the other case where anonymous types come in. You can create a variable of an anonymous type and assign it a lambda expression. Then you can use the variable elsewhere without regard for the type. The syntax for lambda expressions in C++ isn’t easy so I’ll defer from samples. Refer to the provided link above.
It is important to remember that lambdas and anonymous types are strictly compile-time features. The compiler generates the boilerplate code you would normally write to get this to work. At runtime C++ just calls functions and all variables have a strong type.
Should I Upgrade Now or Wait?
There were a lot of folks asking if they should go ahead and upgrade to VS2010 or wait for vNext. The simple answer is: upgrade now. Microsoft generally only supports one version back on compatibility so in order to be ready for vNext you should first get your code running under VS2010. Furthermore vNext does not yet have a release date. It could be 6 months or 6 years. The standard life cycle for VS seems to be 2-3 years so it is possible that vNext will be released 2012-2013 but it is far to early to tell. In the meantime VS2010 provides a lot of functionality today that is better than VS2008. You need to be familiar with this functionality in order to prepare for what is coming in vNext. So if you haven’t upgraded to VS2010 yet then do so now.