The one dynamic language I think Microsoft needs to embrace in .net…

So a few days ago, Jimmy Schementi announced the death of IronRuby. Oh, sorry, “IronRuby isn’t dead, it’s just back in the hands of the community” which is essentially the same.

Now, while there may be a chance for IronRuby to survive, I personally think it’s not something that Microsoft should do, so I think it makes sense for them to kill it off internally. Same for IronPython. I think the DLR is a great addition to .net though, and I think there is a far better language already available.


Many of us perceive JavaScript as a Browser-only language that is hampered by different implementations in different Browsers (textContent vs. innerText anyone?), something which is being addressed through the use of frameworks like jQuery.

But think it one step further: How many languages do you need to write a Web Application? At least two: JavaScript and whatever backend language you use, for example C#, Java, Ruby or PHP. How do you write Form Validation? You write separate Code for the Client Side and for the Server Side so that users get instant feedback without being able to compromise the system by turning JavaScript off. This is stupid and a severe violation of DRY. Also there are subtle differences between the Code, for example because JavaScript’s RegEx Engine works slightly different than the .net one.

.net is at it’s core a language-independent technology that doesn’t only support but encourage using multiple languages. Sure, there are only 3-4 really supported languages which are rarely mixed (Some people mix C++/CLI with C# or for some COM stuff, or F# with C# for financial/statistic stuff) and some languages that have some limited support (Boo is my favorite in this category).

So why not do what’s logical and embrace JavaScript as a Server-Side technology? Node.js arrived recently and showed it’s possible. Microsoft already somewhat supports JavaScript in Visual Studio (although the experience is far less than stellar) and they even had their own bastard child in form of

There is a big discussion whether or not C# is a good language to write Web Applications in. People point at Cucumber and talk about how great Ruby works with the Web while C# feels like a chore because of it’s static typing, verbose Syntax and need for IoC Containers to do Unit Testing properly. Other people point at the insecurity of dynamic languages, about the lack of compiler errors, about the confusion created by not having to declare variables which leads to subtle bugs like `$total = 0; foreach(item in items) $totel += item.price`.

I say: Use both. Use C# for your backend code, for your Business Classes. Get Compiler Errors when you screw up. Make sure everything needs to be explicitly casted to whatever it has to be and that all variables have to be defined officially before use. For the frontend, use JavaScript. Create your Views and View Models like you would create them in the browser, through DOM Manipulation. Write and maintain your verification code exactly once, in one language, browser and server side. Feel free to whatever crazy manipulation you need to do without having to declare and cast tons of variables. If you screw up, it’s “only” your Views, not your data structure because that’s C# code.

Utopia? Maybe. JavaScript is not without it’s faults and it may not be as elegant as Ruby in places. People would have to learn two languages, and people may ask “Why should we switch to an insecure language if C# served us well for years?” – well, the latter people are usually the ones who don’t think they need Unit Testing and believe that WebForms is a perfectly good technology, so let them continue to use it and let the rest of us move forward to face the challenges of 2010 and beyond.

Customers want better apps. They want AJAX, they want snappy, cool looking UI. The Browser market is not a “Make sure it runs in IE and doesn’t suck in Netscape 4.78” market anymore. We need to create cool apps, and we need to run them on Internet Explorer, Firefox, Safari on OS X, Safari on iPhone and Android. Our Web Apps need to do more in less time.

And Microsoft is in a great position because they have the foundation already built. Make Visual Studio a kick-ass JavaScript Development tool and bring it to the server side. Give us great debugging because even with FireBug and the IE Development Tools, it still sucks. Look what Node.js did. Look what you are doing with Internet Explorer 9’s JS Engine. Look what you have with Active Scripting and look what you did with

It’s incredible to see that Microsoft has all this technology already lying around and that no one had the idea to just combine them all together for Sure, Internet Explorer got a lot of (well deserved) crap for issues in it’s JavaScript implementation, but IE9’s previews look really promising.

Because let’s face it: Any .net Language not supported by Microsoft in Visual Studio is doomed.

64-Bit Bitfield Cheat Sheet

Just as a cheat sheet for me, a 64-Bit Bitfield in Dec and Hex.

Bit Int Hex
1 1 0x1
2 2 0x2
3 4 0x4
4 8 0x8
5 16 0x10
6 32 0x20
7 64 0x40
8 128 0x80
9 256 0x100
10 512 0x200
11 1024 0x400
12 2048 0x800
13 4096 0x1000
14 8192 0x2000
15 16384 0x4000
16 32768 0x8000
17 65536 0x10000
18 131072 0x20000
19 262144 0x40000
20 524288 0x80000
21 1048576 0x100000
22 2097152 0x200000
23 4194304 0x400000
24 8388608 0x800000
25 16777216 0x1000000
26 33554432 0x2000000
27 67108864 0x4000000
28 134217728 0x8000000
29 268435456 0x10000000
30 536870912 0x20000000
31 1073741824 0x40000000
32 2147483648 0x80000000
33 4294967296 0x100000000
34 8589934592 0x200000000
35 17179869184 0x400000000
36 34359738368 0x800000000
37 68719476736 0x1000000000
38 137438953472 0x2000000000
39 274877906944 0x4000000000
40 549755813888 0x8000000000
41 1099511627776 0x10000000000
42 2199023255552 0x20000000000
43 4398046511104 0x40000000000
44 8796093022208 0x80000000000
45 17592186044416 0x100000000000
46 35184372088832 0x200000000000
47 70368744177664 0x400000000000
48 140737488355328 0x800000000000
49 281474976710656 0x1000000000000
50 562949953421312 0x2000000000000
51 1125899906842624 0x4000000000000
52 2251799813685248 0x8000000000000
53 4503599627370496 0x10000000000000
54 9007199254740992 0x20000000000000
55 18014398509481984 0x40000000000000
56 36028797018963968 0x80000000000000
57 72057594037927936 0x100000000000000
58 144115188075855872 0x200000000000000
59 288230376151711744 0x400000000000000
60 576460752303423488 0x800000000000000
61 1152921504606846976 0x1000000000000000
62 2305843009213693952 0x2000000000000000
63 4611686018427387904 0x4000000000000000
64 9223372036854775808 0x8000000000000000

Checking if a bit is set:

// AND: Only return 1 if both bits are 1
// 0011 & 0100 = 0000
// 0111 & 0100 = 0100
isSet = (value & 0x4) == 0x4;
isSet = (value & 0x4) > 0;

Setting a bit:

// OR: If either operand is 1, return 1.
// 0011 | 0100 = 0111
newvalue = oldvalue | 0x4; // |=

Unsetting a bit:

// NOT: Invert the Bits
// ~0100 = 1011
// AND: Return 1 if both bits are 1
// 0011 & 1011 = 0011
// 0111 & 1011 = 0011
newvalue = oldvalue & (~0x4) // &= ~0x4;

Toggling a bit:

// XOR: If both bits are equal, return 0
// 0111 ^ 0100 = 0011
// 0011 ^ 0100 = 0111
newvalue = oldvalue ^ 0x4; // ^=