Showing posts from July, 2009

Mono builds of IronPython (and IronRuby)

Ivan Porto Carrero , when he's not writing IronRuby in Action , has been working on ASP.NET MVC integration with dynamic languages. His main focus has been IronRuby, but a lot of the core work (the DLR hosting API integration) applies equally to IronPython. Jeff Hardy has recently taken up the mantle of working on the IronPython integration. Anyway, that is all by the way of an aside. In the process of doing this Ivan has been building IronPython and IronRuby for Mono. He posted this email to the IronPython mailing list: I've added the ironpython mono package to the ironruby mono CI server. It is slightly different from the windows package it doesn't have the licenses included nor does it have the 64bit builds and the file. The tutorial is also not in the github repository so I couldn't include that either. you can download the packages here: The continuous integration server is maintained by CJ Adams-Collier, and it also has a pret

IronPython Training in Stockholm, September 23rd-24th

I'll be presenting a two day training session in Stockholm (the training is in English) with addskills in September (23rd-24th). It is aimed at .NET developers looking to use IronPython for application development, scripting, embedding, testing or just as another useful tool. It will be a comprehensive training session for those with .NET experience who are interested in making practical use of IronPython. There will even be some IronRuby examples covered. IronPython Training with This course is about how to make the most of dynamic languages like IronPython and IronRuby on the .NET framework; with a particular focus on IronPython. The dynamic language runtime, which is being incorporated into .NET 4.0 and is the basis of IronPython and IronRuby, enables a new class of language to run on the .NET framework. In the last few years dynamic languages have gained a reputation for increased developer productivity and being easy to learn. These new languages for the .NET fram

Teaching IronPython: D520 Course Notes (Week One)

Tony Andrew Meyer has now started teaching course D520 ("Programming") at Northtec . He's using IronPython in Action as course material (see IronPython in Action goes to college ) and has written up his search for an IDE for his students. The course is now starting and he is promising to post his notes online as he goes: IronPython Course Notes – The Plan Since I decided to use IronPython as the programming language for teaching D520 at Northtec, I’ve planned on putting my course material online so that anyone else planning on using IronPython in teaching can make whatever use of it they can. There won’t be a huge amount of material, especially in this first year, and especially since I managed to find an excellent textbook to use, but there will be some exercises, assignments, an exam, and so forth. Each year I teach a course I add new material, and while some material is replaced or removed, usually the old material stays, so the amount of material gradually increa

A Good Mix 17: MUD, the Python for .NET that never was, Intellisense for IronPython, SciPy and Silverlight

Yet another selection of articles and projects on IronPython and the Dynamic Language Runtime from around the web. chiroptera This is the gitorious project page for a C# project: Chiroptera is a MUD client written in C# and uses IronPython as a scripting language. It runs on Windows and on Linux. Windows version has a graphical user interface. Linux version has a text interface with 256 color support. Charming Python: Inside JPython and Python for .NET Back way in the past, before 1.0, there was a previous Microsoft project to bring Python to the .NET framework. Unfortunately .NET pre-1.0 wasn't a good platform for dynamic languages and the project was never released. This article (from December 2000) is an interview with Mark Hammond who was the programmer on the project. Mark Hammond is familiar to most Python programmers because of his excellent development of the PythonWin environment and the PythonCOM extensions. And for the same reasons that we look up to Mark, Microsoft als

Running IronPython 2.6 with Python stack frame support

IronPython 2.6 has Python stack frame support. Python stack frame support has a performance cost, but allows code that uses sys._getframe() , plus the standard library pdb debugger , to work. To run IronPython 2.6 with stack frame support you need to use one of two command line switches, -X:Frames or -X:FullFrames. In an email on the IronPython mailing list Dino Veihland (core IronPython developer) explains the difference: -X:FullFrames promotes all local variables into the heap. So you can always crawl the stack and look/change them for all methods. -X:Frames only creates the frame objects and if something happens to make us promote local variables (e.g. a closure, or a call to locals() , exec , eval , dir() , vars() ) then the local variables will be available for that specific method.

