from Hacker News

Rust for Professionals

by keewee7 on 1/2/23, 8:59 PM with 100 comments

  • by wrs on 1/3/23, 12:23 AM

    An important “unblocker” for me when learning Rust after decades of other languages was internalizing that assignment is destructive move by default. Like many Rust intros, this sort of glides past that in the “ownership” section, but I felt like it should be a big red headline.

    If you’re coming from C++ especially, where the move/copy situation is ridiculously confusing (IMO), but also from a simpler “reference by default” language like Java, this has profound impact on what’s intuitive in the language.

    For the C++ comparison, this is a pretty good article: https://radekvit.medium.com/move-semantics-in-c-and-rust-the...

  • by attractivechaos on 1/2/23, 11:10 PM

    Nice blog post. Nonetheless, to a new learner like me, the hardest part of rust is not its syntax; it is the ownership management. Sometimes I easily know how to implement a task efficiently in other languages but I have to fight the compiler in rust. I either need to reorganize data structures, which takes effort, or to make a compromise by cloning objects, which affects performance. Note that I do agree with rust designers that it is better to make data dependencies explicit but learning to deal with them properly is nontrivial for me.
  • by xiphias2 on 1/3/23, 1:27 AM

    In my opinion this is the way _not_ to learn Rust. These syntaxes are not important at all, and doesn't introduce lifetimes (which is by far the most important part of the language for deciding whether to use it or not).

    Any blog about learning Rust for beginners should just contain information that helps the reader decide _whether_ she should put in the time required for learning it, then refer to the great Rust Programming Language book that's really hard to surpass.

    The reference is great as well, though personally I miss a part that formally defines the type system in its current form (there are some papers about lifetimes, but they are very hard to read).

  • by mlindner on 1/2/23, 10:12 PM

    It'd be nicer if there was some way of selection which language is shown on the left side. Expecting readers to understand both C++ and Kotlin and Java and Javascript will be a stretch for most.
  • by deepsun on 1/3/23, 1:26 AM

    > Inner functions. Rust also supports inner functions. ...

    > Closures (lambdas). Rust supports closures (also called Lambdas, arrow functions or anonymous functions in other languages).

    That's misguiding.

    Closures are not lambdas. Lambdas are just syntax, but the whole point about closures is that they capture the enclosing environment (have access to variables where it's defined). Rust's documentation states just that. Closures may or may not be lambdas.

    In above example of "Inner functions" (which is also a closure) that would be more clearly explained if the inner function used an outside variable. Not all languages can do that.

  • by joaquincabezas on 1/2/23, 10:12 PM

    I keep saving these Rust resources for a near future... Am i the only one??

    I really hope to start using Rust in 2023, probably for some kind of API gateway experimentation

  • by solomatov on 1/3/23, 2:15 AM

    This document only briefly mentions interior mutability, which IMO, is one of the most important things to become productive in Rust.
  • by ridiculous_fish on 1/3/23, 12:45 AM

    Curious why the author chose not to discuss macros? You encounter them immediately with a Hello World.
  • by ww520 on 1/3/23, 1:27 AM

    This is an excellent short tutorial. It helps to compare and contrast to other languages.
  • by jason2323 on 1/3/23, 12:58 AM

    As someone coming from a Java background, this seems useful! Thank you!
  • by skor on 1/2/23, 11:28 PM

    any constructive criticism on rust syntax?
  • by tomr75 on 1/3/23, 2:07 AM

    the hardest part and barrier are the concepts behind lifetimes/ownership/borrowing not the syntax