Le keskiviikkona 22. lokakuuta 2025, 15.09.32 Itä-Euroopan kesäaika Gregor Riepl via ffmpeg-devel a écrit : > > My main motivation is to be able to use STL, which would simplify > > string handling and memory management, and give us access to its data > > structures. Manual memory management has its place, especially in lavc. > > In lavf less so. RAII would do wonders in de-gotofying error handling. > > Features like std::filesystem, std::chrono, std::thread etc abstract > > away many OS particularities. Thorough STL-ification would render parts > > of lavu obsolete. avstring.*, bprintf.* and tree.* come to mind. This > > would have security benefits. Another reason is stronger typing, which > > tends to reveal bugs. > > Just for the sake of the argument: Wouldn't it be better to opt for an even > safer language than C++, like Rust?
Yes. If the goal is to use better abstraction, notably for data structures and memory handling, than are possible with C, then Rust provides zero-cost abstractions. In C++, you can't do that; for instance, your virtual methods may or may not be specialised, and you have no control over it. Also C++ provides a lot of abstractions that are nowadays widely considered just *bad*, even by C++ advocates, such as multiple inheritance. Rust also doesn't need its own runtime library, so it would be essentially transparent for (binary) downstreams, whether statically or dynamically linked. And it's actually easy for experienced C programmers to learn (been there, done that). The static memory safety features are just icing on the cake. The big difficult is integrating dependency tracking from rustc, compilation (rustc or cargo) and linking into an existing build system. But that's a one- time cost for one motivated person to deal with. Sure, C++ would be much easier with respect to that one specific aspect, but so what? > C++ has received a lot of criticism in being just as memory unsafe as C, and > I personally think that it adds an epic amount of complexity to writing > correct code. Although - that may or may not be the case depending on where > and how it's used in the code base. +1 -- 德尼-库尔蒙‧雷米 Tapiolan uusi kaupunki, Uudenmaan entinen Suomen tasavalta _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
