Part of the 10MB is your own source code. the process of doing the same thing, you have to express the same information.
I’m finding it harder to reach an end result, as such have given up trying to do some things that I find easy in C++.
some of the libraries are to big and bloated, it is the fact they try to be all things to all people that makes them hard to use.
I can write templates that handle the cases I need.
**My motivation to use Rust, sorted by priority:- **
- [1] no header files
- [2] better lambdas (via 2-way inference, and just plain better syntax |x|…)
- [3] ‘immutable by default’ , unsafe globals (thats the one restriction I DO agree with)
- [4] enum/match (this feature is awesome)
- [4.1] ‘everything is an expression’, i’ll list it here where it shines.
- [5] better macro system/ ‘reflection’ type uses cases, e.g. easy serialisation.
- [6] tuples (I really enjoy the ability to anonymously group values, in a syntactically lighter way than ‘std::pair()’)
But to get these - I’m finding the traits (loss over general overloading) and full safety a hinderance; and I can’t just wrap unsafe{} and use raw pointers because the remainder of the raw pointer use has been (seemingly) . Either one of those on their own might be ok; it’s the combination of both that begins to seem oppressive.
C++ is used for control, but damaged for productivity in awkward ways by mere syntax (headers, misuse of premium [] , chars). I really do just want C++ cleaned up. rust came with a load of ‘bonus features’ (like match) which are very interesting.
It should be possible to pick and choose exact blend of features I want. Software is the most malleable medium on this planet.
What happened along the way is some features I liked got removed (~T ~[T] … syntactically light smart pointers and vectors counted for a lot, playing well with () to make light function signatures … I would have gone further and added [K=>V] for maps giving very light signatures for a lot of common code, note Swift does also have [K:V] so my notion isn’t entirely spurious … a tech giant agrees; ‘do notation’ for internal iterators… dropping the nesting level for lambda-based code; Whilst some features landed in C++ … which is why I didn’t stick with it originally)
At the moment, nothing stops you from creating an unsafe library
(addressed above: beyond merely needing ‘unsafe’, the language syntactically discourages raw pointers in other ways)
for a better insight into my POV, I agree with about 90% of what he says https://www.youtube.com/watch?v=TH9VCN6UkyQ&list=PLmV5I2fxaiCKfxMBrNsU1kgKJXD3PkyxO … he discusses how he considered Rust,D,Go as alternatives and why he rejected all 3 to continue.
All it would take is a few options to relax things and it would open this language up as a definitive choice. Just unleashing the full inference alone would make things more pleasant ( i note in haskell, you don’t actually have to implement all the functions in a typeclass; we can do ‘unimplemented!()’ but we could recover the C++ use case as an ‘opt-in’ if there was a ‘compile time failure’ - a stronger ‘unimplemented’ ).
Sure, having the types in functions is a reasonable compromise but sometimes you have working code, but then you want to extract a function… but that’s hard to do because you now have to figure out the signature (which might have complex intermediate types)…
As it stands… I have to keep going with C++ (modules will fix [1], I can resort to a #define for compact single-expression lambda), and possibly wait for his language (his goals align more closely) … or even continue with my own (which would get no other users, but I could inter-op with C++ better by supporting more of the feature set https://github.com/dobkeratops/compiler).
I hear that Swift is actually going to get move/move-semantics, that might be another option
Then the library adds 2 features, one of which you want to use and need and one which now uses some other “unsafe” library. Suddenly, in your use case of the library, you get a security vulnerability
I don’t see that happening, surely the ‘unsafe’ can be correctly flagged through the calligraph and or module dependancy graph if it really is an unsafe module. (linking to unsafe crates would be blocked unless you deliberately asked for an unsafe build).
But ‘unsafe crates’ continue to exist of course, i.e. all the bindings to existing C/ C++ projects… they’re not going to re-write OpenGL, Vulkan, all the video codecs etc etc etc in Rust.
bear in mind this conversation is conflating 2 things, unsafety, and Rust other ‘oppressive choices’ (compulsory traits and no overloading). just loosening one of those would ease things a lot. the ‘unsafe’ case will remain; C++ wont go away, there’s massive sourcebases in regular use, and for most use-cases the solution is to layer an ‘application language’ ontop (most of my friends are busy using C# now and loving it)
I’ll check how the ‘intrinsics story’ is going in Rust BUT
the fact is machines change, ISA’s change… in the past it was console gamedev; in future it might be new chips for AI (what if they start making RISC-V with custom accelerator stuff, what about the movidius chip…) C++ with intrinsics gives you a blend of customisability and optimizability out of the box that is hard to match; not everyone has time to customise their compiler or study it’s internal API
I can tell you that the work i’ve done ‘in anger’ was all about ‘getting shit done’ on new platforms before the tools were ready, hence having a competitive advantage (being on a platform before rivals) That meant being able to drop down to ASM for custom instruction use, Microsoft took a step forward by actually enabling C-like intrinsics but originally those weren’t accessible if you wrapped types in ‘classes’, only a pure intrinsic typedef. They fixed it eventually but if you architected your code reliant on that… you missed the critical first/second wave window … your product releases along with a flood of competitors.
I’m not doing this right now, I am looking into ‘other languages’ for interest… but the point is if we are talking about the ambition of a C/C++ replacement - it must be able to handle the same use-cases.
If i just wanted to ‘ship apps’ like anyone else using existing libraries there’s swift/C# etc … and you get the use of optimised OS services (if you really want to defer all that to some one else).
I think it’s possible to improve on 2 of 3 axes - performance,productivity,safety, but maybe not all 3 simultaneously.