Bug Vanquisher

30 April 2008

Threat Levels

Filed under: Funnier — Tanveer Badar @ 6:03 PM

[Disclaimer: No intended offense to any English, French, Italian, German, Belgian, Spanish or Aussie reader who happens to come across this post.]

The English are feeling the pinch in relation to recent terrorist threats and have raised their security level from "Miffed" to "Peeved." Soon, though, security levels may be raised yet again to "Irritated" or even "A Bit Cross." Londoners have not been "A Bit Cross" since the blitz in 1940 when tea supplies all but ran out. Terrorists themselves have been re-categorized from "Tiresome" to "A Bloody Nuisance." The last time the British issued a "Bloody Nuisance" warning level was during the great fire of 1666.

Also, the French government announced yesterday that it has raised its terror alert level from "Run" to "Hide." The only two higher levels in France are "Surrender" and "Collaborate." The rise was precipitated by a recent fire that destroyed France’s white flag factory, effectively paralysing the country’s military capability.

It’s not only the English and French that are on a heightened level of alert. Italy has increased the alert level from "Shout Loudly and Excitedly" to "Elaborate Military Posturing." Two more levels remain: "Ineffective Combat Operations" and "Change Sides."

The Germans also increased their alert state from "Disdainful Arrogance" to "Dress in Uniform and Sing Marching Songs." They also have two higher levels: "Invade a Neighbour" and "Lose."

Belgians, on the other hand, are all on holiday as usual, and the only threat they are worried about is NATO pulling out of Brussels.

The Spanish are all excited to see their new submarines ready to deploy. These beautifully designed subs have glass bottoms so the new Spanish navy can get a really good look at the old Spanish navy.

The Australian’s level has increased from "What the f#ck?" to "Who the f#ck?". The next level for Australia will be "Well, f#ck me" all the way up to "Enough is a f#ckin nuff".

22 April 2008

Horribilus Totalus

Filed under: Bugz, Fun, Rant vs Vent — Tanveer Badar @ 3:32 PM

I can’t properly write anything from Live Writer if I have IE8 installed. For some weird reason, mshtml.dll seems to decide that an AV is in order at some random instant whenever playing with tables or particularly (read pretty) formatted text.

19 April 2008

The Myth Called Overloading

Filed under: Dev inside! — Tanveer Badar @ 11:23 PM

There are some serious word press screw ups in this post. No smileys, ever! Yet word press insists. Also, line breaks are disappearing like mad.

There is no such thing as function overloading in this world! Period.

Whatever you see in HLLs is the compiler lulling you into the false sense that function overloading exists.

Cases in point:

1- C++: Most major compilers (at least from Microsoft) use name mangling. Here is dump of four constructors on std::bad_cast from msvcrt.dll

Mangled mode

Pretty mode

??0bad_cast@@AAE@PBQBD@Z bad_cast::bad_cast(char const * const *)
??0bad_cast@@QAE@ABQBD@Z bad_cast::bad_cast(char const * const &)
??0bad_cast@@QAE@ABV0@@Z bad_cast::bad_cast(class bad_cast const &)
??0bad_cast@@QAE@PBD@Z bad_cast::bad_cast(char const *)

2- CLR:Everything compiles down to IL, whether you like it or not. And here’s IL for typical function calls:

call class System.ServiceModel.Channels.Message System.ServiceModel.Channels.Message::CreateMessage(
class [System.Runtime.Serialization]System.Xml.XmlDictionaryReader,
int32, class System.ServiceModel.Channels.MessageVersion)

from System.ServiceModel.Channels.Message.

That’s it, you get the whole nine yards. Return type + fully qualified function name + fully qualified parameter types. It does not matter whether you use call, callvirt or calli. If its a call, its going to use everything fully qualified.

3- You may want to argue about operator overloading. But that’s just syntactic sugar.  Here is >> from std::basic_istream.

Mangled mode

Pretty mode

class std::basic_istream
<wchar_t,struct std::char_traits<wchar_t> > &
std::operator>>
<float,wchar_t,struct std::char_traits<wchar_t> >
(class std::basic_istream
<wchar_t,struct std::char_traits<wchar_t> > &
,class std::complex<float> &)
??$?5M_WU?$char_traits@_W@
std@@@std@@YAAEAV?$basic_istream
@_WU?$char_traits@_W@std@@@0@
AEAV10@AEAV?$complex@M@0@@Z

