3 ms·
It's almost certainly a much more tractable problem to get C code compiling with a C++ compiler, and then gradually transitioning to C++ and the STL over time.
by kelnos 5y ago
It's almost certainly a much more tractable problem to get C code compiling with a C++ compiler, and then gradually transitioning to C++ and the STL over time. I would love to see greater Rust adoption (especially in things that deal with untrusted peers on a network!), but that project is likely orders of magnitude larger than what the author has chosen to take on.
Also it seems like the author is already well-versed in C++; learning Rust might not be a priority for them, and would certainly slow things down a lot.
And while there are certainly plenty of footguns and unsafe things you can do in C++ (even unintentionally), it's probably still safer than C, even if it's not as safe as Rust.
- ryandrake 5y agoAnd just to be that overly pedantic nit-picker, when most people refer to the "STL" today, they are really talking about the C++ Standard Library[1], which is related to and based on the conventions of the old-school Standard Template Library (STL), but a different thing. When you #include <vector> on most modern development platforms, you are not using the actual historic STL implementation. 1: https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library
- FpUser 5y ago>"And while there are certainly plenty of footguns and unsafe things you can do in C++" If I want to shoot myself in the foot I should have full rights and the ability to do so. In a normal coding however modern C++ is very reasonable language and I do not recall stepping onto any landmines in a last few years even though my code runs high load / high performance business servers that also do a lot of calculations.
- ncmncm 5y agoThis. It is quite easy to steer clear of unsafe constructs, and is less work. The people who trigger footguns are mostly those trying to code as if they were still coding C. Their code is typically slower, too.
- kelnos 5y agoUnless you are a perfect programmer, you will sometimes make a mistake, and shoot yourself in the foot even though you didn't intend to. Perfect programmers don't exist. Everyone will screw up sometimes. With Rust, I know that my code will be free of memory errors and data races as long as I never use `unsafe`. No one can say the same about a C++ program, not with certainty. If you don't care, that's fine (I guess), but please don't get all huffy with those of us who do. I think it's telling that you seemed to need to get all defensive even considering that my original post was in support of the libtransmission author using C++ instead of Rust.
- hutzlibu 5y ago" No one can say the same about a C++ program, not with certainty." Formal proof is a thing, so I think you can. "Hello world" would be easy to verify. Verifying transmission on the other hand, is a kind of big project on its own, though. And I agree, that there are no perfect programmers around, but I would also agree to parents point, that if I want to have full power, I fully want to remain my right for footguns. It all remains a tradeof. The ecosystem of C++ is just incredibly bigger than rust, so a new game, I would start in C++, but for something critical I would probably also choose rust.
- junon 5y agoJust because you can't rely on the compiler to tell you, doesn't mean memory errors exist. There's this weird idea Rust programmers have that since C++ doesn't force you to write less performant code by bowing down to a borrow checker that isn't smart enough to handle e.g. single threaded futures and locking properly, that it is IMPOSSIBLE to write memory safe C++ code. A piece of code without memory errors is, by definition, memory safe. This whole idea of "every piece of code has bugs" is some new-wave tripe coming out of code camps and the web development scene.
- vlovich123 5y agoI would go with a transpiler approach first (eg https://c2rust.com/ https://c2rust.com/) and then gradually transition pieces to use the Rust standard library and to safe code instead of the adhoc custom containers. Still, that all would be predicated on having good Rust experience or using it as a learning experience and that may not be the motivation of the authors.
- pizza234 5y ago> gradually transition pieces to use the Rust standard library and to safe code Is this realistically possible on a non-trivial project? I suppose that porting to safe Rust requires a radical rearchitecture of the code.
- kitsunesoba 5y agoI have no experience converting a C or C++ project to Rust but have transitioned Objective-C projects to Swift and have found that even with Obj-C's newer additions to improve Swift interop, making the project as a whole safe is difficult until you've factored Obj-C out of all critical paths. It's just too easy for things to go wrong in the Obj-C half or in the Obj-C → Swift interop. So almost unavoidably you end up with two refactors: first, the piecemeal rewrite in the the safer language, and then a second when the original language has been rooted out and you can take advantage of all of the features of the new language.
- deleted 5y ago[deleted]
- dzhiurgis 5y ago> especially in things that deal with untrusted peers on a network! Are there any practical torrent clients that I can run in docker container?
- felipelemos 5y agoTransmission itself. I highly recommend the image built by the linuxserver.io: https://hub.docker.com/r/linuxserver/transmission https://hub.docker.com/r/linuxserver/transmission