5 ms·
Why not use C++? For the most part, these aren't security critical components. You already have a massive amount of code you can use like say llama.cpp You g
by RcouF1uZ4gsC 2y ago
Why not use C++?
For the most part, these aren't security critical components.
You already have a massive amount of code you can use like say llama.cpp
You get the performance that you do with Rust.
Compared to Python, in addition to performance, you also get a much easier deployment story.
- oersted 2y agoIf you already have substantial experience with C++, this could be a good option. But I'd say nowadays that learning to use Rust *well* is much easier than learning to use C++ *well*. And the ecosystem, even if it's a lot less mature, I'd say is already better in Rust for these use-cases. Indeed, here security (generally safety) is a secondary concern and is not the main reason for choosing Rust, although welcome. It's just that Rust has everything that C++ gives you, but in a more modern and ergonomic package. Although, again, I can see how someone already steeped in C/C++ for years might not feel that, and reasonably so. But I think I can farely safely say that Rust is just "a better C++" from the perspective of someone starting from scratch now.
- outworlder 2y agoIndeed. Plus, one doesn't usually just 'learn C++'. It's a herculean effort and I've yet to meet anyone, even people exclusively using C++ for all their careers, that could confidently say they "know C++". They may be comfortable with whatever subset of C++ their company uses, while another company's codebase will look completely alien, often with entire features being ignored that they used, and vice versa. Despite that, it's still a substantial time commitment, to the point that many (if not most) people working on C++ have made that their career; it's not just a tool anymore at that point. They may be more willing to jump entire industries rather than jump to another language. It is a generalization, but I have seen that far too often at this point. If someone is making a significant time investment starting today, I too would suggest investing in Rust instead. It also requires a decent time investment, but the rewards are great. Instead of learning where all the (hidden) landmines are, you learn how to write code that can't have those landmines in the first place. You aren't losing much either, other than the ability to read existing C++ codebases.
- riku_iki 2y ago> But I'd say nowadays that learning to use Rust well is much easier than learning to use C++ well. For someone(me) who was making a choice recently, it is not that obvious. I tried to learn through rust examples and ecosystems, and there are many more wtf moments compared to when I am writing C++ as C with classes + boost, especially when writing close to metal performance code, rust has many abstractions with unobvious performance implications.
- IshKebab 2y agoRust is much better than C++ overall and far easier to debug (C++ is prone to very difficult to debug memory errors which don't happen in Rust). The main reasons to use C++ these days are compatibility with existing code (C++ and Rust are a bit of a pain to mix), and if a big dependency is C++ (e.g. Qt).
- pjmlp 2y agoAdditionally the industry standards on GPGPU APIs, tooling ecosystem. Maybe one day we get Live++ or Visual Studio debugging experience for Rust, given that now plenty of Microsoft projects use Rust.
- IshKebab 2y ago> Maybe one day we get Live++ or Visual Studio debugging experience for Rust I don't know what Live++ is but the Rust debugging experience is already better than C++. In VSCode I can just click "Debug Test" next to a test and it magically all works. It's never that slick in C++, even in Visual Studio.
- pjmlp 2y agoVSCode is a joke versus Visual Studio proper, try to do hot code reloading in Rust, dive into GPU, parallel debugging, trace points, this is the kind of stuff Live++ or VS offer.
- Philpax 2y agoWhy use C++? What's the benefit over Rust here?
- timonv 2y agoI've worked with C++ in the past, it's subject to taste. I like how Rust's rigidness empowers rapid change _without_ breaking things. Besides, the ML ecosystem is also very mature. llama.cpp has native bindings (which Swiftide supports), onnx bindings, ndarray (numpy in Rust) works great, Candle, lots of processing utilities. Additionally, many languages are rewriting parts in Rust, more often than not, these are available in Rust as well.
- roca 2y agoLots of reasons, but a big one is that dependency and build management in C++ is absolutely hellish unless you use stuff like Conan which nobody knows. In Rust, you use Cargo and everyone is happy.
- pjmlp 2y agoThere are lots of things I don't know until I learn how to use them, duh. Cargo is great, for pure Rust codebases, otherwise it is build.rs or having to learn another build system, and then people aren't that happy any longer.
- riku_iki 2y agoYou can always use something as simple as Make for your C++ proj with manually dumping dependencies to some libs folder.
- roca 2y agoThat doesn't solve the problem of making it easy for people to download and build the dependencies.
- riku_iki 2y agoThe idea is that dev packages dependencies in lib folder, so when people retrieve sources, they also retrieve all dependencies. But you are right, that this is some extra work for dev, so this is question of trade offs: do you want to deal with all C++ build tooling mess, or you are Ok to do some manual steps. Another alternative is to use some popular stable linux distro as build platform, then many libs will be packaged as part of that distro.