Home > Blogs > Jim Mischel

RSS FeedSubscribeRSS details

"Highly unlikely" does not mean "impossible"

One of my programs crashed the other day in a very unexpected place.  A call to System.Threading.ConcurrentQueue.TryDequeue (from the Parallel Extensions to .NET) resulted in an OverflowException being thrown.  Investigation revealed a pretty serious bug in the System.Random constructor.

Continue reading...

Don't assume too much

We were discussing the design of a collection class at the office the other day, when the topic of parameter checking came up. This particular collection class has a Sort method that works just like the Sort method implemented by the .NET List generic collection. The programmer implementing the collection wanted the constructor to do some checking so that it could set a flag indicating whether the Sort method would actually work. This turns out to be a very bad idea.

Continue reading...

By Jim MischelAugust 10, 2008
Topics: Programming, Windows Programming

What's next for C# and .NET?

About 10 days ago, MSDN's Channel 9 site released an hour-long video entitled Meet the Design Team, that talks in very vague terms about uncoming features in C# 4.0.  You'll learn that the language will include more dynamic constructs and built-in support for multiple cores.  Honestly, that's about all you'll learn from watching the video.  Granted, either one of those broad features implies many changes to the language and to the underlying runtime.

Continue reading...

Is this really asynchronous?

I've been working on a relatively simple program whose purpose is to see just how fast I can issue Web requests. The idea is to get one machine hooked directly to an Internet connection and see how many concurrent connections it can maintain and how much bandwidth it can consume. A straight bandwidth test is easy: just start three or four Linux distribution downloads from different sites. That'll usually max out a cable modem connection.

Continue reading...

Why is this regular expression so slow?

One of the benefits--or curses, depending on my mood and how urgently I need a solution--of programming computers is that I often start working on one thing and end up getting sidetracked by a piece of the problem.  Today's distraction is a regular expression that's a lot slower than I thought it should be.

Continue reading...

It's obvious when you think about it

So many bugs that we encounter in our code are obvious in retrospect.  That makes it even worse when we discover them, especially if it takes us a long time to track them down.

Continue reading...

Pre-allocating a HashSet

In my most recent .NET Guide update, I mention that it's possible to create a large HashSet by creating a List or other collection, and then passing that collection to the HashSet constructor. However, I did not have a way to create an empty HashSet larger than about 48 million items. A little experimentation after I submitted the column revealed a solution.

Continue reading...

Goofy API functions

Sometimes I wonder if API designers think about how people will view their functions.  A good example is the Console.ReadKey method in the .NET Runtime.  

Continue reading...

By Jim MischelApril 16, 2008
Topics: Programming, Windows Programming

Counting on side effects

I've long been suspicious of code that depends on side effects, like depending on the order of expression evaluation.  In the past, one had to worry about stuff like this because language standards often didn't specify expression evaluation order, which meant that code that worked when compiled with Microsoft C, for example, wouldn't work when compiled with Borland C (or vice-versa).  I wrote some code like that today in C#, and wondered if it's considered bad practice.

Continue reading...

By Jim MischelMarch 12, 2008
Topics: Programming, Windows Programming

Why no IParseable interface?

I found it curious that in the .NET Framework objects can implement the IFormattable interface to expose custom formatting, but there is no corresponding IParseable interface. Not only is this curious, it's somewhat frustrating. I was going to write a rant asking why the lack of IParseable and present a possible solution, and then I discovered the very good reason why such a thing hasn't been done.

Continue reading...

By Jim MischelFebruary 26, 2008
Topics: Programming, Windows Programming

Take back the desktop!

At some point in the 30 years or so that I've been working with computers, we've lost sight of the most important fact:  computers are supposed to be tools that serve us.  All too often these days, I feel like I'm the one serving the computer.  At other times, the computer reminds me of the over-eager employee who comes running to the office after completing every minor task, enthusiastically telling me how impressed I should be that he managed to find and actually work the photocopier.

Continue reading...

By Jim MischelFebruary 19, 2008
Topics: Programming, Windows Programming

LINQ: I'm a believer

Language-integrated query (LINQ) is a new technology introduced with .NET 3.5.  The C# 3.0 language has been extended to support it.  LINQ is, in essence, a query language for in-memory data.  Think of SQL for your data structures and you get the idea.

Sometimes you have to see a thing in action before you understand just how powerful it is.  The other day I had the opportunity to learn that about LINQ.

Continue reading...

By Jim MischelFebruary 7, 2008
Topics: Programming, Windows Programming

Page 1 2 Next >