8 ms·
A Gentle Introduction to Rust
- allengeorge 9y agoParsing with `nom` seems like a pretty aggressive introduction to Rust :)
- stevedonovan 9y agoI got carried away with a personal enthusiasm. It happens :) `nom` is marvelous, but the hard bit with combinatorial parsers is getting them to spew out good error messages. By default they are like Prolog - the answer is 'no'.
- skywhopper 9y agoSpeaking as someone who's poked around at the edges of Rust and always come away frustrated, the Rust world does need a "gentle introduction". But while this document seems to understand that need, it gets messy pretty fast. First of all, the introduction is all over the place, and poorly structured. There first section asks "Why Learn a new Programming Language?" but never answers that question (beyond "it's good mental exercise"), and follows it up with a section labelled "Where Rust Shines" that instead vaguely compares its memory management approach to C, calls C a "cowboy language", lists some of Rust's design components (not really even principles, just aspects of the language), and then starts giving advice for how to learn a programming language in general? What? Next is Hello World, and immediately "Rust is a curly-braces language with semicolons, C++-style comments and a main function - so far, so familiar." Well, to C++/Java/Javascript programmers, maybe it is familiar. That may well be a huge part of your intended audience, but this gloss of the basics is a big red flag about what assumptions might be made further on. "The exclamation mark indicates that this is a macro call. For C++ programmers, this can be a turn-off, since they are used to seriously stupid C macros" Whoa, there, cowboy! This is Hello World! Mentioning macros at all should probably be reserved for a little later, much less vaguely referencing the C preprocessor's bad repuation. Then the tangent about "OMG, you mean I have to type an exclamation point!?" is telling, though. At this point in a gentle introduction, you probably shouldn't be already alluding to the trash talking about the language. We aren't even past the first example. Further down the page, there's some big talk about how Rust favors explicitness, immediately followed by a discussion of how all the types are implicit and how confusing that can be. No mention of how you would remember that `f64` is the default floating point type... This is a worthy attempt and probably a good first draft. It's definitely a document that needs to exist, but in its current state, it's an gentle intro that only a disaffected C++ programmer could love. But please keep working on it--I need something like this.
- conradev 9y ago> No mention of how you would remember that `f64` is the default floating point type While the default is `f64`, it's only used if the type can't be inferred otherwise. If the author had changed the `f64` in the code sample to `f32`, type inference would have made the float literal to be an `f32` to match. That is a little complicated to explain, but the UX is such that literals generally "just work".
- some_account 9y agoI think you are a little unfair, expecting the guide to be towards complete beginners who would get confused by the language having curly braces or not... Rust is not a first language, it's a systems programming language. For previous programmers, the guide looks pretty good to me.
- cies 9y ago> Rust is not a first language, it's a systems programming language. Since when are sys prog langs not introductory languages anymore? I understand that using an dyn typed, interpreted, GCed lang is easier to get started with; but a whole (2) generation(s) of programmers has started with systems programming as their first experience, and I must say they seem well equipped for they jobs (maybe better so than those only exposed to Python/JS/Java/C# that leave higher educations nowadays). I see it as two different educational strategies: easy first vs hard first. And even when easy first was not an option back in the days, it does not mean that hard first is a bad option nowadays. A ref to this letter by Dijkstra may be on point (where he "discusses" the move from Scheme/Haskell to Python/Java in a university curriculum). https://chrisdone.com/posts/dijkstra-haskell-java https://chrisdone.com/posts/dijkstra-haskell-java
- LandR 9y agoAt my university course, we did C in the first year for all programming courses. THen onto C++ in year 2 onwards, but all the fundamentals were in C. Now that same course goes straight to Java as the introductory language, alongside html / css and javascript. Now any sort of low(er) level language is avoid until year 2 when they do a course on C / C++ Which seems ass backwards to me. I also see some developers come into the industry now who have never done anything lower level than Java or javascript at all
- thsowers 9y agoReally enjoyed the section on error handling. I had read similar sections in the rust book, but something about this explanation really made things click for me! As much as I love Rust, I personally found it a little difficult to get used to the error handling coming from an language like JS which cares little about appropriate handling
- Animats 9y ago4th post with this title from this author.
- shrewduser 9y agoI would assume they really care about getting new Rust devs.
- quickben 9y agoWhy does every single rust promoting article have to bash on c++? They built a GC, good job. But, surely there is something else more worthy of typing about when hyping the language?
- rapsey 9y ago> Why does every single rust promoting article have to bash on c++? Because it was built to be a C/C++ replacement. > They built a GC, good job. ?
- banachtarski 9y agoTo me, it feels like Rust really only has value to people who aren't already using C++14/17. The incremental benefit in certain areas is small, and it steps backwards in other areas.
- MrBuddyCasino 9y agoMaybe I'm living in a special kind of bubble, but I have yet to meet a C++ programmer IRL who doesn't hate it.
- pjmlp 9y agoHello, now you know me. I leave that special spot for C.
- Ygg2 9y agoSay what you want about C, but at least it doesn't require reading several LotR length books, to be up to date with all the stuff. Sadly, Rust, seems to be getting a few tomes of its own as well :P
- pjmlp 9y agoActually it does, for anyone that cares about how to write portable and safe code in C. There is this myth that C is a simple language, when devs stick to a single OS/compiler combo.
- tempodox 9y agoWhat makes Rust still rather inaccessible for me is the difficulty in finding «functions I can apply to an argument of type X» and «functions that return a value of type Y» other than, “read every last bit of API doc about everything and memorize it”.
- tuukkah 9y agoThat would be what Hoogle is for Haskell: https://www.haskell.org/hoogle/ https://www.haskell.org/hoogle/ Could you start by grepping API docs?
- tempodox 9y ago> grepping API docs Of course, but that's still painfully slow and awkward. It's exactly the kind of repetitive crap we programmers are born to automate.
- fredmorcos 9y agoWhen you search in the API documentation, you will find 3 tabs at the top: "In Names", "In Parameters" and "In Return Types". Example: https://doc.rust-lang.org/std/?search=option https://doc.rust-lang.org/std/?search=option
- masklinn 9y agoThe official docs have limited support for it, if you search for i32[0] the default facet is "in names" but you can use the "in parameters" and "in return types" tabs for these. I don't know how well these handle abstract types and it's nowhere near hoogle convenience, but there you are (there were efforts to port/replicate hoogle a few years back but the few I remember seem to have been abandoned, specifying a search syntax is probably non-trivial as well given Rust's signatures are not as convenient as Haskell's there)/ [0] https://doc.rust-lang.org/std/?search=i32 https://doc.rust-lang.org/std/?search=i32
- komuW 9y agoAs a Go dev that learned programming via Zed Shaw's learn python the hard way, I have to say this tutorial made me want to learn rust. I've bookmarked for later, once I'm done learning dart/flutter. Thanks Donovan
- deleted 9y ago[deleted]
- pohoza 9y agoThe tutorial is also avaliable at slash tutorial https://slashtutorial.com/rust/ https://slashtutorial.com/rust/