Wednesday, October 12, 2005

Microsoft Visual Studios 2005 Team System, Episode IV (Microsoft Visual C# 2.0 new Features Part A)

Now I'll resume the Visual Studio 2005 Articles, but I'll put one or two new features in each new article to stop it from being to large.

Let's begin.

One of the most amazing features which come with C# 2.0, is the enabling of edit and continue in debugging mode, in this article, we'll talk about what's edit and continue, how it's working, and its limitations inside C# 2.0, for the full article, visit:

What is edit and continue?

Edit and Continue (hereafter referred to as E&C) is a new debugging feature introduced in Visual C# 2005, it was used by VC++ developers since early VC++ editors.
It allows you to make changes to the code while an application is being debugged and to apply the code changes without having to end execution, rebuild, and run the application again.

But how it could make your life easier?!

Imagine you're making something like a complete Game Engine, or a huge 3D game, and as you know debugging such applications is like hell, now imagine after 20 pr 30 min of full debugging, you discovered that you need to change something in your code, but Ohh my god, I must stop the debugging and restart it again, so all the time I passed in the debugging (the 30 min) is over now, and furthermore, I may lost the exception which I had already caught if I tried to restart it again, so what shall I do?!!
Now this is why you should use edit and continue, because now you're not forced to stop and restart the debugger again, it'll just get the edits you made, inject it to the code inside memory and here you're debugging the application after being changed without restarting it, isn't it amazing ;)

How does edit and continue work?!

Though E&C is simple to use, the CLR and the compiler have to work together to do some heavy lifting in the background. When a file is edited in the IDE during a debugging session, the compiler first checks whether the change is allowed or not. If it is not possible to perform that change, you'll see a dialog box like the one in Figure 1.

Figure 1. Message box shown when you make a change that is not allowed

Clicking the Edit Code button takes you back to the debugging session to allow you to fix the errors that won't allow the debugging session to continue. You might choose this option if the errors that didn't allow E&C to continue were build errors. . Clicking the Stop Debugging button ends the current debugging session and reverts back to design mode. You would choose this option if the errors detected are changes that you need to make. The compiler supplies delta-IL and delta-metadata, which is used to replace parts of the existing IL and metadata in memory. Delta-IL and delta-metadata simply refers to the gap used to insert the edited code. If the edited methods have been JIT-ed into native x86 code, they are replaced with new x86 code.

Limitations of Edit and Continue:

The rule of thumb for making E&C changes is that you can change virtually anything within a method body, so larger scope changes affecting public or method level code are not supported. Some examples of such unsupported changes are:
· Changing the name of a class.
· Adding or removing method parameters.
· Adding public fields to a class.
· Adding or removing methods.

That's all for today, next time we'll talk about Generics the new feature in C# 2.0 which mimics C++ templates but in different way.
Catch you later.....

Saturday, October 08, 2005

H1B Visa, Status Report!

Hii everybody, and sorry for being late for writing new episode on C# 2.0 inside Visual Studio 2005, but there's a reason for this, which is the news I got from my immigration attorney inside Microsoft.

As I said before, I heard that the Fiscal Year 2006 (FY2006) H-1B visa cap has been reached, but I was having no clue whether Iam inside those whom got accepted or not.

Till 2 days ago I was having no clue about this, but finally I knew, that my petition was not selected for adjudication under the FY2006 cap, and this mean that if I wanna apply for H1B visa again I'll travel on next September 2006 at least.

So what about solutions?!

There're many solutions, some of them I can't publish here unless I get sure that I can use them, others are like optaining another type of visa temporary or waiting until the next H1 cap are also available!

Iam just telling you that the next episode will be late somehow till I knew any thing new.

Catch you later.....

Thursday, October 06, 2005

Microsoft Visual Studios 2005 Team System, Episode III (Microsoft Visual C++ 2005 new Features Part B)

Now it's time for Visual C++ 2005 new features part B, so what else?!

3- Additions for optimizing the generated applications:

Another huge part is the optimization inside Visual C++ 2005, you'll know all now about PGO (profile guided optimization) in this part.

