January 2004 - Posts

Script hell literally ;) and a bug definitely !

DHTML, one of the things that web has opened up with Javascript is a beauty. As we know, there are lots of fantastic things we can do using javascript but there are also loads of hiccups along the way. Browser compatibility, version compatibilty, client side settings et al affect how these things work most often.

Have you been in a situation where you had to go through bulk of Javascript code which does validation, creates UI effects, background requesting for data, and much more and find out which part of the script is throwing up the single weird yellow exclamation icon saying 'Error on Page' on the bottom left corner of IE ? hmm ... It gets all the more tougher when IE points out the line number of the error somewhere totally irrelevant to where it actually is. If you've been there, you must know how i'm feeling now. Recently, i've worked on good amount of client side scripting for enhancing a web app and learnt about another bug !?!

Here goes ... Take a look at this HTML code ... What do you think will happen when i execute ?? The HTML is simple but in a real project this is not how it looks anyway. All it does is to open up a new window when you click on 'This is cool' and dynamically writes a HTML string onto the new document. That's it ! But guess what happens ??!


Put the following Javascript function in the head script section ..

  function ShowWindow()
  {
     var myWnd = window.open("about:blank", "View", "status=yes,scrollbars=yes,width=800,height=700");
     myWnd.document.open();
     myWnd.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">; ');
     myWnd.document.writeln('<html>');
     myWnd.document.writeln('<head>');
     myWnd.document.writeln('<script language=javascript src="MyScript.js" ></script>');
     myWnd.document.writeln('</head>' );
     myWnd.document.writeln('<body><center><font color="blue" size="2">Hello World</font><center></body>');
     myWnd.document.writeln('</html>');
     myWnd.document.close();
     myWnd.focus();
     myWnd.close();
  }

Inside the body put the following span tag alone ...

<span onclick="ShowWindow();"><center><H4>This is Cool.</H4></center></span>



The HTML rendering is screwed up big time and all that is in the script is shown as such in the client HTML. The HTML is valid, the script is valid but what is the problem ??

The reason ( as far as i could plunge in and check out ) is that when you try to spit out the script start and end tag dynamically, the actual HTML doesn't render as such but instead the browser tries to validate and then render it which results in a total chaotic situation. All the script after this particular statement that spits the end tag , is shown as such and is considered to be a valid HTML and not part of script anymore ;(

The workaround for this would be to separate the ending tag of script from '</script>' to '</' + 'script>' ...

Anybody seen this kind of behaviour before or any similar situation with some other tags during dynamic HTML generation using scripts ?!

Update : As Ryan Gregg had pointed out, i had return the workaround here. But guess what the '<' in the workaround sentence screwed up again ;) How worse can it get... Mr. IE ! I'm already frustrated here .. Dont pour oil over the fire that burns inside uzzz ...

The Longhorn Meetup !

Check out Longhorn Meetup via Chris Sells. I've registered myself too but bad that the venues list doesn't include Bangalore yet. hmm guess what, Chennai, India has the leading response for the meetup till now :) Awesome ! Wouldn't mind travelling 300km to Chennai, which is kind of my native anyway to talk about Longhorn ... Of course it all depends on what i'll be involved with there .... If you are in India or anywhere else, check out the site and see if you can attend one of the meetups !

And btw should only stuff about longhorn be discussed at this meetups as the name specifically suggests or can we talk about Orcas, general OS features and other related technologies too ??? In my opinion, if this is a very informal meeting kind of thing, then a fixed agenda is not required ... Talk what is technologically delightful about the future ! 

What do you think ?

Longhorn, Native IL and Intel ?!? What the ...

A comparatively old article but very interesting facts. Read about Writing an end to the bio of BIOS !

It talks about the collaboration of Intel and MS to promote a technology specification called EFI (Extensible Firmware Interface) as a new system for starting up a PC's hardware before its operating system begins loading, a process that kicks in every time a PC is switched on or restarted.

Beautifully said :

"After 23 years, it was time to start from scratch," said Richmond. "There's a certain life span for every technology. You can expand it and grow it, but at some point you have to start over."

Reminds me of why such a total change in the APIs in Longhorn was brought in ...

Ok anyway on this context i was wondering whether MS will develop a new chip that can execute IL natively instead of Assembly code to optimise the execution of managed code ! If such a thing happens in the future, the efficiency of Longhorn applications will be amplified tremendously but then all the backward compatibility goes for a toss and surely the slashdotter's hue and cry on Monopoly and yada yada yada will keep rising :(