A Good Mix 16: Metaprogramming, Talks, PyDev, Excel and Testing

Another selection of articles, audio recordings and blog entries on IronPython collected from around the web. How I Learned to Love Metaprogramming Slides and code from a talk by Kevin Hazzard on metaprogramming on the .NET framework using C# 4.0 and IronPython. The title of my presentation was "How I Learned to Love Metaprogramming" and it concerns Dynamic Language Runtime architecture, performance of dynamic typing and Python to C# integration. The slides and source code are linked below. I will be giving this talk again in September at the Charlottesville .NET User Group meeting. Both of the demos require C# 4.0 which is available in Visual Studio 2010. Demo One - shows how to do XML parsing using a fluent interface based on a DynamicObject derivation in C# 4.0 Demo Two - shows how the Level 0, 1 and 2 CallSite and ActionBinder caches perform. UPDATED: I added a demo on 30 June 2009 that shows how the DLR 0.9 compares by invoking dynamic code through the DLR hosting APIs,

IronPython 2.6 Beta 2 Released (performance, ctypes, frames and more)

Hot on the heels of IronPython 2.0.2 is a new release - the second and hopefully final beta of IronPython 2.6. The big new features in IronPython 2.6 are: Python 2.6 compatibility The __clrtype__ metaclass for data binding and attribute support Implementation of the ctypes module Support for Python stack frames and sys.settrace , which means the pdb debugger works Better performance through adaptive compilation Faster startup In the announcement of the release Dave Fugate had this to say about the timetable for IronPython 2.6: At this point we are essentially feature complete from a CPython 2.6 perspective, and look forward to making available IronPython 2.6 Release Candidate 1 within the next couple of months. As such, we’d very much like everyone to try out this release and report back any major problems you may encounter so we can fix them in time for the first release candidate. Any bugs that you find can be reported via Codeplex . IronPython 2.6 Beta 2 Download and Release No

Five Reviews of IronPython in Action

In the last couple of weeks a whole stack of people have posted reviews of IronPython in Action . Here's a brief summary of five of them: Jason Baker on IronPython in Action Jason Baker is a Python developer for Zeomega : " In summary, if you’re a developer wanting to work with Windows technologies using Python there’s no question: go and buy IronPython in Action. Right now. If you’re wanting to develop IronPython applications for various platforms or don’t want to tie yourself to just Microsoft technology… still go and buy IronPython in Action. There are still some holes that can be filled, but all in all, this is a pretty solid book ." Mike Hadlow on IronPython in Action Mike Hadlow is a well known .NET developer from the UK: " It’s a very well written and crafted book, with an easy to read conversational style. I find many programming books quite hard work, but this one was a pleasure. " Mark Bloodworth on IronPython in Action Mark Bloodworth is a Microsoft

Øredev 2008 - Cool Languages - Pumping Iron: Dynamic Languages on .NET (video)

Last year Jonathan Hartley delivered a talk at the Øredev conference on IronPython and dynamic languages on the .NET framework . A video of his talk is now up on viddler: Øredev 2008 - Cool Languages - Pumping Iron: Dynamic Languages on .NET Pumping Iron: Dynamic Languages on .NET Jonathan Hartley, Resolver Systems , UK As you may know, Microsoft is developing IronPython and IronRuby, .NET implementations of the popular open-source programming languages Python and Ruby. While it's clear that Microsoft wants to attract existing Python and Ruby developers to .NET, the role of IronPython and IronRuby for existing .NET developers is less clear. What value is there for a .NET developer in learning IronPython? What are the tradeoffs between IronRuby and a more traditional .NET language like C# or VB? Jonathan also took some pictures at the conference.

Gestalt: Ruby, Python & XAML in your HTML pages

