C/C++

The MIE Podcasts – Govert van Drimmelen

In this podcast we caught up with Excel DNA author Govert van Drimmelen. Govert is a Mathematics lecturer at the University of Johannesburg, in South Africa. Excel DNA has had some attention from the Excel blog sphere in the past few months, Simon, Mike, and Mathias have all posted about it. I’ve been using it for a while now, and it’s brilliant. Here we talked about how Excel DNA came about, the basics of how it works, some of the new features and what’s planned for the further.

Govert van Drimmelen, famous for his Tom Selleck impression

If you don’t know what Excel DNA is, well then listen to the podcast, but in short it’s a free and easy way to get .Net code into Excel.

I’m sure you will all join with me in thanking Govert, not only for making time for the podcast, but also for all the hard work he’s done  in getting Excel DNA out of the door – well done Govert!!!

And remember if you’d like to see more of Excel DNA, I’m giving a talk about it at the UK Excel Dev Con, in a weeks time!!!

A Devlopers Tool of Choice?

When we talk about which language to use we often, if not always get talking about the technical advantages of a given tool, XLL’s are faster than VBA, VBA is easier to deploy than VSTO, VSTO is more secure than VBA, and so on and so on. Simon has some information here and I have some .Net stuff here. But one aspect that’s over looked is what each offers the developer.

Let’s consider an example. I’m writing a adding for the users in my department, it needs to contain some UDF’s, apply a custom formatting option to a selected range, help import a strangely formatted XML file, and link to a database and pull back some data. What are you going to write that in?

Well from a technical point of view you might like to used an XLL for the UDF’s, a Com adding for the formatting and database stuff and make use of some .Net classes for the XML processing. Nice!

For 90 percent of us, we will solve every problem using VBA, simply because that’s the only tool we have. But what if?

Here’s what I think different technologies offer the developer, not the technological advantage, it the things that make the developer’s live more enjoyable!

VBA: For simple stuff it’s quickest. As things get more complex and or the difficulty of what you are trying to do gets harder VBA becomes more of an effort (think of userform stuff, VBA, vs .Net?!). If you need something that needs constant changes, or something that you expect to grow in size over a period of time it might be worth doing it VBA.

VB6 (Com addins): If the UI you need is a bit more complex, than it might be time to switch to VB6, the more powerful forms and use of active X components means that you can have more choice when designing them. Also from a deployment POV, you have to worry less about the thing being installed on the PC, as you can compile them into the DLL

As the size and complexity of the project increases, switching to VB6 can be a help. Functionality can be complied in to different parts, external libraries can be used and packaged easily, source code can be shared with other developers – although this is rare for Excel projects.

Another good reason for a developer to pick VB6 com adding over VBA ones is that, although generally VB6 code can be changed with little effort to run in VBA, there are times when VBA does not quite have the same feature set, and dropping some code straight in to a VB6 com addin is just easier than messing around trying to convert it to VBA.

VSTO: Well its IDE isn’t 100 years old, thats a big plus! But the most compelling reason why an Excel dev would want to use VSTO, would be to make use of the framework. Forms are incredibly powerful in .Net (form namespace), but so too is all the functionality that the framework provided, like the threading name space, or the services name space. When we start to try and do really grand stuff, .Net is brilliant.

C/C++ [XLL]: Purely from an easy of development POV, I can only really think of 2 things XLL would over. One would be a situation where you need to deploy is a “hostile” environment, so the extra work in the coding would be repaid in the effort saved deploying. The other would be if there is a C library with some complex functions in it, a bit like with the VB/VBA issue, it might just be easier to keep the C code and wrap it up in a XLL.

VSTA: What’s VSTA?!?!

So there you go that’s my take on it, disagree?

Is C# like Robby Williams?

When Take That first came on the seen Robby Williams was a young sexy super stud, loved by all, women wanted to be with him, men wanted to be him (ok, maybe the analogies not perfect). Now he’s a slightly overweight widero who chases flying saucers.

And so C#. When it came out (easy!) developers flocked to it, hailing it’s development speed over C++, and hoisting it’s strongly typed compile time error detection pants up the flag pole of integrity. Now, with C# 4 around the corner, those panties have slid down the pole a bit, as MS have seen fit to invite a bloshy Dynamic Runtime Library sorry, Dynamic Language Runtime (- what every it’s called!) to the party.

