Rust for audio
Posted: Tue Sep 22, 2020 6:29 pm
I am currently studying Rust and I like it a lot! I like the syntax, not "beautiful" in any sense but it can easily be picked up by people who know C++ and OCaml, Scala or Haskell; I think that Rust is pretty clean and benefited a lot from not having to be backward compatible with C and older versions of C++ and that it has a lot of potential for audio programming, too, since it is a functional language.
I will continue studying Rust because I think I can learn a lot from it. Aside from that, it often leads to cleaner and safer code - C++ has too much stuff and it's very hard to keep up with it, especially since the old ways (from C++03 and C++11) are sometimes radically different from the new ones and template metaprogramming isn't exactly developer-friendly
Also, five C++ programmers in the same room would have completely different styles, while Rust has pretty good official documentation that sets a common standard.
Anyway, most of those would be good reasons to switch to Rust, except for these things I have heard:
1) The Rust community is a bit like NodeJS' - they use their package manager a lot to provide basic functionalities in small libraries, to the point that a typical program might have dozens of dependencies
2) Many Rust libraries use "unsafe" and this defeats part of the purpose of using Rust
3) Rust has slow compile times (C++ has the same problem, as far as I can remember, also long error messages)
If those are true, what would be the benefit of using Rust instead of C++20 with the strictest compiler options? Sure, it's harder to write safe C++20, its functional code looks a bit weird and C++ has no packages but I feel like the benefits of learning Rust wouldn't outweigh the costs if most audio libraries are written in C or C++ anyway. Additionally, even if Rust is growing there simple are more C++ programmers around, from my own experience - Rustaceans are aplenty for a new language (pretty vocal too) but it still isn't used in any major FLOSS project except Mozilla's own Servo - so there is a concrete risk of the language losing developers once the hype train slows down (I've seen it happen with many other languages now).
In short, now that C++20 allows memory-safe functional programming, why learn Rust? Above all, pardon my ignorance and please correct my views!
I will continue studying Rust because I think I can learn a lot from it. Aside from that, it often leads to cleaner and safer code - C++ has too much stuff and it's very hard to keep up with it, especially since the old ways (from C++03 and C++11) are sometimes radically different from the new ones and template metaprogramming isn't exactly developer-friendly
Anyway, most of those would be good reasons to switch to Rust, except for these things I have heard:
1) The Rust community is a bit like NodeJS' - they use their package manager a lot to provide basic functionalities in small libraries, to the point that a typical program might have dozens of dependencies
2) Many Rust libraries use "unsafe" and this defeats part of the purpose of using Rust
3) Rust has slow compile times (C++ has the same problem, as far as I can remember, also long error messages)
If those are true, what would be the benefit of using Rust instead of C++20 with the strictest compiler options? Sure, it's harder to write safe C++20, its functional code looks a bit weird and C++ has no packages but I feel like the benefits of learning Rust wouldn't outweigh the costs if most audio libraries are written in C or C++ anyway. Additionally, even if Rust is growing there simple are more C++ programmers around, from my own experience - Rustaceans are aplenty for a new language (pretty vocal too) but it still isn't used in any major FLOSS project except Mozilla's own Servo - so there is a concrete risk of the language losing developers once the hype train slows down (I've seen it happen with many other languages now).
In short, now that C++20 allows memory-safe functional programming, why learn Rust? Above all, pardon my ignorance and please correct my views!