Silverlight makes it possible to script the browser with Python and Ruby (IronPython and IronRuby of course), but the experience is very different to working with Javascript. That could all change thanks to a new project from MIX Online Labs called Gestalt. Gestalt Gestalt is a library released by MIX Online Labs that allows you to write Ruby, Python & XAML code in your (X)HTML pages. It enables you to build richer and more powerful web applications by marrying the benefits of expressive languages, modern compilers, AJAX & RIAs with the write » save » refresh development model of the web. Amongst its features it promises: Make way for Ruby & Python, JavaScript! Gestalt lets you write Ruby & Python within script tags (or linked scripts) right in your (X)HTML pages allowing you to do everything and more you've been used to doing in the page with JavaScript. Transparently compiled and blazing fast When a user visits a page that uses Gestalt, we harness the power of

IronPython 2.0.2 Released

Work on IronPython 2.6 progresses (there is even a new page that appeared overnight comparing the performance of the as-yet-unreleased 2.6 Beta 2 to CPython 2.6.1 ). In the meantime there has been a bugfix release on the stable IronPython 2.0 branch - IronPython 2.0.2 has just been released. This release is a minor update to IronPython 2.0.1, which in turn is a CPython 2.5-compatible release running on the .NET platform. Our priority was to make IronPython 2.0.2 a bugfix release that remains backwards-compatible with IronPython 2.0.1. In particular, we focused on issues the IronPython community brought to our attention through codeplex . As such, there have been important improvements on the compatibility and stability of IronPython as summarized below. Download IronPython 2.0.2 Detailed change summary: 21577 – binascii.crc32 doesn't accept one argument. 20616 – wrong TypeError message when invoking "str.join": implicit parameter 'self' not counted 19665 – 2.0.2

Using IronPython in WPF to evaluate expressions

IronPython makes a ridiculously good expression evaluator, and for some reason it seems to get used a lot for adding dynamic features to WPF. For example see Using IronPython for Converters in Silverlight and Binding Dynamic Types with WPF . This Code Project article, by Sacha Barber, uses IronPython with WPF to evaluate mathematical expressions from C#. Using IronPython in WPF to evaluate expressions I have just read a little book on IronPython and thought it a pretty cool language. What I especially liked was the fact that it can be hosted in .NET as a script. This gave me an idea, wouldn't it be cool if we could use IronPython as a script to evaluate mathematical expressions for us and return a value. Think javascripts eval function, which is missing from C# (at least it is right now, it may be part of C# 4.0 who knows). So with this thought in mind I whipped up a small proof of concept and was actually very pleased with the results, so much so I have turned it into this arti

Python and Farseer: 2d Physics in Silverlight

Silverlight is a Microsoft browser plugin competing with Flash for rich internet applications and games (amongst other things). The most interesting thing about Silverlight, to me at any rate, is that it allows client-side web applications that run in the browser to be written in IronPython - including full access to the browser DOM. Silverlight is now maturing, with version 3.0 released only recently. Silverlight runs natively on Windows and the Mac on Firefox, Safari and Internet Explorer browsers. The Mono version for Linux, Moonlight , has reached the level of compatibility where it is capable of running DLR applications - like my IronPython examples . There are now lots of interesting open source libraries for developing Silverlight applications. One of them is the Farseer Physics Engine : The Farseer Physics Engine is an easy to use 2D physics engine designed for Microsoft’s XNA and Silverlight platforms. The Farseer Physics Engine focuses on simplicity, useful features, and

IronPython editor postscript (Eclipse and NetBeans)

Tony Andrew Meyer did a comprehensive blog entry on choosing an IronPython editor for teaching . In it he reviewed 7 IDEs and Python editors for use with IronPython. He's posted an update to this where he tries out NetBeans plus the combination of Eclipse and PyDev. IronPython editor postscript I earlier tried various editors I was considering using to teach IronPython. One of the glaring omissions was Eclipse/PyDev, which has built-in support and is a very well-known IDE (particularly in the Java community). The main reason that I skipped Eclipse was that when I was searching for an IDE to use professionally about five years ago I tried Eclipse (for Python, C, and C++ development) and I really hated it – the IDE was very slow (especially to launch), it was very Java-centric, and just didn’t suit me at all. I’d briefly tried Eclipse before that as well, with similar results. Over the last few days, I decided that I was probably being unfair, and since this was a choice for my s

A Good Mix 15: SharpDevelop, IronRuby, Mono and Scripting

