20 ms·
Rust for Professionals
- joaquincabezas 4y agoI 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
- tmtvl 4y agoI saved up Common Lisp resources for a few years and in 2022 I finally decided to sit down and learn it. It was entirely worth it, so I recommend you sit down to learn Rust one weekend. In fact, do it next weekend. Getting started on anything is always better done sooner than later.
- randmeerkat 4y ago> Getting started on anything is always better done sooner than later. So true. It’s never too late, you’re never too old, there’s never something else you need to learn first, just do it.
- kika 4y agojoaquincabezas, don't listen to this person. It's a trap. In February I found myself in AirBnB alone with nothing to do, because my wife had to stay back home for an extra week and I waited for her to join me. AirBnB had a decent work desk, decent(-ish) monitor and barely ok keyboard so I decided to learn Rust. Now it's January, I'm at 3000+ LoC of Rust and about 4000 in Dart/Flutter and trying to make the project to ShowHN. Weekend project, my ass. Rust is highly addictive, you've been warned. I tried to get sober, left this project for months on end, but always relapsed.
- joaquincabezas 4y agofn main() { println!("Too late I guess!"); }
- avaldez_ 4y agoNice. I'm doing exactly that with CL, one of my new year's resolutions. Would you mind to share your resources?
- tmtvl 4y agoBesides the obvious Big 4 (Gentle Intro, PAIP, On Lisp, and Cookbook) I am also quite fond of Lisp in Small Pieces. Aside from those I'd also recommend grabbing the GCL source and building the Info manual so you can browse it in Emacs, it contains a fairly complete copy of the HyperSpec (I know it's available online, but I don't like visiting websites that haven't updated to HTTPS yet). Also check out CLiki (the Common Lisp wiki, https://www.cliki.net/ https://www.cliki.net/), it's very helpful in finding useful libraries, like Alexandria, defstar, trivia, lparallel, and so on.
- avaldez_ 4y agoDidn't know half of those. Thank you!
- rr808 4y agoYeah I wish there was a strong jobs market for Rust developers then I'd feel like I wasn't wasting my time.
- Gigachad 4y agoThere aren't many full Rust jobs but there are a whole lot of companies with ever expanding bits of Rust in production. Probably the best way at this point is to push it internally and put together a convincing case for using Rust for new projects.
- alltheworlds 4y agoThis is our company. Frankly, I don't agree with this approach. We're a hedge fund that uses Java for low latency trading systems. Someone pushed for Rust to be used for a new project, because they wanted to use it, and now we have a split codebase. We have duplicate code (eg. connections to external APIs) written in Java and Rust, and now we have two sets of code to maintain whenever one of those APIs change. I always get annoyed when I hear about people suggesting to push for a language in a company because they feel it would be a good fit. Sure, maybe it would be, but now the company will always require experts not in one language but two, and developers are no longer as fungible between teams. Having said that, from a selfish perspective, I will use it to write some production Rust code in the future.
- bschwindHN 4y agoWhat kind of Rust job would you be looking for?
- pjmlp 4y agoI can only justify Rust for hobby coding, none of the stuff I do professionaly cares about what Rust offers, compiled managed languages are good enough and have decades of software maturity, and using Rust as translation layer between them and C++ libraries hinders more than it helps.
- mlindner 4y agoIt'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.
- clumsysmurf 4y agoI thought there would be an option to select just one, but seems they are indeed just random smatterings of rust vs { Typescript, Javascript, Kotlin, Java, C, and C++ }
- 86J8oyZv 4y agoThese features aren’t each supported by all those languages though. I also don’t think expecting a dev interested in Rust to understand several C-like languages is unreasonable, at least enough ti understand these straightforward example cases.
- nine_k 4y agoAFAICT, the expectation is that the reader knows at least one modern programming language from the list, and maybe is acquainted in passing with a couple of others. So at least some comparisons should click. (They seemingly don't use more apt comparisons with OCaml and Haskell, for instance, not expecting the reader to know them.)
- mlindner 4y agoJavascript I've seen a decent amount and tweaked/edited some of code in it but I wouldn't say I "know" it at all. Kotlin I've never even seen before and I know literally nothing about the language. Java I wrote a bit of in high school but haven't touched it in 15 years. So yeah there's quite a lot that people wouldn't know.
- nine_k 4y agoWell, Golang? Pascal? They have similar ways of declaring data types, for instance. This guide is not going to magically teach you Rust is there's nothing to compare it to; there are other guides to help those without a background. But it could somehow help people who already have similar concepts in their mind to link them to corresponding concepts in Rust.
- attractivechaos 4y agoNice 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.
- insanitybit 4y agoThe short answer is... yeah, just clone the objects. Whatever other languages are doing is going to have the same tradeoff - performance (or safety, if the other languages aren't memory safe). Iff it becomes a problem, come back later and remove the '.clone()'.
- zozbot234 4y agoYou can also use Cow<> to choose between cloning and and immutable borrowing at runtime.
- insanitybit 4y agoUnless you're using `'static` you will still run into lifetimes with Cow, which I suspect a lot of people will find difficult. I'd suggest just using clone, learning the broader language, and learning about lifetime stuff later. Lifetimes aren't hard or complicated, what's complicated is understand their interaction with other features (closures) when you don't even understand wtf closures in rust are, or traits, etc. I'd just focus on the other stuff for as long as you can.
- aussiesnack 4y ago> Lifetimes aren't hard or complicated, Untrue - read https://users.rust-lang.org/t/what-is-a-good-mental-model-of-borrow-checker/ https://users.rust-lang.org/t/what-is-a-good-mental-model-of.... Even Rust aficionados can't describe how they work without vast screeds. Or if you think the posters there are just wrong, try the RFC on which the current implementation is based: https://rust-lang.github.io/rfcs/2094-nll.html https://rust-lang.github.io/rfcs/2094-nll.html. You truly don't find that hard or complicated? It may be the case that people can use simplified subsets of the language to ease their way. But when a Rust advocate says that in effect to understand lifetimes you have to read the standard library source (as is written in the forum thread linked above), because no current documentation is comprehensive enough to cover it, then you know the whole thing itself is pretty complex.
- skor 4y agoany constructive criticism on rust syntax?
- tmtvl 4y agoUsing clearly defined bit sizes (i32, f64) rather than legacy naming conventions (int, double) is a good idea, the language could be really quite something if they switch to S-expressions.
- legerdemain 4y agoSyntax or semantics? Not a lot for syntax... maybe the "turbofish" syntax with generic types is a bit too much line noise: <Foo<_> as Bar<_>>::baz<_>()
- guilhas 4y agoDefinitely, rust looks clear for what is programmatically happening, making it noisier to overview the problem being solved
- ridiculous_fish 4y agoWith the caveat that syntax is the ultimate bikeshed topic, one (IMO) syntactic wart is the special pattern syntax: 1. "Operators" have different meanings. `1 | 2` and `1..=2` mean something different in patterns than in expressions. Here is a silly example: https://rust.godbolt.org/z/76Ynrs71G https://rust.godbolt.org/z/76Ynrs71G 2. Ambiguity around when bindings are introduced. Notice how changing a `const` to a `let` breaks the function: https://rust.godbolt.org/z/aKchMjTYW https://rust.godbolt.org/z/aKchMjTYW 3. Can't use constant expressions, only literals. Here's an example of something I expect should work, but does not: https://rust.godbolt.org/z/7GKE73djP https://rust.godbolt.org/z/7GKE73djP I wish the pattern syntax did not overlap with expression syntax.
- scotty79 4y ago> 2. This actually bit me in the a__ when I misspelled my enum variant and instead match created a variable named like that, that captured everything and I got only a warning and very wrong code. I think there should be `let`s inside match block if matching creates some variables.
- wrs 4y agoAn 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-case-for-destructive-moves-d816891c354b https://radekvit.medium.com/move-semantics-in-c-and-rust-the...
- coderenegade 4y agoI found the copy/move situation in Rust to be far less intuitive than in C++. In C++, move semantics are obvious because they rely on std::move and the && operator, whereas in Rust, similar behavior seemed to depend on the object type. Even more confusingly, Rust has its own move operator as well, despite destructive move being the default behavior for assignment. I found it frustrating enough that I put the language down and just went back to using C++.
- scotty79 4y ago> In C++, move semantics are obvious because ... In Rust it's also obvious because every = is a move. Confusion comes from tutorials pretending for too long that it's not. > whereas in Rust, similar behavior seemed to depend on the object type. It's best to think of that as an exception to the rule created specifically for numbers and other similar small, cheaply copied things. If you need to move `a` but `a` has a trait Copy then you copy instead. > Rust has its own move operator as well, despite destructive move being the default behavior for assignment. I don't think that's true? Rust has a `move` keyword but it's a part of closure definition that makes it take all the variables from its environment by move, even if it doesn't need it. Unless you are talking about something else...
- legerdemain 4y ago
- ridiculous_fish 4y agoCurious why the author chose not to discuss macros? You encounter them immediately with a Hello World.
- John23832 4y agoDeclarative macros would be too confusing to get into in any way other than "the ! in println! denotes a macro".
- jason2323 4y agoAs someone coming from a Java background, this seems useful! Thank you!
- deepsun 4y ago> 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.
- xiphias2 4y agoIn 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).
- jackmott 4y ago[dead]
- ww520 4y agoThis is an excellent short tutorial. It helps to compare and contrast to other languages.
- tomr75 4y agothe hardest part and barrier are the concepts behind lifetimes/ownership/borrowing not the syntax
- scotty79 4y agoI think the hard part is understanding how limited is basic feature set of just Rust. That you can write very few interesting programs without venturing into the heap with Box, Rc and such and into internal mutability with Cell and RefCell. Then it quickly raises to the power of other languages and surpasses them with "pay for only what you use" mentality.
- solomatov 4y agoThis document only briefly mentions interior mutability, which IMO, is one of the most important things to become productive in Rust.