Well you never know what's in store but on the lines of what Richmond says, it looks to me like 'a perfect new start of the managed era !'.

Dodge this !

Check out this Dodging game ... Its completely done in Javascript and is bloody addictive ..

All you got to do is Dodge your way out ... Change the speed and others the way you want it ... I'm going to start writing this as a C# Winform app ! Will post that pretty soon :)

Novarg || Mydoom

The virus of the week in the Windows world is called W32.Novarg.A@mm or W32/Mydoom@MM. It will arrive as an email attachment with a file extension .bat, .cmd, .exe, .pif, .scr, or .zip. It can affect all versions of Windows back to Windows 95. If you get infected, it will set up a backdoor on your system and use that to do a number of other nasty things. It will also mount a denial of service attack against SCO Corporation. There are a variety of subject lines and text it uses in the email. You can see some of them at Symantec's write-up of this threat here

via BugBlog

Also read more on '1 in 12 e-mails carries nasty new virus. Mydoom could be worst Net worm ever'

I remember reading a similar 'Worst worm ever' statement when Sobig hit the net and many networks went crashing down. But how do these virus creators keep creating new viruses ?! I would love to see MS hire all the best hackers and virus creators around who can figure out the vulnerabilities and exploit it and inform MS about it before anyone with a malicious intent tries to do the same. In my point of view, that is the best way to improve the quality of a product. If you can't stop them, use them ;)

Age old debate - Java vs .NET ( Reloaded )

The original posts by Carlos Perez on “101 Reasons Why Java is Better than .NEThas been re-compiled and posted into a single article ... I missed it previously, but found a link from Jason Whittington's Radio Weblog ( where he comments about the top 25 in the list ) and then digged thro' the webspace to find the “101 Reasons Why Java is Better than .NET ( Reloaded )” post here .. hmm.

Also during the process found another link to "101 things that the Mozilla browser can do that IE cannot".

Don't start a war here but it's always good to know the point of view of the other side in competition ! Some things as they say could be true and some are absolute crap but take the good points alone. It always helps if you ask me ;)

Link Interface 21.

Lots of good things happening recently, good talks, articles, posts and other stuffs ... Too many to link to but here's a few of them !

  • Just noticed that Don's going bonkers about Indian food in UK !!! Hey that's 'Pani Puri' and not 'Puri Pani' ! My advice for you is to try the 'Masala Puri' next time Don ...
  • Fowler has posted about DecoratedCommand pattern. I think the aspectish behaviour of this pattern that he talks about is a by-product of wrapping the command with a decorator (another level of indirection, more like a proxy ?! ) so that advice, as he puts it, can be provided to the domain's methods.
  • Old news but if you'd missed, check out Anders interview about Generics in Artima...
  • How to Advertise in Google via SilverStr's ramblings at the Sanctuary
  • SimpLite - Instant Message Security System. Encrypts MSN or other IM stuff, tho the person at the other end needs SimpLite too.... ( via The Chicken Coop )
  • Bob Powell has got a awesome bunch of articles on GDI+ .. Check it out.. No wonder he's an MVP too ..
  • CodeJack - a .NET community for sharing code and other artifacts, with chat rooms, message boards, and other features ... ( via Larkware News )
  • Another post on X# or Xen ...
  • A pretty old site but read this funny site about one man's fight against mice ...
  • An article on improvisation of security in code by Trusting reluctantly ! very interesting .... I liked this particular statement 
    • Sometimes, it's prudent not to trust even yourself. While everyone wants to be perfect, it's wise to get an outside opinion.
    • Remember, trust is transitive. Once you dole out some of it, you're implicitly extending it to anyone the trusted entity may trust. For this reason, trusted programs should never invoke untrusted programs. Be careful; trust can come back to bite you.

That's it for now ! Wow ! I am barely able to keep my eyes open now .. gotta catch up with some sleep ! Happy reading :)

Googlism !

I don't know how many of you have been to this place but it got me laughing for a long long time ... Its called Googlism !

Googlism.com will find out what Google.com thinks of you, your friends or anything! Search for your name here or for a good laugh check out some of the popular Googlisms below.

I tried out my name first and went bonkers about the stuff that google had returned .. Kept laughing until everyone around me here started giving weird looks ! I was thinking about who else to try it on and then 'Rory' struck my mind ...

Some excerpts :

rory is a man of mystery ( you can say that again ;) )

rory is a icon in the sound system business ( Oh yeah .. We all heard that particular recording of yours ! )

