Thursday, December 31, 2009

A Good Mix 34: Silverlight Logging, WPF and NotifyIcon, more Python and Ruby and pickling Python books

Another collection of IronPython and DLR related articles from around the web. A fine way to end 2009.
A nascent project to Port Log(4|5)J from Java to C# with the goal of usefulness in Silverlight, especially for IronPython.
 Two Japanese blog entries, both by sasakima-nao. As with previous entries the code examples are very readable. The first is a simple WPF picture viewer (nice penguins) and the second shows how to create a NotifyIcon and ContextMenu in the taskbar (with Windows Forms classes).
This blog entry is in Russian, but I think there are enough code examples for it to be useful for those of us who don't speak Russian. As I've mentioned before the promise of the Dynamic Language Runtime is that dynamic languages can interoperate and share libraries. This is exactly what this blog entry shows: using the Ruby soap/wsdlDriver from Python.

The cool thing is that this is done with a helper / wrapper library, that looks like it could be used to expose virtually any Ruby module / class that can be accessed through IronRuby to IronPython. Using his ruby module, the code looks like this:
from ruby import _import_, get_class
_import_('soap/wsdlDriver')
Soap = get_class('SOAP::WSDLDriverFactory')
client = Soap('http://localhost1/Service1.asmx?WSDL').create_rpc_driver()
client.HelloWorld(None)
Marcus McElhaney has discovered IronPython and likes it. The reasons he gives are:
1. I can very easy use everything I know about the .Net Framework, VB.Net, and  C#
2. I can run IronPython in Visual Studio
3. I can reference ESRI's  ArcObjects libraries in  Visual Studio and IronPython
What's even more gratifying is that he has been exploring IronPython through IronPython in Action and likes that too. A slight misspelling gives rise to my favourite quote about IronPython in Action:
IronPython In Action is probably the best Python book I have ever pickled up because it also explains a lot of not just Python but also about .Net.
If any book deserved to be pickled up, this is it... Have a great 2010.

Wednesday, December 30, 2009

Does Microsoft take Dynamic Languages Seriously?

My belief is that the answer to the question in the title of this entry is an emphatic yes. Microsoft have poured a lot of money into IronPython, IronRuby and the Dynamic Language Runtime and have demonstrated a consistent commitment since the inception of IronPython. What they haven't done is build full support into their premier development tool, Visual Studio. The reason for this is that it is a very difficult problem. Visual Studio is built around statically typed languages. Features like intellisense, refactoring and code navigation all rely on having type information which is absent in languages like Python and Ruby. (The way they are implemented in Visual Studio requires that information I mean.)

What Microsoft have done is provide example integration in the form of IronPython Studio, which frankly sucks. Many important features are fragile, broken or missing altogether. Good IDEs like PyDev and Wing do provide these features, so it is definitely possible - it just requires a lot of work from scratch.

Microsoft have however added intellisense for Javascript, particularly for jQuery, into Visual Studio. Javascript is of course a dynamic language, but without having tried the integration I can't tell you how well it compares to using a good Python IDE. I believe that Microsoft would like to add support for dynamic languages to Visual Studio and that it will come eventually. Really they have a lot to lose by not doing it.

Now they have a good platform for dynamic developers to use, which they give away free, but the tools they charge for don't really support them. This puts them in a position of either bringing developers to their platform but not being able to make any money, or having their existing developers stay with their platform but losing dependence on the toolset. Neither option looks much good for Microsoft.

(NOTE: for those who can't wait for official Microsoft support and have Visual Studio 2010, try Jeff Hardy's IronPython for Visual Studio Extensions.)

Anyway, K. Scott Allen sees things a little differently and I understand his frustration:
Consider this …

IronPython got underway in July of 2004. Five years later it appears IronPython is still not a candidate to be a first class language in the .NET framework and tools. You can vote on this issue.

Microsoft first released IronRuby at Mix in 2007. Nearly three years later it appears IronRuby is still not a candidate to be a first class language in the .NET framework and tools. You can vote on this issue.

A first class language is deployed when the full .NET framework is installed. It’s as easy to find as csc.exe. It’s not a language you have to ask the IT department to install separately. It’s not a language that requires you to jump out of Visual Studio to edit or run.

Most of all, a first class language doesn’t require justification to higher powers. A first class language is pre-certified and stamped with a seal of approval. It’s as easy to use in the locked-down big corporate setting as the company paper shredder.
Of course here we are talking about Microsoft as if it was a single entity with a single intention. The reality of course is that Microsoft is a huge company with many divisions and even more individuals working there. In all likelihood the vast majority of Microsoft employees have never heard of IronPython. The relevant division is the programming languages group, which includes Visual Studio development, and where the majority of employees who are developers probably have heard of IronPython if not actually used it... Adding official dynamic languages support to Visual Studio would require substantial investment of time and effort, so even if everyone in this department was determined to add support it would still be dependent on forces from other parts of the company who have other needs and priorities...

Ironclad 2.6 and Spare Batteries for IronPython

Ironclad is a compatibility layer that allows you to use Python C extensions with IronPython. Ironclad is open source and development has been funded by Resolver Systems and it is integrated into Resolver One to allow you to use Numpy within Resolver One spreadsheets.

Ironclad works by implementing the Python C API in a combination of C#, C and Python. Although Ironclad only works on 32 bit Windows at the moment the implementation has been done in such a way that porting it to run on other platforms (with Mono) and 64 bit would be relatively easy. Patches welcomed!

Recent development has changed the implementation to use gcc-xml to access and transform the Python C source code. By reusing as much of the original implementation as possible it minimizes the amount that needs to be 'hand-coded'. It leaves only a (moderately) small core that would need to be reimplemented if Jython, PyPy (or other implementations) wanted to reuse Ironclad. The C# would need to be re-coded in Java or RPython, using the platform's native FFI instead of PInvoke on .NET. The advantage of reusing Ironclad is that difficult problems, like handling the Global Interpreter Lock and matching reference counting to different garbage collection strategies, are already solved (well, for some value of solved...).

Anyway, that is all by way of introduction. William Reade, core developer of Ironclad, has just announced Ironclad 2.6 RC. This is a release candidate of Ironclad targeting IronPython 2.6.
I'm very happy to announce the latest release (candidate) of Ironclad, the 120-proof home-brewed CPython compatibility layer, now available for IronPython 2.6!

No longer need .NET pythonistas toil thanklessly without the benefits of bz2, csv, numpy and scipy: with a simple 'import ironclad', (most parts of) the above packages -- and many more -- will transparently Just Work.

Get the package from:
    http://code.google.com/p/ironclad/

...and get support from:
    http://groups.google.com/group/c-extensions-for-ironpython

...or just ask me directly.

I'm very keen to hear your experiences, both positive and negative; I haven't been able to test it on as many machines as I have in the past, so your feedback is especially important this time round*.

Cheers
William

* I'd be especially grateful if someone with a newish multicore machine would run the numpy and scipy test scripts (included in the source distrbution) a few times to check for consistent results and absence of weird crashes; if someone volunteers, I'll help however I can.
William has recently started blogging. I recommend browsing the few entries he has already posted, particularly this rant on static typing and this post on .NET marshalling, but his latest is of particular interest:
As we all know, Python comes with batteries included in the form of a rich standard library; and, on top of this, there are many awesome and liberally-licensed packages just an easy_install away.

IronPython, of course, includes *most* of the CPython standard library, but if you're a heavy user you might have noticed a few minor holes: in the course of my work on Ironclad, I certainly have. Happily for you I can vaguely remember what I did in the course of bodging them closed with cow manure and chewing gum; here then, for your edification and delectation, is my personal recipe for a delicious reduced-hassle IronPython install, with access to the best and brightest offered by CPython, on win32.

Tuesday, December 29, 2009

A Good Mix 33: Embedding Python and Ruby, Profiling IronPython, News on JScript, ctypes and DeviantArt

More IronPython and DLR related projects, articles and news from around the web.
A  nice example of embedding both IronPython and IronRuby in a single C# project. As an added bonus the project is a Silverlight project so you can add both Python and Ruby scripting to applications that run in the browser.
IronPython 2.6 has useful new hooks for profiling and debugging IronPython code. Unfortunately most 'standard' .NET tools don't know how to use these, and if you attempt to profile IronPython code (particularly in an embedded environment) you have to work hard to get useful information about performance of your Python code. It's nice to see a new (and open source) tool that is designed to work with IronPython:
SlimTune is a free profiler and performance analysis/tuning tool for .NET based applications, including C#, VB.NET, IronPython, and more. It provides many powerful features, such as remote profiling, real time results, multiple plugin-based visualizations, and much more. The source code is available under the terms of the MIT License.

SlimTune is currently in the prototyping phase of development, but a preview release is available for testing and feedback is welcome. Both x86 and x64 targets are supported, but only sampling based profiling is available in the release.
When IronPython 2 and the Dynamic Language Runtime were announced one of the three Microsoft developed languages that ran on the DLR was JScript. Managed JScript was an implementation of ECMAScript (otherwise known as Javascript) and touted as a useful bridge for porting 'traditional-ajax' applications to run on Silverlight. Unfortunately as the DLR evolved JScript languished and there was no official word on its fate.

In this post on the DLR Codeplex forum Bill Chiles (DLR Program Manager) gives the bad news:
The DLR JScript was experimental for informing the design of the DLR (expression trees, interop, callsites, hosting, etc.).  The JS we released with asp futures and the Silverlight dynamic sdk became very old and unserviceable as the DLR continued evolving for release in CLR 4.0.  Unfortunately, there are no plans at this time to develop and release a DLR-hostable JScript.
A Japanese blog entry showing example code using the new implementation of ctypes in IronPython 2.6. ctypes is the Python FFI and in IronPython it is built on top of PInvoke, the .NET FFI. ctypes is used for calling into native code, like the Win32 API. Calls SHGetFileInfoW, which "Retrieves information about an object in the file system, such as a file, folder, directory, or drive root."
No idea what this has to do with the implementation of Python for .NET, but IronPython is the username of someone on the alternative community art site deviantART. Some pretty nice computer generated art, and who knows - maybe they were created from Python...

Scripting Applications with IronPython (ADAM, Revit, AutoCAD & Postsharp)

IronPython and the Dynamic Language Runtime make it almost ridiculously easy to add scripting to .NET applications.

In recent weeks several examples of using IronPython to add scripting or interactive shells to .NET applications have been posted by the .NET community:
This post was heavily inspired by the code presented by my old friend Albert Szilvasy during his excellent AU class on using .NET 4.0 with AutoCAD.
...
In this post we’ll take Albert’s technique and implement a command-line interface for querying and executing IronPython script. This approach could also be adapted to work with other DLR languages such as IronRuby, of course.

Here’s the updated C# code which now not only implements PYLOAD functionality, but also a PYEXEC command.
 Making an application scriptable (particularly in a static language) has historically been difficult. With the advent of the DLR (Dynamic Language Runtime) on the .NET platform it becomes almost trivial to add scripting support to any application. For a recent project I needed the ability to add scripting hooks throughout the application and coupling the DLR with PostSharp AOP attributes made this effort pretty straightforward. Here’s how it was done.
According to wikipedia: "Autodesk Revit is Building Information Modeling software for Microsoft Windows, currently developed by Autodesk, which allows the user to design with parametric modeling and drafting elements.  Building Information Modeling is a Computer Aided Design (CAD) paradigm that allows for intelligent, 3D and parametric object-based design."

Jeremy Tavik blogs about working with the Revit API, and in this post he discusses a Python Shell for Revit that created by Daren Thomas with IronPython:
Daren Thomas of the Professur für Gebäudetechnik, Institut für Hochbautechnik at the technical university ETH Zürich has published a Python Shell for Revit. It was implemented using IronPython and is used to automate the running of daily tests of a building energy analysis package. Hosting IronPython via a Revit plug-in is a now solved problem. Daren's intention is to continue publishing samples of what you can do with it pretty regularly in the future.

The source code is available under the GNU General Public License v3 from a Subversion repository on code.google.com. It is documented, though there is currently little other stand-alone documentation. One would probably want to look for the IExternalApplication entry point and go from there. What the application does is:

Add a button to the Revit ribbon to start the python shell.
Execute a python script entered in a text box, with output going to a separate window.
Daren describes one of the main scripts like this: it "will open up an interactive interpreter loop known as a REPL that will let you explore the Revit API. And by explore, I mean type a statement, hit enter, see the results, carry on. It doesn't get easier as this!"
IronPython is an implementation of the Python language for the .NET framework, using the new Dynamic Language Runtime (DLR) as language services layer on top of the Common Language Runtime (CLR). The DLR's reusable hosting model makes it extremely suitable to add scripting capabilities to existing products.
In this post we'll create an ADAM command line utility that will allow us to run IronPython scripts against an ADAM application.
...
Our command line tool will expose a single command, RunScript, that will take in ADAM connection information and a path to a Python file to execute:

Monday, December 28, 2009

PythonSilverScripting: Silverlight apps in the browser with Python

Tarn Barford is an Australian blogger and programmer who uses IronPython. He's created a Google App Engine site for experimenting with IronPython in the browser (through Silverlight).
PythonSilverScripting lowers the barriers to building Silverlight applications so anyone from high school kids to seasoned programmers can have fun writing Silverlight applications in Python from within a browser!

Below is a simple script that creates a Silverlight application, sets the background blue and adds a TextBlock element with the text "Hello World".
He's also blogged about the new site, including his future plans for it:
PythonSilverScripting is based on crazy idea I have that it should be possible to make Silverlight applications in Python on the web. No tools, no SDKs.. just a browser (and obviously the Silverlight browser plug-in).
I've played around a bit with Silverlight and Dynamic Languages here and there and thought it was probably possible. When I got a chance I looked into it and found I was able to build working XAPs by zipping up plain text IronPython code, the IronPython DLR assemblies, an xml application manifest file and all the additional resources such XAML, images and more source.
All I needed was a web server that could zip files. Google App Engine with Python is good fun and I was able to get this working prototype together in an evening. I'd like to build the features to support building bigger projects (more source files, XAML documents, images and assemblies). On the other hand I'd also like to build features to share, discuss and rate scripts. We'll see how it goes.

Why IronPython Podcast and Best of MSDN Ebook

I recently wrote an article for the UK MSDN (Microsoft Developer Network) newsletter called Why IronPython? This article made it into the collection of the thirteen best technical articles of 2009:

You can download these articles as a free ebook in XPS or PDF format, or read it online:
The UK MSDN Flash developer newsletter contains great short technical articles written by UK developers both inside Microsoft and in the broader developer community. This eBook pulls together these great articles in one place. There are thirteen articles in this second edition covering Python, Inversion of Control, Behavior Driven Development, Silverlight and more.
The MSDN Flash newsletter is run by Eric Nelson. He also has a podcast and we recorded an episode together about Python, IronPython, PyCon and various other topics:
A great chat with Michael Foord, author of IronPython in Action, on why a C# or Visual Basic .NET developer should look at also investing time in learning and using IronPython. Michael wrote an article on IronPython for the November 18th 2009 UK MSDN Flash newsletter:

“One of the new features in .NET 4.0 is the dynamic keyword, building on the Dynamic Language Runtime. A major reason for dynamic is to enable easier interaction with dynamic languages like IronPython. But if you're a dyed in the wool C# or VB.NET programmer why should you be interested in IronPython? 

IronPython is a .NET implementation of the popular open source programming language Python. Python is an expressive language that is easy to learn and supports several different programming styles; interactive, scripting, procedural, functional, object oriented and metaprogramming. But what can you do with IronPython that isn't already easy with your existing tools? …

Tuesday, December 22, 2009

Executing IronPython Code from IronRuby

The Dynamic Language Runtime is a framework for writing dynamic languages that run on the .NET framework, with the two "Microsoft sponsored" languages being IronPython and IronRuby. There is also IronScheme, a community project hosted on Codeplex.

The promise of the DLR is not just that it makes implementing dynamic languages possible, but also that through the DLR .NET languages can interoperate. This includes IronPython and IronRuby (etc) interacting with C#, F# and VB.NET (the supported and statically typed Microsoft .NET languages) but also the reverse (statically typed languages interoperating with dynamically typed languages) and dynamically typed languages interoperating amongst themselves. All very incestuous.

As far as I know this is still unique amongst the modern polyglot runtimes (.NET and Mono, the JVM, LLVM, Parrot and so on).

Whilst IronRuby in particular has been changing very rapidly (IronRuby has only recently reached 1.0 RC 1) it has been hard to get versions of both languages built on the same version of the DLR. However recent builds have tended to include compatible versions of the other language, making it a bit easier.

