Earlier quoted context omitted.
Yes, to do anything interesting, you need to implement the Drop trait, which causes interesting behavior to happen here.
An example of the implementation is all that's missing from the blog post.
My favorite Rust function
91–100 of 197 posts
Re: My favorite Rust function
#92Gotta admit, that really is a cute example. However, I was a bit surprised when the author described Go as "unacceptably crippled." What is he referring to?
Re: My favorite Rust function
#93Earlier quoted context omitted.
Interesting how developer views can differ. Someone describes Go as "unacceptably crippled" while Uber engineering has 1500 microservices written in Go, making it their primary language. https://news.ycombinator.com/item?id=21226347
These are orthogonal points. Linux Kernel is all in C and possibly drives the world. Doesn't mean it's safe and amazing.
Uber on the other hand has many languages available yet picked Go. So they certainly don't think it is "unacceptably crippled".
Re: My favorite Rust function
#94Earlier quoted context omitted.
Sure, and my opinion is that this is a very shallow takeaway. My whole comment is just my opinion.
It is crippled admittedly by the authors themselves. The error checking pattern, no generics etc. are all to keep it "simple" yet are things most other programming languages have. Have you used Rust ? The borrow checker makes a lot of sense.
But of course, Rust is not flawless. In fact up until recently it was kind of annoying, before non-lexical lifetimes became a part of the language. It’s also a very large and complex language compared to Go. This is not unilaterally a bad thing, but just as every line of code comes at a cost, so to does every language feature, and if enough language features fail to pay the rent your programming language will end up feeling bloated.
What Go lacks is exactly its strengths. If you criticize C for not having Java-style exceptions, people will look at you funny. There is some divide in the community over error handling but I defend that Go’s verbose and stupid error handling pattern is my favorite part of the language, and changed how I code inside and outside of Go. I also appreciate Go’s simple but effective patterns for composition-based object oriented programming, and for having a decent concurrency model (not that it is without flaws: the limitation of Go’s memory safety is definitely an issue here.)
Everything comes at a cost. The borrow checker brings immense promise for security, but that does not mean other approaches to memory safety or language design are suddenly obsolete. It’s more complicated than that, and I consider failure to understand this to be a sign that someone is not keeping an open mind.
Re: My favorite Rust function
#95let x = String::from("abc"); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x);
Re: My favorite Rust function
#96Earlier quoted context omitted.
Interesting how developer views can differ. Someone describes Go as "unacceptably crippled" while Uber engineering has 1500 microservices written in Go, making it their primary language. https://news.ycombinator.com/item?id=21226347
These are orthogonal points. Linux Kernel is all in C and possibly drives the world. Doesn't mean it's safe and amazing.
Re: My favorite Rust function
#97> or making the language unacceptably crippled like Go Gotta say, I lost a lot of respect for the author at this point. It’s not like I don’t love Rust - quite the contrary - but if the only takeaway from Go for you is that it is “unacceptably crippled” then I feel you have missed a lot of insight. Go has been one of my languages of choice for over half a decade now, and for good reason.
Re: My favorite Rust function
#98let x = String::from("abc"); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x);
FWIW, that won't compile because std::mem::drop requires ownership of the object being passed; your code is trying to pass a reference instead.
https://play.rust-lang.org/?version=stable&mode=debug&editio...
Re: My favorite Rust function
#99let x = String::from("abc"); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x); std::mem::drop(&x);
FWIW, that won't compile because std::mem::drop requires ownership of the object being passed; your code is trying to pass a reference instead.
On my phone so I can’t triple check, but there’s no bound on T, you can pass in any type.
Re: My favorite Rust function
#100 |_| ()
[1] https://twitter.com/myrrlyn/status/1156577337204465664