[You know I hate making announcements... It seems like my expectations are always higher than what actually happens. I've announced stuff before that I thought was somewhat impressive -- maybe not though-- with like zero interest]
This weekend I created a new project over at CodePlex called "DLRScript." I put this ominous description - "DLRScript is a SilverLight 2.0 sample using the DLR. It is based on the DLRConsole found in the sample in the SilverLight 2.0 SDK, but with a new advanced twist (check back here for more info later... I want to be the first to do this which is why I'm mum on the subject) "
Background
So let me tell you the background. I recently was pondering the new upcoming beta of SilverLight 2.0 (something I have been waiting impatiently for a year). I started thinking about some of my past demos and playing around with it. You see I have been using it to get rid of JavaScript altogether and replace JS with C#. I contemplated creating a project for that functionality a few months back, but with SilverLight 2.0 so far away it didn't seem like a great idea at the time. I also have begun recently playing with some of the DLR languages. I have to say that I really like Python (I wish I was better with it), and Ruby is very intriguing to me as well.
I started thinking about how with SilverLight 2.0 we could actually add new languages that could be put into a script tag. So I built it..
A picture is worth 1,000 words
Here's whit it looks like-
1: <script type="DLRPython"> 1:
2: def clickHandler():
3: DomHelper.alert("Hello from Python")
4: eh = DomHelper.createEventHandler("clickHandler")
5: document.GetElementByID("clickMe").AttachEvent("onclick", eh)
</script>
If you look closely I have a custom object called DomHelper. The reason that exists is that I am currently having problems adding namespaces (but I can easily add variables to the script environment). DomHelper knows how to do a couple things. Send Alerts, and Create An Event Handler from a method name (there are others, but I need to work on them).
That "document" variable is not the standard DOM document, but a reference to the SilverLight environment's HtmlPage.Document. Right now I am having problems with setting the property values of DOM Element (I will be fixing that soon).
Why did you do this (JavaScript is fine)?
I'll blame George Tsiokos again (he was the one who told me he didn't want to have to extensively know JavaScript). I personally don't like that we web developers need to be fluent in a bunch of things : HTML, Language on the Server (be it C#, PHP, python, or Ruby), CSS, and JavaScript. I know that the markup stuff is fairly simple for most of us... it's having to be fluent in 2 languages is what stinks. So my goal is for a Ruby on the Rails developer to be able to use Ruby both client-side and server-side.
Some caveats (it's an alpha what do you want?)
- You need to have the SilverLight 1.1 Alpha Refresh (from September) installed.
- The project is a VS2008 project so you'll need that and the VS2008 Tools for Silverlight alpha (I think this came out in December)
- I have exactly 1 DLR language working: Python.
- I will try to get Ruby working shortly.
- I have code in place for DLRJScript, but it doesn't work (I'm getting an initialization error).
- I don't have the files to try VBx.
- Everything will change after Mix and the release of the beta (unless someone from MS wants to give me a pre-release <wink />)
- The code is a mess right now, so consideer it a rough prototype (that works)
Future Plans
- Get ALL existing DLR Languages working (the one I haven't mentioned yet is IronScheme... are there others?)
- Improve the support for all the basic JavaScript environment functions (prompt, setTimeout, clearTimeout and eval would be nice to actually have working)
- Be able to fully traverse the DOM (this may be working... I just may need to figure out how to get it working... a gold star to anyone who figures it out before me)
- Be able to load modules from the file system (setting a the source attribute for a DLR Language)
- Come up with a sane way to compress a python (or other language) script (maybe there already is a way that I don't know about). Python appears to be a little more chatty (and being able to minimize the download)
The project will be available to download shortly...
Print | posted on Tuesday, February 26, 2008 11:31 AM