More blog entries, articles and podcasts on IronPython and the Dynamic Language Runtime. Why SharpDevelop is a better IDE Discussing IDEs for IronPython is all the rage at the moment , and it is great that tool support is finally improving (and at an impressive pace). This post is by a developer called Mandar Vaze extolling the virtues of SharpDevelop for working with IronPython. In my first post about IronPython, I documented how installing IronPython Studio was painful (Needed Visual Studio shell, which in itself was confusing). When I started with IronPython I did not know about any other IDE, hence I went ahead with IronPython Studio. But later I came to know about SharpDevelop. IronRuby 0.6 Released IronRuby, the evil-twin of IronPython, has had a new release on the road to version 1.0. Jimmy Schementi announces and explains the release: Performance has been a major focus to this release, getting startup time quicker and optimizing built-in types. There has been more progress with

Getting started with IronPython – Part 4: MiniMax algorithm

Dror Helper continues his series on getting started with IronPython programming. He has been creating an example game and after his last entry on unit testing he moves onto adding some simple AI logic: Getting started with IronPython – Part 4: MiniMax algorithm As part of my quest to learn how to program in Python I’ve decided to implement a simple Minimax algorithm. The algorithm is simple and relies on a elementary principle – each turn you will choose the best move and your opponent will choose the worst move for you. By building a search tree with a limited depth we can then choose each time either the maximum result possible or the minimum result according to the player’s turn. You can read more about Minimax algorithm in Wikipedia – or continue reading and learn it from my implementation.

A Good Mix 14: Open Source, XML, XNA and more

Another selection of blog entries and articles on IronPython and the DLR. Microsoft and Open Source A Korean translation of a presentation about the future of Open Source at Microsoft by Harry Pierson, the IronPython program manager. IronPython, and its two companion projects IronRuby and the Dynamic Language Runtime, are at the forefront of pushing the adoption and acceptance of open source in the corporate behemoth we all know and love. bridge version 0.3.8 released bridge is an open source Python library for handling XML that works with CPython and IronPython. Its homepage describes it as: " a Python XML library trying to provide a high level and clean interface for manipulating XML documents. " bridge allows you to write code dealing with XML that will run unmodified on both CPython and IronPython. Most common Python packages for dealing with XML rely on C extensions not available on IronPython (except through Ironclad ) although the FePy project contains an implementa

Choosing an IronPython editor for teaching

As outlined in IronPython in Action Goes to College , Tony Andrew Meyer is teaching a programming course and using IronPython in Action as course material. Part of his preparation is deciding which IDE to use in the course - a choice that is not entirely straightforward for IronPython. Tony has done a long and thorough blog entry going through all the possibilities. The editors he looks at are: Notepad++, IronPython Studio, SharpDevelop 3.0, SharpDevelop 3.1b1, Wing IDE 101, Davy's IronPython Editor, Visual Studio under experimental hive and Komodo Edit. Choosing an IronPython editor for teaching The Northtec D520 “Programming” course is changing to IronPython (from Visual Basic) this year, so I have to figure out what editor/IDE the students should use. In some ways, Visual Studio would be ideal, since they need to get exposed to that during the course (and it’s an excellent IDE, with a really great form designer), but since there isn’t any real IronPython support in Visual St

IronPython for build scripting

Python is ideal for tasks like automating build processes. Similarly, in a .NET environment IronPython is a valuable tool. Steve Gilham has been putting IronPython to work in his current project. IronPython for build scripting Following on from the earlier post with the snippet about generating GUIDs -- and covering a good chunk of what's been occupying me since... I have ended up in charge of the build system for the current project at work. This started out with one framework that used a number of custom projects inside a solution to perform unit test, FxCop and coverage analysis, with a lot of magic happening in post-build steps, including direct calls to Wix command-line utilities. Another team had developed a better separated MSBuild-based system, which split out things like the analysis and installer building from the assembly-building solution. We can argue the merits of taking the unit tests out of every checking compile; but separating out the installer build does have a

Interoperability Happens: Ted Neward Reviews IronPython in Action