What am I going on about? Well, MS have stated that they want to bring VB, and C# much closer, so that new features in either language (read C#) are deployed at the same time in both. Other stuff that’s coming with the new release of .Net is the Dynamic Runtime. I’m no expert – in fact what I am is a Luddite on a soap box – but for this to work (with out having to write 10 million lines of code), C# has to have much of the features of VB, basically dynamic types. This is not necessarily a requirement at the developer code level, but required to make the language work with external object. This in turn means that .Net can work more directly with Office and all other components developed in other languages! – cool!. Hence why they can get rid of the dreaded PIA’s.

Along with this MS are making other changes, like named arguments and not having to write ref missing 10 billion times to fill out all the optional parameters. Also in VSTO deployment is getting better too.

So the point? well 2 things really:
1. In both VB and especially C# it’s getting easier to develop,… for Office.
2. C# and VB are getting even more alike, expect to see “with {}” some time soon. Why an organization would invest in developing 2 languages that both have the same strengths and weakness is for Stevie Bulmmer to debate, but I can’t see the point can you?

As always, M.I.E will be the 5th or 6th to bring you slightly wrong information about the latest developments in the world of Office and .Net.

Some links worth reading if you want to find out more:
The Future of .NET Languages
Office client developer enhancements with VS 2010
VSTO news

Is Managed Code Slower Than Unmanaged Code?

What’s you gut answer right now; without reading the rest of this post?

In my (seemingly) never-ending quest along the path of Uncapacitated Facility Location problems, I found myself thinking if I would be better of write some core functions in C (unmanaged) and calling them in my VB.net project? I thought that it probably would be, but decided to check first. Here’s the link, you can skip to the conclusion at the end for the low-down:
http://www.grimes.demon.co.uk/dotnet/man_unman.htm

Dot Disaster, Frameworks don’t work!

The world of managed com addins is a mess. VSTO has not been received well and the story of unmanaged code (Excel) and managed code is of deployment and stability nightmares.

There are a quite a few things right from the off that cause problems for Office devs wanting to use .Net technology:
- .Net is inherently slow, and slower still when com interop is needed
- mscorelib (hell, ;-))
- Security
- Deployment (esp. VSTO < v3)
- Framework availability

VSTO and managed com addin can over come the first 3 issues by using so called “com shims”, which are proxies sitting between the managed code and the com application (com shims themselves are unmanaged code). Although these solutions actually compound some of the other problems (i.e. speed), they generally work well and have been successful.

Deployment for managed com addins is not such an issue, as it is up to the dev to ensure the addin installs correctly. However the first two versions of VSTO tried to simplify this process, unfortunately Microsoft never “managed” to get it right. VSTO 3 seems to have cracked this particular nut, although we should wait for reports from the wild until we take this as gospel.

ms1.PNG

There is little anyone can do about framework penetration, but having to install a .Net framework to run a addin if frankly a laughable proposition and there is quite literally no way to avoid it, it’s fundamental to the concept of .Net. The problem then becomes what if users are unable to install frameworks. The thinking is that this problem will vanish with time, as windows service packs and new installs load the framework “organically”.

However, the last point may be moot because there is potentially a black cloud hang over managed code and Office!

Stephane Rodriguez of xlsgen points out that the framework version Excel (office) loads first, will be the framework versions that all subserquent managed addins will have to use. The com shim does not effect this out come as it’s controlled at the Application level, i.e. the process belones to Excel, not to your addin. This is comfirmed by Microsoft here, where the conserquencies are spelt out quite plainly!

If other managed code, such as an add-in, requires the later version of the .NET Framework, it will not run.

In the research I have briefly done of this issue there does not seem to be a solution available as of today. This seems like quite a serious shortcoming, and to me at least, hugely surprising because one would imagine that MS are aware of the implications.
It does beggar the question as to why this sort of thing should ever be an issue for devs, Microsoft trumpet long and hard about how easy MS products are to use, and often that is true, but with .Net and Com this could not be further from the truth.

This the is yet another blow for .Net and Office, it has implications for all the .Net technology, VS, VSTO, and VSTA (should VSTA ever make it in to a actually product?!), what are MS doing to us?!!?

I’m a big fan of .Net, its quick and easy, and very powerful, but is it the right tool for current office products? It’s Unlikely that MS will port Office to a .Net platform (currently no MS product of note are built using .Net odd that!)

So where does that leave us? VB6 has long departed (although is still exceedingly popular) VBA is no longer developed, MS variations of C, and their claims to nativity is up for debate and it’s hardly a tool you want to use to build true RAD solutions. So, anyone for Delphi?