Wednesday, September 17, 2008

jQuery

I've only been playing with it for a few days, but I *REALLY* like this framework. I also whole-heatedly recommend jQuery in Action to help you get up to speed.

#    Comments [0] |
 Tuesday, September 02, 2008

Initial Thoughts on Google Chrome

Cool! One of the things I love about the current tech environment is the amount of competition between all of the big companies. Competition is the only true driver of innovation. Both users and programmers are going to end up with better technology when all is said and done. Those years of browser stagnation seem like a distant memory now.

Another thing I found interesting in the Wikipedia entry on Google Chrome was the following:

The Gears team were considering a multithreaded browser (noting that a problem with existing web browser implementations was that they are inherently single-threaded) and Chrome implemented this concept with a multiprocessing architecture. A separate process is allocated to each task (eg tabs, plugins), as is the case with modern operating systems. This prevents tasks from interfering with each other which is good for both security and stability; an attacker successfully gaining access to one application does not give them access to all and failure in one application results in a Sad Tab screen of death not unlike the well-known Sad Mac. This strategy exacts a fixed per-process cost up front but results in less memory bloat overall as fragmentation is confined to each process and no longer results in further memory allocations.

Interesting. What this means (on Windows at least) is that when you start up Google Chrome you get two processes:



I can only assume that one instance is for the Chrome host process and one instance is for the initial tab. When you create a new tab and navigate to a web page you will see at least one new instance of chrome.exe. There may be more than one process for the tab depending on the number of plugins on the page.  

After creating a few additional Chrome tabs my 'Windows Task Manager' looks like this:



For a "process hawk" like me this will take a some getting used to!

#    Comments [0] |
 Thursday, March 06, 2008

Google Maps in IE8 Beta1: BUSTED

So this is Microsoft's strategy to defeat Google. Yikes!

UPDATE: 3/19/2008 - Joel Spolsky explains the "big picture" of what's going on here in his Martian Headsets article.

#    Comments [0] |
 Thursday, January 03, 2008

Using Volta from the Command Line

While it’s unlikely that you would ever want to invoke the Volta compiler directly, using it does provide some insight into how Volta works.

Let’s say that you have an existing assembly named BoringObjects.dll.  BoringObjects.dll contains one class named Person.



To do a Volta conversion of this assembly from MSIL to JavaScript execute the following command from the console window. NOTE: you will need "C:\Program Files\Microsoft Live Labs Volta" in your path.

> volta BoringObjects.dll /out:JSOutput

The only argument of interest is /out:JSOutput.  This is the directory that the Volta compiler will write the JavaScript files to.

If we look under our specified output directory we notice that Volta has created a directory that corresponds to the assembly name.  Under that directory there are three items:

[Types] (directory)
assembly.js
typeMapping.js

Under the Types directory there is one file "tA.js" which corresponds to the lone Person class in our original assembly.  If you use /d (debug) option the file will be named "type_0__Person.js" and the JavaScript code will be nicely formatted.

It’s interesting to note that this same structure is seen in "C:\Program Files\Microsoft Live Labs Volta\Cache".  In that directory you will find that some core .NET assemblies and the Volta libraries have been converted to JavaScript. This step is apparently part of the installation process.

#    Comments [0] |
 Friday, December 14, 2007

The Three “R”s of Volta

A prevalent theme in the Volta documentation is the concept of the three “R”s. These three principles are at the heart of what Volta attempts to provide for developers.  They are retargeting, remodulating, and refactoring.

Retargeting

To me this is the coolest aspect of Volta and the feature that makes it a very interesting technology. At its core Volta is a compiler or more accurately a recompiler.  Instead of recompiling the source code Volta uses a technique called MSIL rewriting. This is what enables the developer to write client-side browser code in C#. Since all CLR languages compile to MSIL, Volta can use that as the common denominator. Volta is capable of MSIL to MSIL, and MSIL to JavaScript conversion.

Remodulating

Another goal of the Volta toolset is seamless cross-browser support. As the documentation states:

 Volta hides as many browser-specific differences as possible, but still allows developers to leverage the unique capabilities of particular browsers. Instead of targeting solely the intersection of browser capabilities, Volta targets the entire union, but makes the intersection browser-agnostic. This is browser remodulating.

Remodulating also deals with the debugging experience. Regardless of the browser platform developers will be stepping through their application code within Visual Studio. That's assuming of course that your target is either IE or FireFox which are the only browsers supported in the current release.

Refactoring

Volta refactoring is about enabling developers to create their applications while deferring decisions about what tier a particular component will run in. In my opinion this will be the most controversial feature of the toolset.  Larry O’Brien has some reservations about it:

This sounds like a bad idea to me. You can't refactor away the difference between an in-memory method call and an Internet message: one happens in nanoseconds and the other in milliseconds

I have some questions of my own about this. The docs claim that:

During development, all code runs in the client for ease of testing and debugging.

What are the implications of this? Not every .NET class is meant to run in a browser context. Does Volta offer any automatic guidance with regard to this? The notion of clicking a “Split Tiers” check box and decorating a class with a [RunAtOrigin] does seem implicitly powerful, I’m just curious to know where the model breaks down. I will try to answer these questions and others as I dig deeper into the framework.

#    Comments [0] |
 Wednesday, December 05, 2007