Ted Neward is a well known .NET developer. He has been reading IronPython in Action and posted a review of it. Interoperability Happens Ted Neward doesn't have unqualified praise for the book, but he seems to like it - even getting over his prejudice for 'the whitespace issue' (block structure by indentation in Python). Here are some things he liked about IronPython in Action: The focus is on both .NET and Python, and doesn't try to short-change either the "Python"-ness or the ".NET'-ness by trying to be a "Python book (that happens to run on .NET)" or a ".NET book (that happens to use Python for code samples)". The authors, I think, did a very good job of balancing the two, making this the book to get if you're in that area on the Venn diagram where "Python" overlaps with ".NET". Part 2, "Core development techniques", starts down the "feed you the Python Kool-Ade" pretty quickly, headi


For IronPython users interested in tool support the big new feature in IronPython 2.6 is the support for Python stack frames and all that comes along with it. Not a small part of this is that pdb , the standard library Python debugger, will work with IronPython - yay! Harry Pierson (IronPython program manager for Microsoft) has a new blog entry detailing the new assembly that will come with IronPython 2.6 (but will actually be part of the Dynamic Language Runtime) to support this: Microsoft.Scripting.Debugging If you’ve compiled IronPython from source recently, you may have noticed a new DLL: Microsoft.Scripting.Debugging. This DLL contains a lightweight, non-blocking debugger for DLR based languages that is going to enable both new scenarios as well as better compatibility with CPython. Needless to say, we’re very excited about it. ... Of course, we hide all this DLR Debugger goo from you in IronPython. Python already has a mechanism for doing traceback debugging – sys.settrace . O

Simon Segal: A WPF IronPython REPL and messaging with NServiceBus

Simon Segal has been building an Entity Framework tool with built-in IronPython scripting support. Part of this has involved creating quite a fully fledged interactive Python interpreter as a WPF GUI component. This turns out to be quite a useful tool on its own. An IronPython REPL Console in a WPF User Control So to move forward with the WPF user control console project I decided to refactor it to support IronPython. Mark has jumped in just recently and started to contribute by adding the new “cached commands”, which offer up / down arrow repeat command behaviour such as found on a DOS console. You will also notice from the screenshot above I have imported the entire System namespace to demonstrate that it is possible (using the environment menu) to print the entire state of the default scopes current set of variables. Configuring, Testing and Probing NServiceBus with IronPython I have recently been working with NServiceBus quite a bit and whilst I was working on a WPF IronPython C

Bazaar on IronPython

The IronPython team are extremely interested in IronPython's compatibility with CPython. One easy way of finding incompatibilities (bugs) is running large Python applications on IronPython. Jeff Hardy has done a lot of work on this front by running Django and setuptools with IronPython, and now the Bazaar (Distributed Version Control System written in Python) team are joining in the fun. Bazaar on IronPython In short, see the attached patch for getting bazaar to run on IronPython. It only passes a subset of the tests, but can do some of the basics like creating a new repo, adding and diffing, and committing the changes. This is not intended for merging, many of the changes are addressing interpreter bugs and differences rather than problems with the code. However there are a number of issues raised that might be of interest to bazaar developers. Having nibbled round the edges of the bzrlib.osutils module, I wanted a task that would serve as an excuse to look over the platform rel

