So, this is something that we've considered for a while now, after all these 
years writing production code in Nim, we long for Python's lack of static 
checking; in the end there is always a Nim code snippet that tests the part of 
the Nim compiler we touched anyway, the static type system doesn't speed up 
Nim's core development. Python is simply more productive to work in, especially 
considering its ecosystem. For example, we want to add machine learning to the 
Nim compiler, if the Nim compiler were written in Python, it would be as simple 
as `import machinelearning`.

However, it is well known that Python code can sometimes be slow if it's CPU 
bound. So these CPU bound parts of the Nim compiler will be written as Python 
extension modules in C. Writing a product in two vastly different programming 
languages allows us to use each language for the part where it shines, C for 
speed, Python for the glue code. The perfomance critical parts inside the Nim 
compiler are probably: The lexer, the parser, the semantic checker, the 
overloading resolution mechanism, the VM for macro evaluations and the code 
generators. Thankfully C is a well understood language with a friction-less 
type system, for example, I think we can get away with modelling the Nim AST in 
C via a single `void*` type.

We have been working on this in the last couple of months secretly and these 
improvements will be part of the upcoming version 1.2 release. 

Reply via email to