There is some misinformation you’re likely to stumble upon via Google when searching for “C# compiler /optimize+”. Interestingly, the following snippet can be seen on various forums. The following is a response from a developer on the C# compiler team: We get rid of unused locals (i.e., locals that are never read, even if assigned).… [Read more…]
In an internal meeting of a bunch of developers at my current company, someone made the assertion that the Switch statement in C# (or Select Case in VB.NET) is just a compiler short-cut for writing a chain of If-Then-Else statements. What do you think? Is that statement – true or false? Take the following C#… [Read more…]
Problem: Consider the following generic function written in VB.NET: What message do you expect to be shown by the following bit of code? Would the “Foo” method even compile? It doesn’t make sense to assign a Nothing (VB.NET equivalent of C#’s null) to a value-type, right? Solution: Well, the code compiles just fine. When synthesizing… [Read more…]
If you’re reading this article, you’re most probably familiar with the InvokeRequired property on Windows.Forms.Control class which we have to use whenever setting a property on a Windows Forms control from a thread other than the one it was created on. Here is what the MSDN page about InvokeRequired says: Controls in Windows Forms are… [Read more…]
Look at the following piece of code: Note how we are first assigning “Hello”, then appending ” “, and then appending “World”. The C# compiler generates the following IL code for our method named Test. From the IL you can see that the compiler did some optimization. The compiler saw what we were actually… [Read more…]
So anyway, this compiler group discovers that they no longer have 32K, or 128K, or 512K. Instead, they now have a 4GB virtual address space. “Hey, let’s use a really big hash table!” you can hear them saying, “Like, how about 1 MB table?” So they did. But they also had a very sophisticated compiler… [Read more…]
Why did I write this article, and why should you read it I have heard blanket statements lately that assert that DoEvents is evil but then I have also seen code that relies on DoEvents. In this article I will attempt to shed some light on why you might want to use DoEvents, possible problems… [Read more…]
As we go about creating abstractions on top of other abstractions to get stuff done we cannot avoid inventing workarounds for quirks and bugs in lower level abstractions. But it is important that those workarounds be incorporated in such a manner that they do not come and bite in the back when the quirks in… [Read more…]
I have finished writing a .NET client library for Tagyu's REST Web-Service. Tagyu is a hosted service that uses human intelligence to suggest tags and categories relevant to a block of text. TagyuLib (that’s my creative name for the .NET API) supports everything that the REST API of Tagyu allows you to do as of… [Read more…]
I have incorporated support for two new features in my Tagyu::Search module and learnt a lot about HTTP in the process. 1. Support for HTTP Basic Authentication With this in place, it is now possible for Perl code using my module to break the one request per IP barrier imposed on anonymous users by Tagyu.… [Read more…]
April 28, 2008
2