Guido van Rossum on IronPython in Action (he doesn't like Windows Forms but Davy Mitchell does)

Guido van Rossum is the creator of Python and its Benevolent Dictator for Life (BDFL). He is employed by google and not known for his love of the Windows platform. That aside I sent him a copy of IronPython in Action and he has reviewed it. As you can tell from the title of his blog entry it isn't a typical review, but he does say some very nice things about the book: IronPython in Action and the Decline of Windows Seeing a book like IronPython in Action, by Michael Foord and Christian Muirhead, is another milestone for IronPython. This is a solid work in every aspect, and something nobody using IronPython on .NET should be without. The book is chock full of useful information, presented along with a series of running examples, and covers almost every aspect of IronPython use imaginable. There are some introductory chapters -- some fluff about .NET and the CLR, an introduction to Python, and an introduction to with .NET objects from IronPython. The Python introduction has a slight

A Good Mix 13: ActiveRecord, Guids and Strings (etc)

Another selection of IronPython snippets and articles from around the web. IronPython ActiveRecord in Action The Active Record pattern is a pattern for working with databases named by Martin Fowler and popularised by Rails: " The interface to such an object would include functions such as Insert, Update, and Delete, plus properties that correspond more-or-less directly to the columns in the underlying database table. " Creating classes where the shape of the class corresponds to the shape of a database table is particularly easy with dynamic languages. This Chinese blog entry demonstrates the pattern with IronPython hosted in C#. Generating Strong Repeatable Guids Blog entries by Steve Gilham have made frequent appearances here on IronPython-URLs, although I believe it has been a while since the last one. This entry isn't specifically about IronPython - but the example code is in IronPython. He shows a couple of example functions he uses in his build scripts to solve th

Simple Python Testing in Silverlight with unittest

Jimmy Schementi is the program manager for the Silverlight dynamic languages integration. He has an unhealthy interest in IronRuby, and created a very impressive IronRuby tutorial that is part of the latest release. It's always nice when he does something with a Python focus, and a recent blog entry of his is particularly good - testing in Silverlight with IronPython and the unittest module . Simple Python Testing in Silverlight with unittest Since doing a post about Ruby testing of Silverlight applications , I’ve felt a bit guilty about leaving Python fans in the dark. However, like Ruby, it takes very little work to run Python unit test frameworks in Silverlight , since IronPython is a very compatible implementation of Python. Though my results aren’t as exhaustive as the IronRuby examples, here’s one simple example:

Another IDE for IronPython? Eclipse and PyDev

A common question with IronPython is which IDE to use. Many .NET developers will immediately look for IronPython integration with Visual Studio but there are much better options. Up until now the front runner has been SharpDevelop with debugger, Windows Forms designer and even C# to IronPython translation. Other viable alternatives are Wing IDE and Netbeans . Another alternative has just arrived - and it is an unexpected one: Eclipse, through the PyDev extensions . The features it supports for IronPython are impressive. Testing on Pydev 1.4.7 & IronPython One of the major features in this release is the IronPython integration. Note that it requires IronPython 2.6 (earlier versions are not supported because of the lack of sys._getframe() ). In that integration, code-completion should be working for the .NET libraries and other dlls. For the .NET libraries, just make sure that the library you're using is listed in the forced builtins -- I believe all libraries should be the

NWSGI: Configuration and Dispatching

NWSGI , as I may have mentioned before, is the creation of Jeff Hardy and is " a .NET implementation of the Python WSGI specification for IronPython. It is implemented as an ASP.NET HttpHandler for use with IIS 6 and 7 ". The goal is to be able to run Python applications like Django, Trac and Pylons on IronPython. It can also be used on the Microsoft Azure (cloud computing) platform. Version 2 is now in beta , and with it come several important changes. In a series of blog entries Jeff has been explaining these changes; and these four entries focus on configuring and dispatching. NWSGI 2.0: Configuration Details For the most part, NWSGI can be used without any configuration. All you have to do is create a .wsgi file, throw it in a directory, let IIS know what’s going on, and you’re good to go! Of course, if it was always that easy, configuration wouldn’t exist. To really work with NWSGI, you need to understand its configuration. It helps if you’re already familiar with web.c

IronPython in Action Goes to College

Thanks to the wonder of Twitter I've heard about two different college courses that will be using IronPython in Action as course material next semester. One is Sargeant Reynolds College in America, with a course taught by Kevin Hazzard , and the other is Northtec in New Zealand with a course taught by Tony Meyer . IronPython is an ideal language for learning programming, it has the great combination of an easy to learn general purpose programming language (Python) with a programming environment which is widely used in commercial development (the .NET framework). Not only these factors, but it is easy to teach good programming practise with Python; things like well structured code, testing, computer science theory including elements of functional programming and so on. I exchanged emails with Tony who explained why he is using IronPython in Action: The course is (unimaginatively) titled "Programming" (not my doing!). It's at NorthTec at the Whangarei campus (a c