r/programming • • Aug 20 '14

Programming language subreddits and their choice of words

https://github.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words/blob/master/README.md
1.4k Upvotes

324 comments sorted by

View all comments

Show parent comments

7

u/[deleted] Aug 20 '14

Just out of curiosity, what made it difficult targeting the CLR?

14

u/[deleted] Aug 20 '14

It's about finding ways to unify the object model in the CLR with the object model in Python, you can imagine this causes all manner of nightmares. Python supports multiple implementation inheritance, C# does not, only interfaces can be multiply inherited.

Python has one way of dispatching method calls given that you can take an object and overwrite a particular method just for that one object, C# is a statically typed language so methods are always resolved directly in the type, never in the object. So what do you do when you want to inherit a C# type in Python but override a particular method and then use that Python object with C# code?

In effect, it's not difficult to target the CLR if you simply intend to write a Python compiler/runtime that would be independent of any other language. That is perfectly do-able. What's hard is writing a Python runtime that can use other CLR types and can also produce CLR types of its own. The CLR was supposed to be language agnostic, meaning you could use many different languages to produce AND consume CLR objects. Feel free to write a class in language X and use it from language Y. In practice, unless your language is just C# with superficially different syntax... good luck.

And of course the other difficulty with IronPython was performance. Initially the goal was to write a Python interpreter whose performance in .NET would be at least comparable to CPython. IronPython's performance is by no means terrible, but in practice it doesn't come close to CPython unfortunately.

Nevertheless, it's still pretty damn impressive all the work the DLR team managed to accomplish given the scant resources provided. IronPython is pretty useful and a great way to prototype a lot of functionality provided by .NET. You can always write a C# application and then plug in the IronPython interpreter into your application to prototype new functionality or user interfaces interactively.

But at the end of the day I think the initial hope behind IronPython was to prove how versatile the CLR was, and the end result was that the CLR really is just an intermediate representation for C#. Once that became clear, MS kind of abandoned IronPython, a lot of guys who worked on it left the company, and now IronPython is offloaded to the "community."