IronShay (Shay Friedman) has written a blog entry demonstrating how IronPython and IronRuby can share code and use each others libraries:
 One of the advantages of the Dynamic Language Runtime (DLR) is the fact that it makes sharing code between the languages that are written on top of it (and on top of the CLR as well). Therefore, it is possible to share code between IronPython and IronRuby (and any other DLR language as well like IronScheme).

This means that IronPython libraries can be used from IronRuby code and vice versa. Ruby on Rails in Python? Django in Ruby? feels like the end of days, isn’t it? perhaps we should really start preparing to year 2012

In this post I’ll show you how to run simple IronPython code from IronRuby so you can take it and do whatever your imagination guides you to.

Monday, December 21, 2009

Why IronPython?

This is a short article I wrote for the UK MSDN Flash newsletter (a Microsoft newsletter for developers). Unfortunately the online versions of these newsletters aren't being updated at the moment; so instead of linking to it I'm reproducing it here.

Why IronPython?

One of the new features in .NET 4.0 is the dynamic keyword, building on the Dynamic Language Runtime. A major reason for dynamic is to enable easier interaction with dynamic languages like IronPython. But if you're a dyed in the wool C# or VB.NET programmer why should you be interested in IronPython?

Much of the discussion here applies to other dynamic languages, including IronRuby, but Python is my particular area of expertise.

IronPython is a .NET implementation of the popular open source programming language Python. Python is an expressive language that is easy to learn and supports several different programming styles; interactive, scripting, procedural, functional, object oriented and metaprogramming. But what can you do with IronPython that isn't already easy with your existing tools?

The first entry in the list of programming styles is 'interactive'. The IronPython distribution includes ipy.exe, the executable for running scripts or programs that also doubles as an interactive interpreter. When you run ipy.exe you can enter Python code that is evaluated immediately and the result returned. It is a powerful tool for exploring assemblies and learning how to use new frameworks and classes by working with live objects.

The second reason to use IronPython is also the second programming style in the list; scripting. Python makes an excellent tool for generating XML from templates, automating build tasks and a host of other everyday operations. Because scripts can be executed without compilation experimentation is simple and fast. Python often creeps into businesses as a scripting language, but beware it spreads!

One of the big use cases for IronPython is for embedding in applications. Potential uses include user scripting, adding a live console for debugging, creating domain specific languages where rules can be added or modified at runtime or even building hybrid applications using several languages. Python has several features, like the ability to customise attribute access, that make it particularly suited to the creation of lightweight DSLs. IronPython has been designed with these uses in mind and has a straightforward hosting API.

There are many areas where dynamic languages are fundamentally different from statically typed languages, a topic that rouses strong opinions. Here are a few features of IronPython that make it easy to develop with:
  • No type declarations
  • First class and higher order functions
  • No need for generics, flexible container types instead
  • Protocols and duck-typing instead of compiler enforced interfaces
  • First class types and namespaces that can be modified at runtime
  • Easier to test than statically typed languages
  • Easy introspection (reflection without the pain)
  • Problems like covariance, contravariance and casting just disappear
The best way to learn how to get the best from IronPython is my book IronPython in Action. I've also written a series of articles aimed at .NET developers to help get you started including Introduction to IronPython, Python for .NET Programmers and Tools and IDEs for IronPython.

Happy experimenting!

Michael Foord

Tuesday, December 15, 2009

IronPython gets a long overdue website!

Thanks to Jimmy Schementi (the new IronPython PM, Ruby lover and all round good guy) IronPython has a new website. And as said best on Reddit, it doesn't look like Microsoft made it. The site has links to documentation, community resources and online IronPython examples using Silverlight (including Try Python).
CodePlex will continue to be the tool we use for project management and releases, but all end-user information will be on IronPython.net. Also, the .com domain still points at the super-old site, but will redirect to this site shortly.

The most notably addition is the .NET Integration Documentation, a thorough set of examples and descriptions of using IronPython with .NET. Considering this is IronPython’s main purpose, it’s amazing we got away with having hardly no documentation for this long … I guess the .NET integration is just that intuitive :) Anyway, please give it a read and let us know if you have any suggestions.

WCF Service in pure IronPython with config file

In previous blog entries Lukáš Čenovský looked into Databinding and WCF Services with IronPython 2.6. This uses the new __clrtype__ feature in IronPython 2.6 to interact with .NET features that previously couldn't be done with IronPython.

