biotite-dev / biotite

A comprehensive library for computational molecular biology
https://www.biotite-python.org
BSD 3-Clause "New" or "Revised" License
679 stars 101 forks source link

Introducing Rust code into Biotite #688

Open padix-key opened 2 weeks ago

padix-key commented 2 weeks ago

To achieve high performance where vectorization with NumPy is not possible, Biotite currently uses Cython code. However, there are some limitations in Cython:

Hence, this issue should initiate the discussion if Rust code using PyO3 should be allowed in Biotite, as it has become quite mature in recent years. This would address all the issues mentioned above. More specifically, these are the places in the code base where the limitations become quite clear:

Probably even more places in Biotite would benefit from routines written in Rust. However there would also be a few disadvantages:

I lean towards accepting Rust in Biotite (otherwise I would not have opened this issue :wink:), but I really like to hear your opinion about this @t0mdavid-m @JHKru @MaxGreil and other contributors/users with an opinion on this topic.

t0mdavid-m commented 2 weeks ago

I am not worried about the increased complexity of another programming language. Speed is a major selling point of Biotite - therefore moving from Cython to C++/Rust bindings seems to be a logical next step.

When deciding between C++ and Rust, given we do not have preexisting legacy code in either langugage, Rust, due to its memory safety, seems to be the logical choice.

I think keeping the build complexity for all user groups low is also quite important. However, https://github.com/PyO3/maturin/pull/2177 seems to be quite active. So given that it is merged, I would vote for adding Rust code to Biotite.

JHKru commented 2 weeks ago

Hi, I haven't contributed anything on the Rust side so far, but the arguments for accepting Rust sound convincing to me. :)

Do you plan to still accept Cython in new contributions in the long-term? If feasible maintenance-wise, I'd be in favour of accepting both Cython/Rust, to have more options for new contributors and cases for which Cython is not too limiting.

padix-key commented 2 weeks ago

Do you plan to still accept Cython in new contributions in the long-term?

Yes, at least for the foreseeable future. However, I think @JacobAnter and me were the only ones contributing Cython code to the project so far. So realistically, if at some point most Cython code would be migrated to Rust code, we could discuss again, whether we discourage new Cython modules.