Sunday, February 01, 2009

YAAS (Yet Another Awesome Selection)

I've nearly caught up with my backlog, but in the meantime there have been several selections full of smaller entries and snippets. Here's the first one.
Two new pages on the IronPython cookbook showing how to use COM interop to automate Microsoft Word.
I've featured various non-English articles on IronPython before, but I think this is the first one in Russian. This article shows how to use IronPython to provide macros for C# .NET applications. The example shows Python scripts adding menu items to a notepad style app.

I'm not sure of all the details, this is the best google translate could manage for part of the article:
Create your tongue + interpretor to him with an opportunity. NET interoperability - non-trivial task, leave it for the enthusiasts.
The code is all shown though, so it should be easy to figure it out.
Steve Gilham continues his adventures of experimenting with Scala, Jython, and IronPython all using the same codebase...
in my quest for a cross-VM (JVM and CLR), single code-base, polyglot language stack, which doesn't involve any more Java than can be helped.

To summarise where we are, and what we have discovered to date --
  • Python can call Scala and Java happily
  • Java calling into Python is funky and platform dependent; doubly so for Scala
  • Scala cannot both call into java.* classes and compile on .net
  • Low-level Scala pre-defs differ in the Byte type (signed in Java/J#/Scala-JVM, unsigned in Scala-msil)
  • Ruby's predilection for Pascal-case namespaces (fudged in JRuby to match Java's lower-case convention) would require a lot of plumbing around in C# to mate IronRuby to J# or Scala-msil (as the rest of .net uses Pascal-casing).
A very simple example showing how you reference .NET assemblies from IronPython, and import and use classes from the namespaces in the assemblies.
Darren Hawley leaves himself a note on using the IronPython compiler and reccomends SciTE as an IronPython IDE rather than the IronPython Studio.
Those of you interested in how dynamic languages are influencing the .NET framework may be interested in this article on the IDynamicObject interface. Specifically it shows how to implement the GetMember method to provide dynamic behavior for objects declared as dynamic. GetMember is the equivalent of __getattr__ in Python.
OpenBabel (a .NET library described as "The Open Source Chemistry Toolbox") already supports IronPython (example) and Noel O'Blog is looking at explicitly supporting Linux and Mac OS X through Mono.

1 comment:

  1. Correction: OpenBabel is a C++ library (we just use Swig to create C# bindings which we compile into a DLL).


Note: only a member of this blog may post a comment.