[Baypiggies] Official Language War Thread?- Rails vs.Turbogears.

Jimmy Retzlaff jimmy at retzlaff.com
Fri Dec 2 00:31:24 CET 2005


David E. Konerding wrote:
> 1) when I recently read the C# introduction, I get very, very scared,
> since I found myself having a very hard time taking issue with any of
> their design decisions wrt to OO.  I assuaged my fear by realizing C#
is
> a static language (albeit one with a complete parser and compiler
built
> in)

Why would liking features in a language cause you to feel scared? I can
certainly understand fear induced by static typing. :)

> 2) after playing with IronPython and the .NET API for a while I found
> myself preferring the .NET API for achieveing pretty much everythign
in
> the CPython standard library (and enjoying the raw speed of the CLR
> compared to the CPython VM).  I am now stuck in a very difficult
state:
> I have a great deal of legacy C code that interfaces with the CPython
> interpreter and I'd have to rewrite all the interfaces, and I have
lots
> of code that uses parts of the standard CPython library but which will
> probably not be implemented in IronPython.
> 
> It makes me wonder; if IronPython covered the CPython standard library
> completely, wrapped the CPython extension system so that
> my existing _whatever.so's and _whatever.dlls could be used without
> recompilation, and Mono implemented enough of the .NET library that
all
> my existing code continued to work fine, what would I need CPython
for?

You might want to take a look at Python for .NET at
http://www.zope.org/Members/Brian/PythonNet. I recently had a client
that insisted the config files for my Python application use the same
encryption for passwords that all their C# code uses. They gave me their
C# code which depends completely on the .NET crypto libraries and I
started looking for ways to build a bridge. I'm glad I found Python for
.NET. I basically took their code, removed type declarations and
semicolons and I was done. Here are a few lines from the C# code:

ICryptoTransform encryptor = new RijndaelManaged().CreateEncryptor(key,
IV);
MemoryStream msEncrypt = new MemoryStream();
CryptoStream csEncrypt = new CryptoStream(msEncrypt,
                                          encryptor,
                                          CryptoStreamMode.Write);

and the analogous lines in Python:

encryptor = RijndaelManaged().CreateEncryptor(key, IV)
msEncrypt = MemoryStream()
csEncrypt = CryptoStream(msEncrypt,
                         encryptor,
                         CryptoStreamMode.Write)

You don't get Python hosted within the CLR, so you don't get the same
language interoperability among other things, but for library access it
works beautifully. And you can still use your own extensions, Numeric,
PIL, etc.

Jimmy


More information about the Baypiggies mailing list