In this follow up blog entry Lukáš shows how to saved the IronPython interface in an assembly with a config file.
I was wrong when I wrote in the last post that the IronPython service cannot be saved into an assembly. It can. Which opens a way to use .config file to configure the service.
The interface is the same as in the previous version. The only difference in the service to the previous version is in the ServiceHost initialization - we omit the service configuration parameters because they are in the .config file. I also changed the clr namespace.

Sunday, December 13, 2009

NWSGI 2 RC 2 and IronPython Extensions for Visual Studio 2010

Jeff Hardy is a big cheese in the IronPython world. One of his older projects is NWSGI, an implementation of the Python WSGI (Web Server Gateway Interface) specification for .NET. This allows Python WSGI applications to run on IronPython and be served by IIS.

One of his newer projects is an extension of Visual Studio 2010 (still in beta) to provide Python syntax highlighting and IronPython support.

Jeff has recently announced progress in both projects.
The final release candidate of NWSGI 2.0 is now available. Except for version numbers, this is what will become NWSGI 2.0 as soon as IronPython 2.6 is released.

NWSGI 2.0 Release Candidate 2 includes all of the features of NWSGI 2.0 Release Candidate 1, and adds support configuring tracing, lightweight scopes, and the profiler. It is built against IronPython 2.6 RC3.

The following issues are fixed in this release:
 Lately, I’ve been experimenting with the new editor APIs in Visual Studio 2010 to build some simple extensions to make Python editing a little better. Helpfully, IronPython exposes most of the complicated infrastructure (the tokenizer) to make the job easy. The documentation for the new editor APIs is still a bit weak; hopefully that will improve by the final release. In the meantime, the examples are the best source of information. There also a series of blog posts by an Mike Feingold about the NDjango editor for VS2010 that form a great end-to-end example.

Download & Installation
Download IronPython Extensions for Visual Studio 2010 (and the source code; Ms-PL as always) from my BitBucket repository or from the Visual Studio Gallery (direct link). For direct downloads, just run (double-click) the .vsix file to install it into Visual Studio. Otherwise, you can use the extension manager (search for "IronPython") and install it directly from Visual Studio.

Features
The extensions provide three features so far: syntax highlighting, brace matching, and outlining.

In the future I'm planning on adding project support, templates, and (most difficult of all) IntelliSense.

IronPython 2.6 Final Released

IronPython 2.6 is finally out! IronPython 2.6 is a new version of IronPython targeting compatibility with Python 2.6. As well as the new language and library features that come with Python 2.6, IronPython 2.6 has new features for improved performance, general Python compatibility and better .NET integration. It's a great release; congratulations and thanks to the IronPython team.
 IronPython 2.6 final is identical to release candidate 3. Features new to IronPython in version 2.6 include:
  • The __clrtype__ metaclass for data binding and .NET attribute support
  • Implementation of the ctypes module
  • Support for Python stack frames and sys.settrace, which means the pdb debugger works (and better debugging from the .NET side)
  • Better performance through adaptive compilation
  • Faster startup
There are several changes to the samples in IronPython 2.6. These include two new samples:
CommentChecker
Not only will this sample show you how to utilize Word's spell checking functionality from IronPython; it'll also make your own Python code better! You see, this sample processes Python files looking for code comments that contain misspellings. Once these mistakes have been identified Word is utilized again to present you with the correct spellings. All of this is tied together with an elegant, user-friendly interface constructed from .NET's Windows Presentation Framework.
ClrType
The ClrType sample shows how to define a class in IronPython with required CLR members. Normally, a class definition in Python does not map directly to a unique CLR type. This is because the semantics of classes are different between Python and the CLR. For example, in Python it is possible to change the base types just by assigning to the bases attribute on the type object. However, the same is not possible with CLR classes. Hence, IronPython implements Python classes without mapping them directly to CLR types. Using the ClrType sample you’ll be able to define CLR fields, properties, class-level attributes, and declare strongly-typed methods.
Pyc, the IronPython compiler, is no longer available as a sample as "it was incorporated directly into IronPython releases as a tool".