rory is now 30 years old ( Is it ?? )

rory is evangelistic in nature with a prophetic and teaching anointing accompanying his ministry ... ( perfectly said ... )

rory is humiliated and walks out of the studio in a huff after the taping ends ( Is this about .NET Rocks ?? )

rory is still getting better and is getting bigger and stronger as well ( you bet he is ! )

rory is with jesus now but through this picture he is witnessing to the world ( hmm ... no clue what this is talkin about ?!? )

Rory, you rock ! These things sounded really funny but then i could see lots of things they say that you really are ! oh well maybe its just another figment of my wildest imaginations ;)

Should IDE be platform(framework) dependent ?

I was trying out something and was desperate to get it working because i thought it could open up a whole new possibility of ways to work on Framework 1.2 without Whidbey but still with a great IDE ( not Notepad or Textpad ;) )! What else would the IDE be other than VS.NET ! But what i found out after trying this experiment was rather very interesting and frustrating. First check out this entry that talks about Testing compatibility for Whidbey/Everett and talks about the lack of forward compatibility.

Someone sent a question recently to an internal alias so I thought I would share. The question was what will happen when a C# V1 component consumes a C# V2 component that exposes a generic class.  First some background information, there are two types of compatibility, backward compatibility and forward compatibility. 

  • Backward compatibility refers to a future version of a product, like Whidbey, supporting already existing functionality like something found in .
  • Forward compatibility refers to an older product, like Everett, being able to support a new feature like generics.

As you can imagine, it's easier to add backward compatibility since it is a known thing.  Designing for forward compatibility can be more difficult as it is an unknown thing.  The goal of C# Whidbey is geared more towards backward compatibility so that if you write a component today for version 1.x, your component will "just work" in C# Whidbey. 

I decided to test what forward compatibility will work with the current Tech preview for a VS Whidbey component to be used in VS 2003. To test forward compatibility, I created a simple generic class with two static methods.  The first method returns a generic collection, the second returns a non-generic collection.

via Dan Fernandez

A pretty informative entry but there are certain loose ends i think.

Now this is what i tried out -> Create a new VS.NET 2003 C# project and then de-reference all the System assemblies pointing to V1.1 and then refer the corresponding V1.2 assemblies. Compile the application. The application will compile without error from inside VS.NET, if all the methods and types that you are using are declared in the V1.2 assemblies ( till now fair enough ! ). Now Run the application. Since it compiled without any errors or even a warning, you would have got excited right now and would expect the beast to run and then show you 'Hello world' ! Aha .. There's the gotcha of the day... Eventhough the application is referencing only V1.2 assemblies, the mscorlib.dll which contains the base definitions are only those corresponding to what VS.NET 2003 uses ( V1.1 ). ahem., is there a way up your sleeves to specify the mscorlib.dll version while compiling ?

Eventhough Dan said that it throws an exception at run-time, he doesn't describe it completely. Here's the deal. It appears as though, the managed version of the framework on which VS.NET was built seems to be the default version for all applications built using that VS.NET IDE. I cannot see any other reasoning behind this one. So what happens is that, when the code loads, there is some runtime fault occurring because of version mismatch and the application fails to run. I reflected upon my compiled application, and the version of the mscorlib.dll alone was old but all the new references were properly set in the metadata of the assembly.

Another interesting fact is that, when i referenced the V1.2 assemblies, the VS.NET shadow copied *all* the assemblies ( System.*.dll ) into the local bin directory. hmm pretty interestingly weird behaviour i would say ;)

Now my only question is that why did you relate or rather link the mscorlib.dll version even before i set my refs and compiled it because that's how it seems to have happened ??! Why is your VS.NET IDE linked so closely with the version of the framework with which it ships ?!?! If it weren't for that simple restriction, today i could have been working with generics on my machine with just the V1.2 Framework installed and then using a single VS.NET IDE ... All the further updates could have happened to that single IDE and my working experience could have become better and better everyday. Unfortunately, that's not how things seem to work :( does it ? I have now ended up with VS.NET 2002, VS.NET 2003 along with framework versions 1.0, 1.1 and 1.2... Should i install Whidbey on top of this to create and try out code in generics, anonymous methods and other cool futuristic stuff ??! Why do you guys do this ? It feels thrilling to realize that the IDE that i work on is a managed product of the framework that i'm programming on; but you could have atleast let the dependencies be loaded independently while compiling applications in the IDE. Why is compilation linked and not made independent of the version of IDE ?!

