Mercurial choosing Rust over Python

According to this article in Mercurial wiki, its core is being re-written in Rust. Mercurial is one of the largest open-source Python projects in existence.

This does not however mean everything will be rewritten in Rust. (Yes, this post’s heading’s not entirely accurate.)

* hg is a Rust binary that embeds and uses a Python interpreter when appropriate (hg is a Python script today)

* Python code seemlessly calls out to functionality implemented in Rust

The obvious reason for the decision is startup performance concerns, but the article also (interestingly) states:

In addition to performance concerns, Python is also hindering us because it is a dynamic programming language. Mercurial is a large project by Python standards. Large projects are harder to maintain. Using a statically typed programming language that finds bugs at compile time will enable us to make wide-sweeping changes more fearlessly. This will improve Mercurial’s development velocity.

Git was also designed with a core written in C and a host of shell scripts that call the core for additional functionality. For example, rebase is actually a shell script.

However, usage of shell scripts has made porting Git to Windows a pain. See the Lessons Learned section in this AOSA article.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *