Search code examples
c#pythonironpythonlanguage-designdynamic-language-runtime

What it means - "IronPython is an implementation of the Python programming language"


I know question looks to be broad and subjective, but am stuck with this definition of IronPython everywhere - "IronPython is an implementation of the Python programming language" Please feel free to mark this as duplicate if any SO post answers this question precisely.

My understanding around this so far have been :

1) Iron python is nothing but managed libraries (IronPython.dll) written in C# and uses CLR

2) Iron python managed code internally makes use of standard Python libraries (installed as part of Iron Python) to bridges gap using DLR.

What is actual execution run time for any python code here ? Is it Python interpreter ? Does this interpreter runs in different process ?

3) IronPython.dll exposes api to integrate with python code with any other .net language.

I am sure somewhere my understanding is not correct to justify - "IronPython is an implementation of the Python programming language" Because from this it appears like Python language is kind of contract which specifies how you write check condition if condition and implementors like iron python take care of transforming it into IL code. Is this the case ?

Appreciate any help or pointer on this.


Solution

  • Think of programming languages not as actual software, but as "specifications". This kind of means that I can just specify a programming language, but not necessarily implement it. To implement a language means to write a program that takes code of that language and "run" it exactly as the specification says.

    The csc compiler is not C# the programming language itself but an implementation of the C# programming languages. The C# programming language is defined by the C# Language Specification. The language spec defines what the language is. And implementations of that language should compile/interpret the code exactly as the language spec says. In a sense, the language spec is the programming language.

    IronPython is an implementation because it's a program that takes a string of python code as input and then behave exactly as the python specification says. That's what's meant by "an implementation".

    What Iron Python does is this:

    An alternate Python for .NET. Unlike Python.NET, this is a complete Python implementation that generates IL, and compiles Python code directly to .NET assemblies.

    So Iron Python takes some python code, does some stuff to it, and spits out IL that behaves exactly as the language spec says. This makes Iron Python an "implementation" of the python language.

    CPython is regarded as another implementation of python because it does essentially the same thing: takes some code, transforms it into an executable that behaves exactly as the language spec says.