The full IronPython 2.6 release notes:
We’re proud to announce the release of IronPython 2.6 final. This is a major release with improvements across all areas of IronPython. Significant changes include: 
  • Updating the language and standard library to match CPython 2.6
  • Improved .NET integration
  • Updating to the latest version of the DLR
  • Adding previously missing CPython features and fixing bugs
  • Performance improvements in particular startup time improvements
Python 2.6 support includes a large number of new features which include support for the new bytes and byte array types (PEP 3112), decorators for classes (PEP 3129), advanced string formatting (PEP 3101) which will feel familiar to .NET users and integrates nicely with IFormattable, print as a function (PEP 3105), Abstract Base Classes (PEP 3119), support for binary literals, along with lots of other minor features and changes.

IronPython also continues to improve .NET integration in this release. We’ve added the __clrtype__ method to types which enables deep integration via meta-classes with the .NET type system. There are also a number of smaller changes such as supporting IDisposable in for loops matching the behavior of other .NET languages. This release also includes the latest version of the DLR and fixes a number of issues related to cross-language dynamic interop. Not to be left out there’s improvements in Silverlight integration by supporting Python code in HTML script tags.

We’ve also continued to improve Python compatibility by adding missing features and fixing bugs. In this release we’ve added support for the ctypes module which provides interop with native code in a compatible way across Python implementations. We’ve also implemented sys.settrace to provide support for the pdb module and other Python debuggers. This release also changes how we support sys.getframe: a fully working version is now available by a command line option; when not enabled sys.getframe doesn’t exist at all. This release also fixes over 400 bugs removing a large number of smaller incompatibilities.

As always we’ve also continued to improve performance, and this release primarily focuses on improving startup time. The IronPython installer now pre-compiles (ngens) IronPython during installation on both 32-bit and 64-bit platforms. Modules are now interpreted initially and hot functions are compiled for faster import times. A number of other code paths that used to involve runtime code generation have been optimized to be contained within the pre-compiled IronPython binaries. We’ve also made a number of smaller changes which improve performance in other areas such as adding constant folding.

Tuesday, December 01, 2009

Gestalt 1.0 and the Gestalt Widget Pack

Gestalt is a project by Mix Online to use Silverlight and the Dynamic Language Runtime to allow you to script web pages with Python or Ruby instead of with Javascript.
DLR.js is a library released by a collaborative effort between the Dynamic Language Runtime team and MIX Online Labs. This JavaScript library 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.
 Gestalt has reached a significant milestone with the release of version 1.0 and a widget pack. It has matured to the point where you can do really crazy things like run Rails *in your browser*. Probably not specifically useful, but it shows what it is capable of:
A few months ago, we released Gestalt beta as a MIX Online lab.  Gestalt began as an exploration—a way to bring Ruby and Python to the web browser.  Today, we’re delighted to announce that Gestalt has been updated to version 1.0. It's now part of IronRuby 1.0 and IronPython.

What’s new in Gestalt 1.0? Gestalt Beta -- plus more!
  • Supports bundling of Ruby and Python files using each language’s convention.  You can now (for example) package and run Rails on your client!
  • Allows you to dynamically load assemblies (only downloads what you need)
  • Integrated with the Dynamic Language Runtime
    Simplified and streamlined model for creating Gestalt apps.
  • No jQuery dependency.
  • Support for remote references to Gestalt
  • Visual Studio debugging support
  • A browser console for debugging and manipulating Gestalt
  • Rich error reporting
  • Built-in support for loading external assemblies and content
  • Support for running multiple instances of Gestalt on the same page
They also have a longer blog entry discussing the thinking behind Gestalt and what it makes possible. Perhaps worth drawing out from this article is the following: "By adding a <script>
tag to the top of your HTML file, you can automatically enable use of HTML5-compatible video and audio tag syntax.
"
Last week, we discussed the fact that Microsoft invests heavily in both HTML5 and Silverlight, two technologies that other companies would have you believe are mortally opposed.  Our commitment to both was underscored this week by our announcements about IE9 and Silverlight 4.

When we launched Gestalt beta less than 4 months ago, our goal was to demonstrate a really simple idea: that a proprietary plugin like Silverlight complements and advances the standards-based web.  With today’s launch of Gestalt 1.0 and the first few widgets in the Gestalt Widgets Pack, I’d like to drill deeper into this underlying philosophy of Gestalt.