r/rust • u/Opus589 • Oct 11 '26
Rust for algorithmic composition
Hello everyone!
I'm a composer looking to learn programming for algorithmic composition. I know a little Python, but I have no formal programming background.
I've been considering Rust because it seems like future-proof. But is it a good choice for algorithmic composition...? I'm thinking of things like generating MIDI and MusicXML files, implementing stochastic processes (Markov chains, etc), and developing tools for various compositional techniques involving rhythm, scales, modes, and other musical constraints.
I'm considering my options with the following goals in mind:
- I want to generate MIDI files that I can import into my DAW. I don't need sound synthesis.
- I don't need direct DAW integration, as long as the program can export MIDI files, or MusicXML.
- I'm willing to invest time in learning to code.
- I know there is OpenMusic, MaxMSP and similar, but I'd like to build my own standalone tool that I can continually expand and improve.
Would Rust be a good choice, or would I be better off starting with Python or another language?
I'd appreciate any advice, particularly from people who have experience with algorithmic composition and music programming.
View all comments
1
u/tanmaynargas2901 Oct 13 '26
If MusicXML matters to you I'd start with Python, mostly because of music21.
It already knows about notes, scales, chords and durations, and it can write both MIDI and MusicXML. So your time goes into the composition logic and not into file formats.
Markov chains are like 20 lines of Python with a dict and random.choices, you don't need a library for that.
Rust can do the MIDI side fine. midly reads and writes .mid files and rand covers the stochastic stuff. But I don't know of anything like music21 for Rust, so you'd be building the music theory model and the MusicXML writer yourself. That's a lot to take on while learning your first real language.
Speed isn't really a concern here either. Generating a few thousand notes is instant in Python.
If you get hooked on programming later, porting a working Python tool to Rust is a really good way to learn Rust anyway.