4 ms·
> write non duplicated code ... Like how many string implementations are there across c code bases. In one of projects I needed foo::string that can share data
by c-smile 8y ago
> write non duplicated code ... Like how many string implementations are there across c code bases.
In one of projects I needed foo::string that can share data with foo::variant without copying the data each time. So foo::string was implemented as a COW string - smart pointer for foo::string_data. std::string simply does not work in such requirements.
So I am not sure I understand how cargo will help in this case. Either Cargo source repository will contain implementations of any possible permutation of requirements of strings or people will just use standard std::string.
The only feature that I need in C/C++ is unified ability to include libraries in code:
#define PNG_APNG_REQUIRED
#include source "libs/png/png-amalgamated.c"
I am perfectly fine with downloading png.tar.gz manually and putting it in place where I need it.
In any case decision to include library to a product requires quite a lot of reasonings and architectural investigations.
For typical web front-end projects NPM or Cargo probably make sense. But for, say, NodeJs or Cargo itself they should not use any such automatic downloader.
- adamnemecek 8y agoYour problem isn't hard to solve in Rust. Reasoning about allocations is a foundational idea of Rust and is solved using lifetimes. Basically, lifetimes are allocators as a first-class language construct. You can reason about what happens if values are stack or heap allocated and specialize your code based on that. Lifetimes are definitely an advanced feature and I think you can do some crazy optimizations with them. But your use case is not hard to implement. If you show me the C++, I'll show you how to achieve the same semantics. Cargo helps because Rust lets you build cleaner abstractions and abstractions that compose nicer. So integration is super easy. > For typical web front-end projects NPM or Cargo probably make sense. I might misunderstand your sentence, but neither Rust nor cargo are for front-end?
- steveklabnik 8y agonpm is used a lot for front end code, incidentally. Node is an environment for a lot of build tooling.