Q-So what is the difference between CPython, Jython, IronPython?
A-These are different implementations of Python. Cpython is implemented in C,Jython in Java,IronPython in C#,pypy in RPython.
Q-What just happened!!
python is implemented in java???,so why don’t we call it java then ? And what does “implemented in java” even mean?
What What What!!!!
First of all, a “Language” is not what you think it is.
When you go to official website , to download a “version” of python(2.x or 3.x),what you get is not “The Python Language”.
A language is a set of strings, defined on a set of symbols ,called Alphabet . Languages have a “grammar” associated with them. This grammar is defined as a tuple (N,T,S,P).
N is a set of variables or non-terminal symbols.
T is a set of Terminal symbols.
S is a special variable called the Start symbol, S ∈ N
P is Production rules for Terminals and Non-terminals. A production rule has the form α → β.
Q-*interrupts* …wait,STOP! !………talk in English!!!
A-OK…lets talk in, and about English……English language has Alphabet containing 26 symbols,which we call letters.These symbols are arranged in some order ,in a sequence to form a word(string) and a sentence respectively.
We have a grammar to tell us how to arrange the elements to form a meaningful sentence.
Programming Languages work the same way.
[simplicity warning!! Languages like English fall in an entirely different category(see chomsky hierarchy ).But computer languages can be approximated to modern ,informal language like English.As the syntax,and sentence structure of these informal languages can be defined by computer languages(CFGs).]
Python Language is just a set of symbols,with a set of rules.
You can make sentences in Python,like you make in English.But then??What next??What to do with that sentence??Where to put it??Who will recognize it??
Here comes the Implemented part.
The “recognizer” for whatever beautiful mess you created with the language is called the Implementation.
This recognizer is also written in some language(as this recognizer did not come from heavens,we humans made it.And it is in computers,so we must have used something,which is used by humans to talk to computers.A computer language.Now what were the languages available to us when we were building a recognizer for Python?
You got it..
C (lets not fight and say C)
Q-ok so what,why and how this recognizer of yours work??And what about Jython??IronPython??Why only C??Are you dodging my questions!!!
A-I am not.
lets just say that our recognizer translates our “Python” sentences into something alien(called bytecode ,stack-machine based instruction set)and then tries to do what we intended.
our sentences →bytecode(which acts like ISA) — get executed by — →Interpreter.]
why do we translate??CONVENIENCE and efficiency dictate us to do so.
Now we are not limited to C…People made a recognizer in Java,named the recognizer Jython.
Jython compiles your Python sentences to Java bytecode(the alien language 2…this will be a different ISA,intended to work on different machine), so your Python code can run on the JVM(that different machine).
IronPython ,recognizer in C# lets you run Python on the Microsoft CLR.
Don’t worry about Microsoft CLR and JVM,just assume they are “Computers”.
We even made a recognizer in Python itself(RPython to be precise,but you can say we made “python interpreter for python”).And it is faster (people like to debate on this,but lets just say it is.)than our first recognizer we made in C,check out this image:
Q-You explained everything ,but i am not satisfied with the ISA part!!!
A-You shouldn’t be …But you must understand ,these are vast topics…there are 6 months/1 year courses dedicated to these topics,just to grasp the fundamentals..
we worked on “differences between python interpreters”…Next time we will work on Interpreters ,compilers, ISAs, Microarchitecture and why the sentence “Python is an interpreted Language” is not fully correct.
Now say goodbye to this person staring at us