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] |
 Monday, November 26, 2007

Bug - Half Life 2: Episode 2 (Orange Box PC)

I’ve really been enjoying the Orange Box so far.  Unfortunately, I’ve encountered an apparent bug in Half Life 2: Episode 2.  During “Chapter 2: Vortal Coil” the game will consistently crash at the same point.  The crash occurs after you escape from the guardian ant-lion by dropping into a corridor.  At the end of the corridor there is a medic sitting against the wall.  When you walk closer to the medic, the display will freeze and you will be dumped back into Windows.  You receive an error informing you that the “hl2.exe” process has crashed.  After doing some Google searches I was able to find a solution posted here and here.  The workaround is to basically shoot the web at the end of the passage, face the wall on the right, crouch, and then strafe until you get into the next room.  I followed these instructions and I was able to avoid the crash.  I love being a PC gamer!!!


#    Comments [0] |
 Saturday, November 24, 2007

ASP.NET and Spolsky’s Law of Leaky Abstractions

For reasons beyond my control I recently found myself developing in classic ASP.  After years of developing in ASP.NET this was obviously a little jarring.  However, what surprised me about the experience was that there were some things about classic ASP that I actually enjoyed.  Most notably I felt I had more control with classic ASP.  Nothing was in my way.  Things that should be simple were simple.  For a moment I imagined that this is what it must feel like to be a PHP developer. ;-) 

I wondered why I felt this way.  After all, the whole the whole point of ASP.NET is to save me from having to deal with “icky” HTML, JavaScript, and CSS…right?  I really like developing in ASP.NET.  I would take ASP.NET over classic ASP any day of the week (and twice on Sunday).  ASP.NET is certainly one of most thoughtfully designed and well implemented frameworks I have ever worked with.  Scott Guthrie is a genius and he has the patents to prove it.  However, I couldn’t ignore the fact that some things were a lot easier to accomplish in classic ASP.

I realized the unfortunate truth that there are some abstractions in ASP.NET (and all frameworks for that matter) that can transform into obstacles.  In order to use these abstractions you end up having to learn a lot about the internals of the framework.  I’m talking about Reflector. You have to codify assumptions about the underlying technologies into your application.  In other words, the abstraction leaks.  I borrow this term from Joel Spolsky’s Law of Leaky Abstractions.  I think that the small sense of empowerment I was feeling when developing in classic ASP came from the fact that I wasn’t forced to dig too deep into, or worse, code around the framework in order to get the job done.  There was no framework. 

Another, even more heretical thought occurred to me during this process.  I wondered if code-behind is always necessary. Is it always essential to separate code and markup?   If you simply replaced VBScript with C# and gave yourself a set of libraries as rich as the BCL, would combining code and markup be more palatable or even more productive in some scenarios?  Can some aspects of ASP.NET be abandoned entirely?  I’m not sure, but I’m now a little more inclined to find out.

#    Comments [0] |
 Wednesday, November 21, 2007

2006 Beantown .NET Ajax Slides

Here are the slides from my 2006 Beantown .NET talk on ASP.NET Ajax.

beantown_ajax.ppt (636.5 KB)
#    Comments [0] |
 Monday, November 19, 2007

SICP



Every once in a while I find myself reading a book that makes me feel stupid. As I try to internalize the prose I can’t help but feel a strong sense of regret for not being more adequately prepared.

Then I learn that the book has long been the basis for an “Intro to Programming” course at some college. Did you say intro to programming!? This is usually the part where I start to feel a strong sense of inferiority. :-(

Is the feeling of inferiority enough to make me want to put the book down? Hell no. If anything I’m finding SICP to be one of the most compelling computer books I have ever read. Like the Scheme language itself, SICP is incredibly dense. No reading on autopilot here, folks. You need to be paying attention or you’re going to get nothing out of it. The code examples draw almost exclusively from math. In the first chapter alone the following mathematical concepts are used to “help” teach the reader about computer programming (in general) and Scheme (in particular):

The other thing that seems strange at first is that Scheme uses recursion for nearly all processing. I’ve only completed the first chapter, but I have yet to see a “for” or a “while” construct in any of the code.

I know that that some fellow .NET developers might ask “Why are you wasting your time with that?” or “Why aren’t you spending your time learning about Silverlight?” Well I couldn’t really say for sure. I’m a big fan of Paul Graham’s essays, so those are certainly what motivated me to have a look at a Lisp dialect. What’s keeping my interest is the richness and depth of the content. There’s just so much there.

I plan to post more about SICP as I wade my way through it over the next several weeks… or months. I’m going to take my time and savor every head scratching moment. 

If you are Java or C# programmer who is looking for something to expand your mind, you should certainly have a look.


#    Comments [2] |
 Tuesday, November 13, 2007

Resurrection

After being dormant for years my blog is finally being resurrected. Wish me luck!
#    Comments [1] |