0

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.

rahulaga-msft
  • 3,964
  • 6
  • 26
  • 44
  • https://stackoverflow.com/questions/17130975/python-vs-cpython – Alex Mar 03 '18 at 08:26
  • @Alex : Thanks. post says _IronPython lets you run Python on the Microsoft CLR_ which means something must be translating python code (and referred python libraries) to IL code. Is this something completely take care of at run time by DLR ? – rahulaga-msft Mar 03 '18 at 08:45

1 Answers1

5

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.

Sweeper
  • 213,210
  • 22
  • 193
  • 313
  • _So Iron Python takes some python code, does some stuff to it, and spits out IL_ if I am not not wrong, it precisely means that Iron Python is c# managed code running running in context of DLR to transform python code into IL ? – rahulaga-msft Mar 03 '18 at 10:28
  • 1
    @RahulAgarwal Yeah. – Sweeper Mar 03 '18 at 10:28
  • Also I kind of perceive this somewhat similar to how IQueryProvider taking care of converting expression tree into target platform language (like T-SQL in case of entity framework) – rahulaga-msft Mar 03 '18 at 10:41
  • I can see at several places IronPython is referred as Dynamic Language - are these just loose terms ? because i built up my understanding as IronPython is like compiler for python language. Shouldn't IronPython will have lexer, parser for python code in that case ? – rahulaga-msft Mar 19 '18 at 10:05
  • 1
    @RahulAgarwal Yes it will have a lexer and parser. – Sweeper Mar 19 '18 at 10:28