Is there some other good reason behind all this ( and am i the only one babbling like this ?? ) What will Orcas bring then ?? Do i have to install another version of VS.NET again then ?

What do you think about all this ? Should your IDE be framework version dependent or independent of it so that all updates happen to that single IDE and enhances it further and further.

  • Consistent UI experience
  • No change in Project and solution files formats
  • Addins targeted at a single IDE rather than one for each of the versions ...
  • A single update can enable the IDE to work with a newer version of the framework
  • Saves a hell of a lot of disk space on the computer ( Definitely a billion times better than having 4-5 versions of VS.NET on computer to work on different version of the framework dont you think ?? )

Well ?!?

A better CMD.EXE

I frankly haven't had much problems working in the good ol' Command prompt but today got caught in a situation which made me realise how non user-friendly the command prompt has been all this while. This is just an instance of how frustrating things can get with the black and white screen ...

Ever tried copying a whole directory structure in command prompt mimicking what you would typically do in the explorer by doing a drag and drop ??? I did today and whoa, it will make you go wild by the time you are done with it ! The problem being that the command prompt only copies or moves Files and not Directories. Why has there been a special privelege to these virtual objects in the physical sense ? That too when you are stuck with something like a deep level of hierarchy and want to copy the whole thing, ughh i'm yet to find something more saturating and tedious than this for today !

Will MONAD, the command prompt in Longhorn solve problems like this ??! Anybody ?

Are delegates services ?

I was working on a multi threaded application now and out-of-the-blue, it struck me as 'Delegates' being close counterparts to '.NET Remoting' from a service oriented perspective. Correct me if my vision is skewed here, but isn't a delegate offering another mechanism to inform its subscribers of a particular event ?! And by definition, wouldn't that mechanism be categorised as a service ? I would definitely think so.
 
Coming from a background with deep object oriented ideas, its been quite a ride on the Service oriented ways recently but i am starting to understand aspects of such a design. In this particular multithreaded application, i have an internal class MyThread which will be created and spawned by the mother process. Now once the thread has  completed its operation, the CompleteHandler event will be called and correspondingly the Handler will in turn inform all the listeners of the event. Come to think about this, the delegate seems to behave more like a service, one that maintains state, with the boundary of the service being limited to in-memory and inherently working on the push model i.e., clients dont periodically check for event messages from a queue or something but instead the events are informed to clients real time. But after reading Don Box on Indigo and SOA the insights i've gained teach me that this might not be actually true. Don makes clear that Services have explicit boundaries which the Delegates do conform. For the other criteria, the Delegates doesn't fit in place and so the confusion in me ( eventhough i know i might have been wrong ) has mounted to mind blowing levels. Someone got any comments on how Delegates behaving like services could be true ?!
 
Although it is just a abstract way of looking at it, it kind of gave me vibes about how thinking in terms of abstraction to provide decoupled systems will help in implementing in a more service oriented way. For all i know i could be way off track here but just wanted to share what i felt. I am sure that it is a nice start for me because my outlook has been changing from being complete and pure object oriented, to object based, to service based now, later to service oriented and finally a ballad of both object and service oriented design methodologies. To me a good design needs proper decoupling and yet be strong in its object interaction and hierarchy structure to be stable and flexible. And that's where i'm trying to reach.

Finally, B'lore beats Silicon Valley !

For all those drown in misconception, this article shall enlighten them with facts and figures that Bangalore, India is indeed a 'Silicon Valley'. And guess what, it reveals many more facts about how Bangalore has exploded wrt Technology in the recent past and how it has got entwined itself as part of the global tech fraternity !

Today, Bangalore stands ahead of Bay Area, San Francisco and California, with a lead of 20,000 techies, while employing a total number of 1.5 lakh engineers.

via Slashdot

Don't start flaming about the article or anything, but what i wanted to show was just a glimpse of what the actual truth is. I remember a friend of mine who explained me on what his clients from overseas asked for when they flew down here for a product demo. Seems like, the customers were very curious whether my friend could do 'The Rope Trick'. I'd say 'WTF' ??! Give me a break and grow up. Come out of such delusions and accept the facts about developing countries and the pervasive effects of globalization.

Well, whatever be it, i strongly beleive that it won't make sense to have opinions about facts !

Spam filtering.

Saw this posting : Security Predictions of 2004 on Slashdot today and then remembered Paul Graham's work on Spam filtering methods. There are definitely lots of interesting suggestions and methodologies used by spammers and ways to identify and filter it. There was also someone out there who was doing spam filtering using Baynesian filterin