new() really is just an alloc and a function call

While reading Eric Lippert’s blog some time ago he mentions that the constructor is just a function like any other function.

This was serendipitously reinforced for me while stepping into a constructor call.  Since Visual Studio ships the CRT source (and it’s been installed), stepping into a constructor call first takes you into new().

I’m pretty sure new’s OK so I immediately step out and find myself executing the constructor.

I guess Eric's right: an object constructor really is just another method.

Parallelism and the Virtue of Selfishness

When it comes to tracking down bugs in recently parallelized code look for static objects in the call path.  This is a case where VB.NET’s naming convention makes it easier to realize this (in VB.NET static objects are called shared).

So far these have cropped up inside of basic data model objects (objects that correspond almost 1 to 1 to a real world object in the domain of your application).  Usually it’s a performance optimization that Moore’s Law has made unnecessary.  Apart from Moore’s Law object allocation in a managed context is pretty inexpensive.

In my case the culprits were a static Regex object and a static SoapFormatter.

When it comes to concurrency, not sharing (selfishness) is a virtue.

Using Window’s FOR command to replace unix find -exec

Finding all directories within a directory recursively:

dir /a:d /s /b <dirname pattern>

e.g.,

dir /a:d /s /b tmpdir*

the /a:d flag restricts the results to directories, /s does a recursive search and /b prints the results in bare format.

Why bare format?  Because that makes it suitable as input to the FOR /F command.  Putting them together, you can delete all these directories with:

FOR /F “delims=” %i IN (‘dir /a:d /s /b tmpdir*’) DO rd /s /q “%i”

FOR’s /F allows, among other things, using the output of a command (in between the single quoted parentheses) as input to a command that’s repeated (the part after the DO).  In this case we’re executing RD (remove directory) on each directory that starts with the name tmpdir.