Volta



It's kind of ironic.  This morning I was seriously considering taking a look at the Google Web Toolkit.  This is despite the fact that GWT is targeted at Java developers, which I am not.  It's just that GWT seems like such a useful idea - I wanted to play with it a bit.

Luckily Microsoft has, apparently, decided to put out a framework that allows developers to build rich internet applications without having to do a ton of JavaScript coding.

It's called Volta and at first glance it seems pretty cool.

When I was doing a lot of work with ASP.NET AJAX last year, the idea of coding in a more productive language and environment than JavaScript kept coming up again and again.  There was Script# at the time, but I didn't get a chance to look into it as much as I would have liked.

This certainly seems like a great development.  Maybe this even brings .NET developers one step closer to what Joel Spolsky described a few month ago.

Now…on to the samples, tutorials, and docs!

#    Comments [0] |
 Sunday, December 02, 2007

SICP in C# 3.0 – Higher-Order Procedures



One of my favorite sections in SICP so far has been section 1.3 Formulating Abstractions with Higher-Order Procedures.  Higher-Order Procedures are procedures that deal with other procedures.  They can take a procedure as an argument and/or return a procedure as a result.

Though it is somewhat academic, I really like the example that Abelson and Sussman use in section 1.3.1 to explain the “procedures as arguments” scenario.  To illustrate this concept they implement summation using Scheme.  They implement a higher-order procedure called “sum” that takes two procedures and a range of numbers as arguments.  One procedure is used for computing the value that is added to the sum and the other is used to determine the next value to compute.  The Scheme code can be seen here.

It’s not as useful as map and reduce, but those are not discussed until Chapter 2.

As some of you may know C# 3.0 adds a whole slew of functional/dynamic features.  Whether this is an effort to keep up with the cool kids or merely a necessity for making LINQ work is not important to me.  What I’m curious to know is if the features make it easier to implement the concepts in SICP using C# 3.0.

Implementing “Sum” in C# 3.0

Following along with the example from SICP - let’s say that you have defined the following methods.



I decided to break with the book here and use iteration instead of recursion to make the code a little more digestible.

Common to each method is the idea of iterating over a range of numbers and adding the result of each computation to the total.  If we create a higher-order procedure called “Sum” to abstract out this behavior we can then redefine each method.

The “=>” and “Func” constructs come from the new Lambda expressions feature in C#.  Lambda expressions are a great new aspect of the language and they make implementing higher-order procedures a lot easier.  In this case the "term" and "next" arguments can be passed as Lambda expressions.

I had to cheat and do some casting shenanigans because the division operation in "PiSum()" brings floating point numbers into the mix, but I feel like this code does capture the essence of the original Scheme implementation.  Implementing "Sum" as a generic method might be a way to make the code more elegant.

If subverting the type system does not appeal to you, the following JavaScript implementation might be of interest.


JavaScript is more similar to Scheme (dynamic typing/first class functions) so it makes sense that the translation is smoother.

It turns out that there are other people interested in implementing SICP in different languages.  Chris Rathman has translated parts of SICP into 19 other languages.  One disturbing thing to note about Chris’s C# translation is that it doesn’t go beyond chapter 1.  Does that mean that it is not possible to implement the code from the rest of the book in C#? 

#    Comments [0] |
 Tuesday, November 27, 2007

Hail Darkon

A couple of weeks ago I decided that I needed a break from the stresses of daily office life.  I walked down to the company cafeteria and purchased a Big Kat from the vending machine.  A Big Kat is like a regular Kit Kat, but bigger.  It’s absolutely delicious.  Anyway, I looked down at an open copy of the Globe (or was it the Herald?) and saw something that caught my attention.  Apparently, IFC was going to be showing a documentary that night focusing on the topic of LARP.

LARP! I thought to myself.  Live Action Role Playing.  A bunch of geeks playing Lord of the Rings on a soccer field!  YES!!!  I have to see this.  The documentary was called Darkon and about five minutes into it I was scolding myself for taking such a narrow-minded view.  

One thing I should have realized about LARPers is that they take their game very seriously.  I admire how much work these folks put it into it.  Watching the interviews and hearing the reasons why they play was truly enlightening.

The larger theme of the movie is obviously the idea of escapism and fantasy.  Why do people feel the need to escape reality?  To what lengths will they go to maintain the fantasy?  Trying to answer these questions goes a long way in explaining why World of Warcraft and Second Life are so popular.  I find all this stuff fascinating. 

Aside from the thematic elements, Darkon is also an intriguing story with interesting characters (both real and imagined).  Different players come to the game for different reasons, but most are motivated by the desire to be something that they can’t be in real life.  I’m not going sugar coat it, at some points this a little uncomfortable to watch, but it doesn’t make it any less compelling.

As you might guess there are political struggles and ego clashes both inside and outside the confines of the game.  The film primarily focuses on the conflict between Skip Lipman (Bannor of Laconia) and Kenyon Wells (Lord Keldar).  A scene at the beginning of the film makes it clear that these two leaders are headed for a showdown. 

If you’ve ever been near an RPG or simply can relate to the need to escape every day life, I heartily recommend Darkon.

Hail Laconia! Hail Mordom! Hail Darkon!

#    Comments [0] |