4- In CLR, the case is even simpler. You get op_Add straight away, then, its off to fully qualified function calls in IL. End of story.

It does not exist. Anywhere. Ever.

18 April 2008

Stick Your Leg [Here]

Filed under: Rant vs Vent — Tanveer Badar @ 5:56 PM

LINQ and SQL Server: Good or Bad Addition to the Database World?

While SQL Server 2008 has introduced many new features and improved many existing ones, one of the newer database features that has recently started taking the development world by storm is Language Integrated Query or LINQ. There are many different varieties of LINQ, including: LINQ to XML, LINQ to Entities, LINQ over Dataset (VB and C#), and LINQ to SQL.

This is what you get when someone who is no programmer tries to stick their leg into matters no one in their ancestors ever understood.

By the looks, it seems that T-SQL itself natively supports LINQ. :)

13 April 2008

It is coming

Filed under: C++ — Tanveer Badar @ 7:52 PM

int array [ ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 };
std::vector< float > v( query::as_query( array , array + 12 ).select( 5.3f ).to_array( ) );
std::copy( v.begin( ) , v.end( ) , std::ostream_iterator< double >( std::cout , ” ” ) );
std::cin.get( );

The first revision is here!

Compare the above to this. Almost all the clutter is gone.

exit( 0 );

Filed under: Personal — Tanveer Badar @ 7:40 PM

I upgraded [it]s project to VS 2008 format, only three days before the semi-official end (on Wednesday, if I remember correctly) of development. Only to find that VS 2008 does not play too well with only 1 GB memory.

7 April 2008

Analyze This!

Filed under: Bugz, C++ — Tanveer Badar @ 1:06 AM

Consider this little piece of ****. I mean piece of code. :)

template< typename U , typename T > U convert( T t )
{
    return t;
}

template< typename T , typename projection , > class blah_blah_blah
{
public:
    // details we really shouldn’t see

    projection& operator * ( )
    {
        return convert< projection >( *current );
    }
};

If you decide to do

blah_blah_blah< float , double > x = get_blahblahblah( );
*x;

The second statement will fail with some cryptic error message. The real problem is the return type of operator * and the statement return t; in convert. The implicit conversion from T to projection (which is to say, promotion from float to double) loses the l-value[dness] of *current. And since a reference requires l-value upon return, it fails to compile.

Given the constraint the convert< projection > was absolutely necessary, and upon further thought, that projection& was not a requirement, a fix was born.

projection operator * ( )
{
    return convert< projection >( *current );
}

Who Says Harry Potter Is Worse?

Filed under: Funnier, Rant vs Vent — Tanveer Badar @ 12:52 AM

There are thing far, far more worst than Harry Potter in the mortal world, mere mortals.

I am talking about ‘The Davinci Code’. If Harry Potter movies were off the plot, The Davinci Code seems like the producer(s) and director(s) never read the wretched novel themselves.

By the looks, they had just the remotest idea of what was supposed to be in the novel and how they should produce the movie, which they then off shored to some sit-together, under-paid, road-killed Indian company. I half expected some cheap song to spring to front at the end.

Thank God I only spent 15 minutes watching the twisted end game. It is much better than the 90 minutes spent on ‘Jarhead’, where I couldn’t decide the entire time whether I should continue watching it or not. That was the first for me in living history where I didn’t make up my mind this long.

6 April 2008

‘The’ Source Code

Filed under: Dev inside! — Tanveer Badar @ 2:51 AM

If you haven’t heard that .Net framework source code is available while debugging under Visual Studio 2008 Professional (may be standard too?) or higher, I suggest you crawl out of the rock you are living under so far.

Specific details about how to set up your environment to enable source level debugging in FX assemblies is here. And it works too. :)

However, what amazes me is that the build tree is even more cryptic than ROTOR. Take a look at the monstrous path to AppDomain.cs.

F:\NetFX Symbols\src\source\FX1434\1.0\DEVDIV\depot\DevDiv\releases\whidbey\REDBITS\ndp\clr\src\BCL\System\AppDomain.cs\7

Yes, the actual .cs file is under <blah blah blah>\AppDomain.cs\7 directory.

[Update: about one hour later]

1- Go to definition does not use this particular source server for whatever reason. Bug filed here.

2- Downloaded source code is not persisted for whatever reason. Suggestion filed here.

Blog at WordPress.com.