Hacker News new | past | comments | ask | show | jobs | submit login

  > I'm a weekend wannabe systems programmer
  > and was attracted to Rust from Ruby because C scares me
I myself was attracted from Javascript for the same reason, you're among friends. :)

  > this is where Go users laugh that Rust attracted a 
  > Rubyist instead of a C++ user
I don't think anyone's laughing at anybody. Different languages will appeal to different people, we don't need to begrudge anyone for that!

  > I'll have to research C++ lambdas some more but given 
  > the safety, usability and performance gains
Performance of Rust closures should be the exact same as C++ lambdas. Safety-wise, you get all the usual guarantees of Rust. Usability-wise, the main nicety of Rust closures over C++ lambdas is that Rust doesn't force you to specify a capture clause, and instead infers how to capture all of the closed-over variables based on context. I think that Rust may actually be strictly less powerful than C++ here (as C++ allows you to explicitly specify the capture mode for each and every upvar if you like), but we believe that you'll have all the power you need in practice. Whether or not this turns out to be true will have to be determined by experience.



While it's less important in a language with immutability as default, closures, especially in dynamic longhops, can be a good way of shooting yourself in the foot (eg, capture inside a loop a variable defined outside of it but which is modified at each iteration and wonder why you always get the value set at the last iteration). Capture lists are not always evil.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: