Rust Sucks If I Fail to Write X
llogiq.github.io
Rust Sucks If I Fail to Write X
1–10 of 89 posts
Re: Rust Sucks If I Fail to Write X
#2Yes! This is a point that I try to hammer home that's missed by many people who write C/C++ on a daily basis. Everyone wants to use the fanciest data structures when most of the times arrays will be faster and simpler to use.
Re: Rust Sucks If I Fail to Write X
#3> While you can hack together a “list” that will be backed by a Vec of nodes with indices to the next / previous item, this approach is quite wasteful – and gains little compared to using the Vec directly.
How is this wasteful or hacky?? This is THE proper way of writing data structures that are not strict trees. Sure, this isn't the correct way to write a list data structure, but there's almost no reason to use a linked list in general.
Re: Rust Sucks If I Fail to Write X
#4> Rustaceans usually opt for continuous data layout (known in C/C++ lingua as array-of-struct or struct-of-array depending on priorities), which is more cache-friendly than reference-heavy data structures anyway. Yes! This is a point that I try to hammer home that's missed by many people who write C/C++ on a daily basis. Everyone wants to use the fanciest data structures when most of the times arrays will be faster a…
Re: Rust Sucks If I Fail to Write X
#5It's easy if you try
No dangling pointers below us
Above us, only sky
Imagine all the programmers writing memory-safe~
Imagine there's no memory
It isn't hard to do
Abstracted away all the pointers
A memory-safe CPU
Imagine all the programmers using their GCs~
You may say I'm a dreamer
But I'm not the only one
I hope someday you'll put down your C
And our buffers won't overrun~
Imagine only capabilities
I wonder if you can
Only objects referencing each other
And remote calls using Capn
Imagine all the programmers sharing across the world~
Re: Rust Sucks If I Fail to Write X
#6I stopped reading here.
Re: Rust Sucks If I Fail to Write X
#71. Code where my objects form a tree. Rust's ownership model is great for this. 95% of my code looks this way naturally, and maybe another 3% can be rewritten to look like this.
2. Code where my objects form a complex graph. At this point, I need to make a choice between manual pointer management (C++, unsafe Rust) and a garbage collector (lots of languages). Happily, Rust does have regular pointers and 'unsafe'.
If most your code looks like (1), and only a small amount looks like (2), then Rust can be a big win. Personally. I really like the combination of low-level control, performance and safety.
But if I encounter a problem with a lot of (2), my first instinct is to reach for crates.io and look up an appropriate library. I do know how to use pointers in Rust and work with 'unsafe', but it's easier to let somebody else do it for me.
If you're really curious, then "Learning Rust with too many lists" (http://cglab.ca/~abeinges/blah/too-many-lists/book/) is a great introduction to more advanced techniques.
Re: Rust Sucks If I Fail to Write X
#8Imagine there's no unsafe blocks It's easy if you try No dangling pointers below us Above us, only sky Imagine all the programmers writing memory-safe~ Imagine there's no memory It isn't hard to do Abstracted away all the pointers A memory-safe CPU Imagine all the programmers using their GCs~ You may say I'm a dreamer But I'm not the only one I hope someday you'll put down your C And our buffers won't overrun~ Imagin…
Re: Rust Sucks If I Fail to Write X
#9> Rustaceans usually opt for continuous data layout (known in C/C++ lingua as array-of-struct or struct-of-array depending on priorities), which is more cache-friendly than reference-heavy data structures anyway. Yes! This is a point that I try to hammer home that's missed by many people who write C/C++ on a daily basis. Everyone wants to use the fanciest data structures when most of the times arrays will be faster a…
Re: Rust Sucks If I Fail to Write X
#10> As an aside, remember that the only difference to C/c++ is that if you write a “basic linked list” in them, all of your code will be unsafe. I stopped reading here.