# Friday, September 05, 2008

One of the persistent myths of managed code is that you can’t have a memory leak if you’re a C# or VB developer. You really can. In this intriguing post, Sasha Goldshtein asks "Is it a managed or a native memory leak?" and then shows you some clues to lead you towards an answer.


Friday, September 05, 2008 9:58:05 AM (Eastern Daylight Time, UTC-04:00)  #    
# Thursday, September 04, 2008

While I was at Tech Ed Developers (US) this summer, I spoke with Craig Shoemaker for his Pixel8 podcast. We talk about UI, and Vista, and the usual things. I have some distinguished company in this interview but if you don’t want to listen to Ted Neward you can zip ahead to the 18 minute mark for me.


Thursday, September 04, 2008 9:56:06 AM (Eastern Daylight Time, UTC-04:00)  #    
# Wednesday, September 03, 2008

In case you were worried that Microsoft efforts like the Parallel Framework (PFX) would be aimed only at managed developers, leaving native developers sitting at the little kids table again, take a look at the Parallel Programming in Native Code blog. It hasn’t been updated terribly often, but perhaps some feedback would encourage them (or is it just Rick?) to keep it current :-). The one downer: "this is technology we're currently exploring and I don't have any ship or CTP dates to announce." Stay tuned, I suppose.


Wednesday, September 03, 2008 9:52:03 AM (Eastern Daylight Time, UTC-04:00)  #    
# Tuesday, September 02, 2008

Tech Ed Developers (Europe) is spotlighting a number of the top sessions from last year, free for anyone to watch. Mark Russinovich (on Wikipedia, his blog) knows more about the internals of Windows than anyone else who’s allowed out in public, and in this session, The Case of the Unexplained... (rated 5 stars out of 5 by attendees), he covers various mystery bugs and how he tracked them down. I’m slightly disappointed that some of the stories ended "so I logged a bug with that team" – I would have loved it if these were all fix-your-config stories, but still to see the techniques is very cool, and if your own code is causing the mystery CPU spike or resource leak, you will really benefit from the tools and approaches Mark shows. Sure, it was at the IT Pro half of Tech Ed, but developers need to know this stuff too!

I would like this stage someday. It's the Barcelona keynote stage, used for wildly popular breakouts also.


Tuesday, September 02, 2008 9:41:47 AM (Eastern Daylight Time, UTC-04:00)  #    
# Monday, September 01, 2008

At Tech Ed Developers (Europe) last November I spoke with Lori Grosland about Woman In Technology topics, life, the universe, and everything for just over ten minutes.

http://microsofttech.fr.edgesuite.net/TechEdOnline/Videos/EU_1_lgrosland_kgregory_FB_500.wmv will take you directly to the video, or try http://www.mstechedonline.com/library/Library.aspx and search for Kate. If you use that second approach, also try clicking the Women in Technology Link to see lots of other videos from the fish bowl and the WIT lunches at Tech Eds around the world.


Monday, September 01, 2008 9:38:22 AM (Eastern Daylight Time, UTC-04:00)  #    
# Wednesday, July 02, 2008

I enjoyed meeting some friends from the C++ team at Tech Ed and taking a turn in the booth. Li Shao and Marian Luparu were there when I was, and plenty of customers came by. Now you can read a nice summary of the customer conversations on the C++ team blog. The comments keep the conversation going. They are reading, so go ahead and join in!


Wednesday, July 02, 2008 12:21:01 PM (Eastern Daylight Time, UTC-04:00)  #    
# Tuesday, July 01, 2008

If you have some native code that you have sweated long and hard to create, and now you want to make a shiny new user interface using managed code (WPF probably) or expose the engine to web services (WCF probably) or the like, I hope you know how to do that. Most of the interop discussion out there is focused on that direction. But what if you have a native application and you want to use some cool capabilities from the .NET Framework? Most people really only know how to do it through COM. Your native code can pretend the .NET object is a COM component. But there are other options.

I've referred before to reverse P/Invoke - this is when a .NET delegate is made into a native callback function and handed to native code. It works, but in a way it's still managed-calling-native since the managed code has to start things off by making the delegate and handing it over.

There is a third way. It's a little complicated, but I bet it's faster performing than COM interop, and parts of it could be automated. Essentially, you wrap a C++/CLI managed class around some C# or VB managed class, and then you wrap a native class around that using gcroot<>. It's all explained with diagrams and samples by Sasha Goldshtein. Take a look!


Tuesday, July 01, 2008 11:24:58 AM (Eastern Daylight Time, UTC-04:00)  #    
# Monday, June 30, 2008

Justin Etheredge made an interesting point about code readability. He asks us to compare these two functions:

public static int GetNextSize(int i)
    //multiply it by four and make sure it is positive
    return i > 0 ? i << 2 : ~(i << 2) + 1;
public static int GetNextSize(int i)
    return Math.Abs(i * 4);  

They do the same thing. One might be faster to execute if there was no such thing as an optimizer. But bit twiddling is notoriously hard to read and maintain. In the comments you can see people saying "don't those two actually return different values?" And that's really his point. Human beings have to read your code and maintain it. They have to understand it. And if you pre-optimize, if you decide that bit shifting is faster than multiplying, you make like harder for everyone after you. Since that might include you yourself, a few years from now, think twice about it. Write readable code. Let optimizers optimize. People time is way more expensive than CPU time.

Some folks think this is a good rule for staff, but that consultants who charge by the hour should go with the clever code. Generally they have two reasons for this. First, they worry that if they write the simple code, someone will look at it and ask "how much an hour did I pay for that!?!?!".  I don't fuss about that, I just think "one dollar for hitting it with a hammer...". Second, they look forward to being brought back every time any changes need to be made to that code, since they're the only ones who understand it. I think that's shortsighted. Once the client realizes you've done that, you'll never get to work on any new projects for them. I'd rather work on a steady stream of new stuff than be stuck bugfixing old stuff for people who resent that I tricked them with my cleverness. And when I do have bugfixing to do, I appreciate being able to read what I wrote :-).


Monday, June 30, 2008 9:57:31 AM (Eastern Daylight Time, UTC-04:00)  #