All entries for May 2006

May 27, 2006

Download WMP Podcast Plugin

Follow-up to Updated Podcasts in Media Player Plugin from codeMonkey.Weblog();

You can now download the plug–in. It's still in beta and comes with no guarantees, so use at your own risk. If you find any bugs, etc please let me know.


You must be using IE 7 (Beta 2) for this to work. The plug–in uses the new feed subscription feature of IE 7 to pull in podcasts. Subscribe to feeds within IE 7 and make sure you check the "Download attached files" box – this will make it download podcasts.

May 24, 2006

Light weight threading

I'm experimenting with light weight threads in Boo. I have an AST attribute that duplicates a method and inserts "yield" statements between each statement. This makes the method into an iterator that can be stepped through. I have a scheduler class that takes a list of methods and effectively runs them concurrently – but without all the heavy weight OS context switching.

Here is sample output from a demo program:

2 Processors
3000 Threads
Light weight threads:
Done in 45 milliseconds
.NET threads:
Done in 50236 milliseconds

About 1000 times faster!!

Note that I have two processors so the light weight scheduler actually creates two OS threads on which to run the light weight ones. This makes maximum use of my machine!

The code being run by the thread is in this class:

class Dog():
energy as int

def Eat():

def Bark():

def Live():
for i in range(100):
So basically I'm saying create 3000 dogs and run them all at once! Normal threads crawl due to the huge amount context switching. Light weight threads work like a dream :)

May 19, 2006

Specter Screencast

I have created a 15 minute screen cast demoing some of Specter's features. In the screen cast I create a simple specification of an object, using a behavior driven development style.

Play the demo (requires Macromedia Flash to be installed)

May 18, 2006

WMP Plug–in Library Source

Here's the source for my Windows Media Player plug–in library. You can use it to create your own plug–ins.


As usual, no warranties come with the code – do what you like with it. If you do make something cool, do let me know ;)

May 17, 2006

AssignFields Macro

Another handy Boo macro:
class AssignFieldsMacro(AbstractAstMacro):

override def Expand(macro as MacroStatement):
ctor = (macro.ParentNode.ParentNode as Constructor)
b = Block()
for param in ctor.Parameters:
assign = BinaryExpression(
ReferenceExpression("_" + param.Name),
return b
This lets me do this:
class Foo:

_name as string
_age as int
_food as bool

def constructor(name as string, age as int, food as bool):
# inserts:
# _name = name
# _age = age
# _food = food

f = Foo("hello", 42, true)
print f.Name
print f.Age
print f.Food
certainly saves a bit of typing!

Google Trend: C# vs Java

Check out Google Trends ! Very cool way to see what people are searching for…
This is C# (in blue) and Java (in red):
C# vs Java

May 16, 2006

RaiseEvent macro

— Update —
I Just found out Boo already does this!! When raising an event by:
Done(self, EventArgs.Empty)
the compiler knows it's an event (not a method) and puts in the null check, etc, on your behalf – so the macro I wrote is not needed. Ah well – was good practice I suppose :)
— End Update —

This is a handy macro I cooked up to generate the boring event raising code. Basically it looks like VB.NET's RaiseEvent keyword.

namespace Equin.Bootilities

import System
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast

class RaiseEventMacro(AbstractAstMacro):

override def Expand(macro as MacroStatement):
assert macro.Arguments.Count >= 1
assert macro.Arguments[0] isa MethodInvocationExpression

method = macro.Arguments[0] as MethodInvocationExpression

# create event reference
evt = MemberReferenceExpression(SelfLiteralExpression(), method.Target.ToCodeString())

# prototype code for event invocation
code as IfStatement = ast:
if Thing is not null:

# change 'Thing' to actual event expression
be = code.Condition as BinaryExpression
be.Left = evt

mie = (code.TrueBlock.Statements[0] as ExpressionStatement).Expression as MethodInvocationExpression
(mie.Target as MemberReferenceExpression).Target = evt

# add arguments for the invoke
for re in method.Arguments:

return code
Sample usage:
class Foo:

event Done as EventHandler

def Test():
RaiseEvent Done(self, EventArgs.Empty)
# This creates the following
#if Done is not null:
# Done.Invoke(self, EventArgs.Empty)

f = Foo()
f.Done += { print "done" }

May 15, 2006

Specter Project

Writing about web page

SourceForge finally accepted my project proposal.

I'm waiting on the SVN migration to take affect – but the source will be online very soon I hope.

For now, you can read more on the website .

— Edit —
Source now available via SubVersion:

May 11, 2006

Boo AST Attribute Ideas

Here are some ideas I had for handy Boo AST (abstract syntax tree) attributes:
def Foo():
expands to
def Foo():
except ex:

Very handy for UI code that calls into business objects that may throw up exceptions. Not having to explicitly write the try…except block is a timesaver!


class MyForm:
btn = Button()

def ButtonClicked():
print "button clicked"
expands to
class MyForm:
btn = Button()

def constructor():
btn.Click += ButtonClicked

def ButtonClicked():
print "button clicked"
This allows the event hookup to appear on the handling method, rather than miles away in the constructor. This is great for UI code since it means u can delete a method and know there is not still a line of code else trying to point to it. (So basically is works like the VB.NET "handles" keyword.)

Updated Podcasts in Media Player Plugin

New screen shot of my PiMP (Podcasts in Media Player) plug–in. (Click for full screen view)
wmp plugin 2

I ditched the slow and ugly grid for a nicer custom item list view control. Un–played shows are indicated by an icon. Click play starts a show playing. Clicking "Show Notes" opens a window to read HTML show notes.

I want to add sync stuff next and also scan show notes for time codes (hh:mm) and then skip playback to those locations.

Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry


May 2006

Mo Tu We Th Fr Sa Su
Apr |  Today  | Jun
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31            


Blog archive

Not signed in
Sign in

Powered by BlogBuilder