Introduction to IronPython & Silverlight
Python in Your Browser
Silverlight is a browser plugin from Microsoft. Through Silverlight it is possible to create dynamic applications and natively script the browser with Python.
In this series of articles we will look at what it is possible to achieve with Silverlight, and how to get started with dynamic applications. This includes the following topics:
- Create dynamic applications
- Using the Silverlight APIs
- Including consuming XAML and create controls
- Access the browser DOM
- Embed IronPython in a C# Silverlight application
- Compile C# for Silverlight without Visual Studio installed
The examples used throughout these articles are online and available for download.
For a more thorough introduction to creating applications with IronPython and Silverlight, read chapter 13 of IronPython in Action. This takes you through more of the APIs, including creating a full application: a Twitter client that runs in the browser. The first chapter of IronPython in Action is available online free, and gives a great introduction to both Python and IronPython.
IronPython is an implementation of the popular dynamic programming language Python. Python is a general purpose programming language used for everything from desktop applications, running YouTube, games, managing Imageworks animation pipeline, automated hard drive testing for Seagate - and much more.
IronPython runs on the .NET framework and Mono. This allows Python programmers to take advantage of the extensive framework libraries and powerful runtime of .NET, and allows .NET programmers to take advantage of Python!
IronPython was originally created by Jim Hugunin, and is now developed by a team of programmers (which sometimes includes Jim!) at Microsoft. IronPython is a Python compiler, compiling Python code to in memory assemblies.
IronPython 2 targets Python 2.5 and is built on the DLR (Dynamic Language Runtime).
Silverlight is Microsoft's entry into the rich internet application framework race.
- A cross-platform cross-browser plugin
- Intended for games and Rich Internet Application
- Silverlight code runs in the browser
- Streaming media and video
- Includes the 'CoreCLR'
- Through the DLR, runs IronPython
Silverlight is a sandboxed browser plugin for creating rich client-side web applications. It runs on Windows and Mac OSX, supporting Firefox, IE and Safari (with support for more browsers on the way). Nokia S60 and Windows Mobile support have also been announced.
There is a Mono version called Moonlight, which runs on Linux (supporting Firefox). This is officially backed by Microsoft who are making the media codecs, the test suite and the full specification available to the Mono team. Initially it will target Firefox on Linux, but eventually will run on multiple browsers everywhere that Mono runs.
- A video player!
- A user interface based on Windows Presentation Foundation
- 'Deep zoom' and adaptive streaming
- Client side storage (1MB per app but you can request more)
- A rich set of APIs (JSON, XML, threading, sockets)
These languages can also interoperate with the traditional .NET languages. They can use classes created from C# /VB code without wrappers. To the dynamic languages they are natural objects just as much as ones they have created themselves.
There are several ways that dynamic applications can use Silverlight:
- The Silverlight control is the main user interface on the web page
- The Silverlight control is completely hidden and acts as a calculation engine that runs in the background
- A fullscreen mode
One major difference between Silverlight and Adobe Flex/AIR is that there is currently no way to use Silverlight to create applications that are separate from the browser (well the Mono guys have done this with Moonlight).
First we'll look at the structure of an IronPython & Silverlight application.
For buying techie books, science fiction, computer hardware or the latest gadgets: visit The Voidspace Amazon Store.
Last edited Sat Aug 14 14:30:21 2010.