We all know about aggressive optimization offered before in Visual C++ 2003 and 2002, I don't know whether they have any modifications inside it or not, but I'd like to talk about PGO now because it's really a very nice features.

My source in this article is MSDN in addition to a private seminar held by one of the VC++ team members in my old company Sakhr, you can find the whole article source at:

Now let's jump into details, to know about how PGO works, you need a quick idea about how normal optimization in compilers are working, to know this, look at this sample:

int setArray(int a, int * array)
for (int x = 0; x array[x] = 0;

return x;


From this file the compiler knows nothing about the potential values for "a" (besides they must be of type int), nor does it know anything about the typical alignment of array.
This compiler/linker model is not particularly bad, but it misses two major opportunities for optimization: First, it doesn't exploit information that it could gain from analyzing all source files together; secondly it does not make any optimizations based upon expected/profiled behavior of the application. That's what WPO (Whole Program Optimization) and PGO (Profile Guided Optimization) are doing.

Before knowing PGO, let's know at first how traditional WPO in Visual C++ is working.

With Visual C++ 7.0 and beyond, including all recent versions of the Itanium® compiler, Visual C++ has supported a mechanism known as link-time code generation (LTCG).

LTCG is a technology that allows the compiler to effectively compile all the source files as a single translation unit. This is done in a two-step process:

1- The compiler compiles the source file and emits the result as an intermediate language (IL) into the generated .obj file rather than a standard object file. It's worth noting that this IL is not the same thing as MSIL (which is used by the Microsoft® .NET Framework).

2- When the linker is invoked with /LTCG switch, the linker actually invokes the backend to compile all the code compiled with WPO. All of the IL from the WPO .obj files are aggregated and a call graph of the complete program can be generated. From this the compiler backend and linker compiles the whole-program and links it into an executable image.

Now with WPO, the compiler knew all about the structure of the whole program, and so will be more effective certain types of optimizations.
For example, when doing traditional compilation/linking, the compiler could not inline a function from source file foo.cpp to source file bar.cpp. When compiling bar.cpp, the compiler does not have any info about foo.cpp. With WPO the compiler now has both bar.cpp and foo.cpp (in IL form) available to it, and can make optimizations that ordinarily would not be possible (like cross translation unit inlining).

To compile your program using LTCG, first you compile your program using whole program optimization switch: /GL
After that link it using /LTCG switch.

Now your generated executable is always faster, although it needs more memory and time to compile using this switch, but the final output deserves these.

But what if you want more optimization?!
It's now PGO turn.

Now you gained a bit performance using WPO through /LTCG switch, but you can gain additional performance which will be very significant using PGO in addition to LTCG.
The idea of how PGO is working is simple, you just run your application several times, and every time a profile for your application is created which is containing all the info about how many times each function is executed, and about the most used parts of your code, and then you use it after that to re-build your application based on this profiles.
The whole process is done in 3 main stages:

1- Compile into instrumented code (first compilation phase).

2- Train instrumented code (profiles generation phase).

3- Re-compile into optimized code (based on generated profiles).

And here you're a graphic representation for how the whole process looks like:

Now to pass through these 3 stages:

1- Compiling instrumented code:

The first phase is to instrument the code, to do this, you first compile the source files with WPO (/GL). After this take all of the source files from the application and link them with the /LTCG:PGINSTRUMENT switch (this can abbreviated as /LTCG:PGI). Note that not all files need to be compiled as /GL for PGO to work on the application as a whole. PGO will instrument those files compiled with /GL and won't instrument those that aren't.

The instrument of you code means putting several probes inside your code, there're two main types of probes, those for collecting flow information and those for collecting value information.
The result of linking /LTCG:PGI will be an executable or DLL and a PGO database file (.PGD). By default the PGD file takes the name of the generated executable, but the user can specify the name of the PGD file when linking with the /PGD:filename linker option.

2- Training of instrumented code:

Now to train your code and generate well profiles that really reflect the usage of your application, you run your application several times with scenarios that reflect their usage in real life, after every scenario a PGO count file (.PGC) is generated and takes the name of the .PGD file with numbers reflecting the scenario number.

3- Re-Compile the Optimized code:

The last step is to re-compile your application using the generated profiles through the different scenarios you made, this time when you link you application you use the switch: /LTCG:PGOPTIMIZE or /LTCG:PGO which will use the generated profiles to create the optimized application.

Now we knew in brief how to use PGO, but the most important thing is to know how PGO could help optimizing applications?
And this is the next section.

There are several things PGO can help in the applications optimization, which are:

1- Inlining:

As described earlier, WPO gives the application the ability to find more inlining opportunities. With PGO this is supplemented with additional information to help make this determination. For example, examine the call graph in Figures 2, 3, and 4 below.
In Figure 2. we see that a, foo, and bat all call bar, which in turn calls baz.

Figure 2. The original call graph of a program

Figure 3. The measured call frequencies, obtained with PGO

Figure 4. The optimized call-graph based on the profile obtained in Figure 3

2- Partial Inlining:

Next is an optimization that is at least partially familiar to most programmers. In many hot functions, there exist paths of code within the function that are not so hot; some are downright cold. In Figure 5 below, we will inline the purple sections of code, but not the blue.

Figure 5. A control flow graph, where the purple nodes get inlined, while the blue node does not

3- Cold Code Separation:

Code blocks that are not called during profiling, cold code, are moved to the end of the set of sections. Thus pages in the working set usually consist of instructions that will be executed, according to the profile information.

Figure 6. Control flow graph showing how the optimized layout moves basic blocks together that are used more often, and cold basic blocks further away.

4- Size/Speed Optimization:

Functions that are called more often can be optimized for speed while those that are called less frequently get optimized for size. This tends to be the right tradeoff.

5- Block Layout:

In this optimization, we form the hottest paths through a function, and lay them out such that hot paths are spatially located closer together. This can increase the utilization of the instruction cache and decrease the working set size and number of pages used.

6- Virtual Call Speculation:

Virtual calls can be expensive due to the jumping through the vtable to invoke method. With PGO, the compiler can speculate at the call site of a virtual call and inline the method of the speculated object into the virtual call site; the data to make this decision is gathered with the instrumented application. In the optimized code, the guard around the inlined function is a check to ensure that the type of the speculated object matches the derived object.

The following pseudocode shows a base class, two derived classes, and a function invoking a virtual function:

class Base

virtual void call();
class Foo:Base
void call();
class Bar:Base
...void call();
// This is the Func function before PGO has optimized it.
void Func(Base *A)
... A->call();

The code below shows the result of optimizing the above code, given that the dynamic type of "A" is almost always Foo.

// This is the Func function call after PGO has optimized it.
void Func(Base *A){
while(true) {
if(type(A) == Foo:Base) {
// inline of A->call();

4- Changes in compiler switches:

You can find them all here:
Last but not least, I forgot to mention that they had added some pre-processing directive to enable on fly distributed-processing for your code when you have more that one processor running on the machine which is running your application :)
Next time I'll be talking about additions in C# Language, so stay tight

Catch you later.....

Wednesday, October 05, 2005

Microsoft Visual Studios 2005 Team System, Episode II (Microsoft Visual C++ 2005 new Features Part A)

Now it's the time for the first technical article, it'll be about the new features added inside Microsoft Visual C++ Whidbey, of course it won't be a complete guide for those searching for every thing new (they can refer to C++ language specification), but Iam only listing here the new amazing features which are added to Microsoft Visual C++.

The new additions for Visual C++ are categorized into 3 main categories:

1- Additions to the core language compiler.
2- Additions for giving the applications more security.
3- Additions for optimizing the generated applications.
4- Changes in compiler switches.

We'll talk about each of these sections in more detail now.

1- Additions to the core language compiler:

During last several years, C++ compiler wasn't following the pure standard rules, in other words, Microsoft Visual C++ compiler till version 2003, was not following the standard C++ language and it wasn't conformant, it was accepting things that mustn't be accepted and was refusing things that mustn't be refused, and so when some body is trying to compiler some code from Unix or Linux on MS VC++ compiler, he'll usually get tons of compilation errors.

This problem had been solved completely, now VC++ compiler is more standard than any compiler (it's about 98% following standard rules), it's more standard than Intel's compiler and gcc, and so, now you can easily import Unix and Linux code and libraries and build them easily without any problems or errors, but you are supposed to get some errors if you compile your old code, and this will be the case only if your old code is not following the standard rules.

2- Additions for giving the applications more security:

Visual C++ 2005 adds a lot of options to make you sure that you're shipping a secure application and makes it passes through many levels of checks, I'll take the example of buffer overrun through this article to make it clear for every body, the first addition to support this, or to say the first level, is making a lot of changes in C and C++ libraries, every function which is dealing with strings or character pointers or any function which may lead to buffer overrun and such security vulnerabilities, is having a new version from it to secure your application, as example, imagine this simple application which will show you the buffer overrun vulnerability through stack overrun from writing secure code great book:

#include "stdio.h"
#include "string.h"

void foo(const char * input)
char buf[10];
//What? No extra arguments supplied to printf?
//It's a cheap trick to view the stack 8-)
//We'll see the trick again when we look at format strings.
printf("My stack looks like:\n%p\n%p\n%p\n%p\n%p\n% p\n\n");

//Pass the user input straight to secure code public enemy #1
printf("Now the stack looks like: \n%p\n%p\n%p\n%p\n%p\n% p\n\n");

void bar(void)
printf("Augh! I've been hacked!\n");

int main(int argc, char * argv[])
//Blatant cheating to make life easier on myself
printf("Address of foo = %p\n",foo);
printf("Address of bat = %p\n",bar);
if(argc != 2)
printf("Please supply a string as an argument!\n");
return -1;
return 0;

Now let's try to show how we could make the overrun happens, first let's try to run it in normal mode:

D:\Secureco2\Chapter05>StackOverrun.exe Hello
Address of foo = 00401000
Address of bar = 00401045
My stack looks like:
0040108A <-- We want to overwrite the return address for foo. 00410EDE

Now the stack looks like:
6C6C6548 <-- You can see where "Hello" was copied in.

Now let's try another input:

D:\Secureco2\Chapter05>StackOverrun.exe ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
Address of foo = 00401000
Address of bar = 00401045
My stack looks like:

Now the stack looks like:
54535251 <-- Return address has changed to this number.

We'll get now an error message telling us that we're trying to execute instruction at 0x54535251.
And as we see 0x54 is the code for the letter T, so if we tried this time:

D:\Secureco2\Chapter05>StackOverrun.exe ABCDEFGHIJKLMNOPQRS
Address of foo = 00401000
Address of bar = 00401045
My stack looks like:

Now the stack looks like:
00535251 <-- Return address has changed to this number.

Now we got it, by changing the user input we're able to manipulate where the next instruction to be executed, so if we could send 0x45, 0x10, 0x40 instead of QRS, we could get bar to execute, but how we could pass these parameters and 0x10 is not even printable? We'll create a perl script (or you could create another program which passes the following input to the buffer overrun exe):

$arg = "ABCDEFGHIJKLMNOP"."\x45\x10\x40";
$cmd = "StackOverrun ".$arg;
system ($cmd);

Then run it:

Address of foo = 00401000
Address of bar = 00401045
My stack looks like:

Now the stack looks like:

Augh! I've been hacked!

Now we knew how it could occur, now how Visual Studio has solved this problem?!

The first level is to provide the strsafe versions for strcpy and such functions, which gives another parameter which is to add the size of the buffer, when the developer is using the normal dangerous versions, the compiler will give him a warning of having the probability of exporting vulnerable code.

That looks cool, but what if the developer had committed a mistake and provided a wrong value for the buffer?!

Now we come to the second level, at execution time (this is the thing Iam not well remembering now), as you see it's all about overriding some values on the stack, the compiler will make many things, the one I am remembering now is the shadow copy of the stack and when it's trying to return will compare the old with the new and then determine if someone has made any thing over the stack or not, I am really not remembering the exact actions, so no body asks me how it's done exactly :D, but whenever I remember or find any resource on the web which is discussing how they made it, I'll put it here immediately :)

I think it's really enough for today, next time I'll resume the new additions in VC++ as I am tired now from writing all these stuff

Catch you later.....

Tuesday, October 04, 2005

Microsoft Visual Studios 2005 Team System, Episode I (Introduction)

As I mentioned before, I'll switch my blog mode to talk in some technical stuff, I'll start here with Microsoft Visual Studio 2005 Team System, then Microsoft Windows Vista, then finally my beloved product, Microsoft SQL Server Yukon (I hope another series of articles will come after that, but that's all for now).

Before any thing, I'll divide my articles about the new version of visual studio into these parts:

1- New features in Visual C++ compiler.
2- New features in C# compiler and the new features in .Net framework.
3- The new addition over traditional Visual Studio Professional and Enterprise Editions which is the Team System.

Actually there're many new features inside the new Visual Studio version, which in my opinion will make it un-beatable when compared to many other editors, because now it's not intended to support programmers only, but also testers, managers, IT professional, system architects, all in one solution.

That's all what I can say now as a simple introduction for what I'll discuss in the following articles, the next article will talk about the new features and additions in Microsoft Visual C++ compiler,

Catch you later.....

People are asking why Microsoft (Benefits of working inside Microsoft)?!

During the last several days I got these questions several times: Why you're so happy because you're going to Microsoft?! And what's the difference between it and any company here like IBM Egypt, Sakhr or ITWorx?! And why you're still asking for it and you're supposed to have a personal project which if succeeded will bring you much much more money than that you'll get after working inside Microsoft?! To answer all these questions, I must list all benefits in points, but before this list, for me the most important reason that I DO LOVE MICROSOFT AND JUST WISH TO MAKE IT BETTER AND STRONGER, for other reasons which are related to mind rather than emotions, here you're the point, so stay tight because it'll be a bit long

A- Company directly related benefits as employee:

1- Effectiveness: you as employee inside are not treated as a new comer who has no right to talking about higher policies in the company and the software you're working in, on the contrary, since the first day you'll find yourself as important as any one there, people of higher positions there like managers ore listening so well to your comments about everything, as example you may give a comment about some sort of feature in your product in the first day and you may find that the team is working with your advice and it has really changed the feature according to your feedback, really amazing!!!

2- Role: knowing the fact that you're working in things every person in the world is using is sooo amazing, unlike many other companies here like those I mentioned before, Microsoft's product is widely used around the world, not only by normal users, also by IT professional, software developers, and business users, etc, so you'll find yourself sooo excited by working in a product which you may find your own family is using everyday, really amazing!!!!

3- Innovation: you have the chance to completely invent and create new things even they are looking mad, no one will come and tell you that the features in your mind can't be achieved because of the company size is still not that big compared with your ideas, in other words, as much as the size of your ideas and the speed of your expansion, Microsoft will be bigger :)

4- Experience: no need to mention this part, most of us had at least used a single product from Microsoft, but lets talk about software developers whom will be concerned with this point so much more than others, at least any of you (I mean software developers here) had used at least a single application or library or piece of code coming from Microsoft and see the amount of professionalism they are creating the software with, furthermore, I had met myself, many team members of many products, like SQL Server, Windows, Visual C++ compiler, in addition to tons of movies on channel 9 of MSDN, and I can prove it to you, that a single year here in Microsoft may be equal to 10 years or more in any other company in Egypt and even in any place in the world, this is because you won't spend your whole life working in only one part which is too small compared to the whole IT world and after 8 or 10 years, when asked about any thing new, you say I don't know!No, you may work today in SQL Server, several months later, may leave and join Windows Team, many months later, may leave to join VC++ team, Xbox team, and so on, so you're working in a very huge organization which is having one simple rule, as much as you wish to work in any field, you'll find it out there :)Although, Microsoft will give you the chance for Professional Development, in other words, Microsoft will pay you all the tuition fees for any courses, Masters, PhDs, or any advanced program for increasing your skills as long as you're taking such courses in things related to your job at Microsoft (I think more than 95% of IT related fields are related to Microsoft work).So your experience in both Scientific and Technical sides will be so huge compared with others in other companies.

5- Freedom: the most amazing part here in Microsoft is the freedom every employee has, I'll list you some of them, first of all and the most important point, no attendance, in other words there's no place for the dummy rule of coming everyday from X to Y and even more, you're not supposed to come anytime but forced to come over certain interval of time (like Harf and ITWorx), and more than this, you're not forced to stay for X hours, you come and leave whenever you want as long as you're doing your job fine and are meeting your deadlines well, also you're free to Blog within Microsoft, free to work and to have another job even related to IT (as long as it's not affecting your work with Microsoft), and so they are not making things like here in Egypt as you sign tons of papers stating that you're not allowed to work in any thing (related or not related to IT) through your job, also after leaving it, you can't work in many fields (some companies extended it to whole IT fields) after leaving the company with several year, nothing like that, also, no one even your manager will force you to do something you're not convinced with, if they asked you to do something you're not convinced with, you'll sit together and talk, and he may find that you're right and he's wrong, and he will state this fact very bravely (he won't tell himself that I am the manager and he's still a new employee so I have more experience than him and so I must be right and he must be wrong), Microsoft Policy as Steve Palmer said (Microsoft's CEO) is Developers Developers Developers, so the developer is the main building block out there, and he's the most important part, so he must be very satisfied by working inside Microsoft.

6- Trust: There's no over-control rules like many companies here in Egypt, in other words, no rules that preventing you from accessing tons of sites, or sending emails within the company or upload files, or connect to messenger service or get your laptop with you inside the company, nothing like that, even more, you can take the code offline to complete it at home (even not only your code!), so the idea that you'll feel the amount of trust the company is giving you (with code which everybody is believing that it worth more than any other code in this country!!) and this will give you the happiness and making you very faithful to the company, also you could access your work and Microsoft's Intranet from anywhere in the world through your blue card within your PC or laptop ;)

7- Internal Environment and Employees Care: I hadn't seen any company all over the world which is caring about its employees to this extend!!Starting from normal free soda and juices all over the place till the health clubs!!!You as an employee inside Microsoft, has tons of benefits, I'll list the things I remember:

1- Health Club: This is known for everybody from its name.
2- Tons of play yards inside the company.
3- Tons of Xboxes, Arcade Video Game, Pool tables, Baby Foot, massage chairs, and many many things around every office which are increasing the fun factor inside the company.
4- Has a separate office (or at max sharing it with one or two members, but in most cases a separate one), no cubicles any more.
5- Tons of green spaces around you.
6- Vacation days: once starting, you have 21 vacation day which will be increased every interval (2 years as I remember).
7- Paid Holidays: Eight US holidays plus two personal holidays to take at your leisure.
8- Relocation: Nearly everything (nearly here means every thing except some rare things like Piano and such things) even furniture, will be relocated by them through some sort of transportation company, your ticket, a starting amount of money (outside your official salary) and many things related to your relocation to Microsoft.
9- P.R.I.M.E Discounts: discounts on many thing, including automotive, computers, restaurants and many thing.

10- Hour Health Line: Available 24/7, the Health Line provides useful, easy-to-understand health information that can help you make appropriate healthcare decisions.
11- Shipping Events: Huge trips after the shipping of each product, as example VC++ team is planning to go to Hawaii when they Ship Visual Studio CodeName Hawaii, so it's usually things like that :)
12- Tons of free stuff and discount on tons of other stuff.
13- Free drinks (the most fun part :P ), which are including soda, juices, soft drinks, etc.I can't remember more than these, but I am sure there were more items than these.

14- Free buses with Wi-Fi
15- On-site showers and lockers.
16- Flexpass: which you can use to ride all these selections for free: buses, trains, metro, even get a free car with free gas if you're more than 2 using the car!

8- People: people here in Microsoft are sooo great and friendly, I had dealt or talked to more than 20 engineers working inside Microsoft, in addition to many HR employees, all of them are great, dealing with you like a dear friend whom you know well since years, really it's so great to find people like that.

9- Management: there's no need to talk about management power inside Microsoft, it's all about management which makes Microsoft reaches this level of professionalism and experience.

10- Professionalism: Also no mention for how much professional Microsoft is, every thing is well arranged, every thing is amazing inside, side by side with great freedom which makes every thing very very very amazing.

11- Diversity: Iam a strong believer in the value of diversity in increasing both technical and community sides of any person, inside Microsoft you'll be working with people from very different cultures, different countries, different languages, and different ways for solving a specific problem, creating you a huge variety of cultures which will affect directly the way you think and the way you solve any problem.

12- Additional Degrees: What about making masters or PhD?
What if you want to make additional degree in your career?
In Microsoft, they won't only put your studying hours inside your working hours (which means if you're studying 20 hours per week, then now you'll work 20 hours only per week and the other 20 are paid for study), but also they will pay all expenses including books, materials, labs, etc, have you ever seen any thing like that?!!!

13- Finances: Very good and competitive package compared with all big companies in USA (of course we can't even think about comparing Microsoft's salary with salaries of any company inside Egypt), Bonus awards, Merit increases, furthermore, Stock awards, in which employee may be eligible to earn stock awards in the company (actually once you started you've stock awards waiting for you, in addition to awards every given interval), not only these.There're investment programs which will help you to secure your financial future, from there programs:

1- Saving Plus 401(k) plan: 401(k) savings plan lets you defer pre-tax income up to 50 percent of your eligible compensation (up to the IRS maximum). Microsoft matches 50 cents on every dollar you defer pre-tax up to a pre-tax contribution rate of 6 percent, excluding catch-up contributions, for a maximum matching contribution of 3 percent of your eligible compensation. You can also contribute up to 7 percent of your eligible compensation on an after-tax basis.

2- Employee Stock Purchase Plan: during any quarterly purchase period, employees may purchase stock at a 10 percent discount off the market price.

3- Goal Planner Investment Program: this program helps you save money from your net pay ― after taxes ― for anticipated future expenses such as college tuition (although in most cases, it's covered completely by Microsoft without any additional fees on you) or the purchase of a home. The program provides a personal discount brokerage account, direct investment deposits through payroll deduction, and financial planning tools that help you make informed decisions. You may enroll during any month.

I wish I hadn't forgotten any thing in this part.

B- Company in-directly related benefits:

Being at Redmond inside Washington, gives you tons of options you will like very much:

1- Redmond City and Quiet Life: Redmond city is sooo quiet, a lot of green spaces, very well arranged, and overall, it's a very perfect place to live within, but other people may ask, what if I'd like to go shopping in a huge city?
Or even want to make ice skating?
Or to swim or to camp?

This will be a simple question, to go to a huge city, just head west, a few miles (exactly 13 miles) you'll find yourself inside Seattle, were a lot of lights exist, and the true meaning of a city with very high building will be available :)

To make ice skating, head north, you'll find a ton of snow out there :)Wanna to camp? Just you'll find tons of forests around you, because northwest is rich with forests and mountains for camping and hiking and rivers and lakes for fishing, boating, kayaking and windsurfing :)
Also minutes from Microsoft, you'll find many Lakes and also heading west you'll find a lot of places to enjoy swimming :)

2- Being inside US, will give you a lot of options of buying cars or houses or any thing with much easy financial options.

And Finally take a look on some photos of MS (Most of these photos are more than 8 years old), it contains a satellite image for building 35, my work place and the SQL Server building:

Also you can see Steven Sinofsky's article on the same subject on:

Mmm, I don't remember what else, but there're many more options (another personal option at least of loving this company so much even before joining it or even before the wish of joining it), I'll try to update this page as soon as I remember any thing, but till this moment, stay updated with my blog, because I am gonna switch the mode of the blog a bit and I'll jump into some technical posts concerning with Microsoft's new technologies and product like Visual Studio Whidbey, Windows Vista, and my beloved SQL Server Yukon. So stay connected :)

Catch you later.....