11 ms·
I started learning Rust over the weekends and I think the second edition "The Rust Programming Language" is among the best introductory books on a programming l
by smoe 9y ago
I started learning Rust over the weekends and I think the second edition "The Rust Programming Language" is among the best introductory books on a programming language I have read (well half way so far).
As someone not only new to Rust but also systems programming in general I especially appreciate that the chapters include actual reasoning about why things are how they are in Rust and that they seem pretty open about drawbacks of the choices. As well as the use of precise language instead of trying to be too cute and overly beginner friendly.
An example for this is the lengthy page on Strings:
https://doc.rust-lang.org/book/second-edition/ch08-02-strings.html https://doc.rust-lang.org/book/second-edition/ch08-02-string...
It really makes me feel you want me to understand what I'm doing from the start instead of getting a generic app out of the door as quick as possible and then tediously figure out the next basic steps from screencasts, scattered blog posts etc.
Also big plus for having the book and api doc available offline by default!
I'm going to try to come by #rustdoc and see if there something I could contribute.
- sharpercoder 9y ago> [...] include actual reasoning about why things are how they are in Rust and that they seem pretty open about drawbacks of the choices. This trait of documentation (the "why" & openly discussing pros and cons) seems to be a property of great systems being well-documented.
- derefr 9y agoI'm not sure—I think it's more, in this case, that Rust assumes the developers learning about it have specific goals: namely, to evaluate Rust vs. C/C++. So every resource that teaches Rust couches the discussion in terms of justifying why the particular design being presented is better (from the Rust maintainers' perspective) when compared to designs in existing languages, even if it makes other sacrifices to be such. I would contrast this to e.g. the Erlang documentation. Erlang/OTP is a great system, and it's well-documented... but the documentation doesn't actually go into the "why" of various choices (e.g. why the BEAM has a module table with exactly two slots per key; why binaries are shared at ≥64 bytes; why clusters are fully connected; etc.) But I think this makes sense, given the differing approach: unlike Rust, the Erlang/OTP platform is trying to facilitate an abstraction where you just write high-level declarative-ish code, and then improvements to the platform will make that code perform better over time. Rust documents its decisions because it expects you to be someone who wants to know those things in order to make precisely those decisions (except you're choosing a systems language, rather than designing one.) Erlang leaves most of its internal implementation as a black box, because it expects you to treat it as a black box and derive advantages (in e.g. maintainability) from doing so.
- steveklabnik 9y ago> Rust assumes the developers learning about it have specific goals: namely, to evaluate Rust vs. C/C++. We don't assume that. From https://doc.rust-lang.org/book/second-edition/ https://doc.rust-lang.org/book/second-edition/ > This book is written for a reader who already knows how to program in at least one programming language. After reading this book, you should be comfortable writing Rust programs. We’ll be learning Rust through small, focused examples that build on each other to demonstrate how to use various features of Rust as well as how they work behind the scenes. That is, we assume programming knowledge, but not specific programming knowledge. Many people come to Rust not knowing C or C++.
- Agathos 9y agoI think derefr was inferring (or imagining?) a subconscious need to defend certain decisions, even if C and C++ are not prerequisites. As a post-structuralist, I generally approve of reading the author's stated intentions and responding, "Yes, well, that's one interpretation." :P
- binarycrusader 9y agoFor what it's worth, rust's often introspective approach to documentation and community is one of its defining virtues in my opinion. Growing up, I was constantly taught new things, without often being taught why. They "why" of things is just as important to me as the "how". So thanks for all you've done and continue to do!
- steveklabnik 9y ago<3
- derefr 9y agoSorry if I wasn't clear; I didn't mean to imply that the Rust maintainers assume any prerequisite knowledge of C/C++. I rather meant that the goal of someone learning Rust "in anger" is for that person to quickly decide if Rust is the best language to use to solve the problem they have. And, if Rust is even a candidate in their solution-space, then usually C and C++ (and sometimes also Go or D or C#) are the other candidates the learner is considering learning. They're Rust's "neighbours" in its solution-space. And so, Rust's documentation is well-written, but it's well-written specifically for this type of person learning Rust "in anger", with the goal of evaluating the language against its neighbours at the same time they're learning it. Such a person wants to see Rust's design-decision guts spilled out on the floor before them, so they can move on if those decisions are not to their liking. This doesn't mean the documentation isn't approachable to people who don't have any such points of comparison! But just like a movie can be enjoyable for both kids and adults on different levels, Rust's documentation has both a "teaching you Rust" level and another "justifying Rust's departures from the Average Low-Level Language" level.
- steveklabnik 9y agoThank you so much! Any improvement from the first to the second edition is thanks to Carol :)
- smoe 9y agoI haven't looked at the first edition, just wanted to be clear which version I'm referring to. Kudos to everyone involved and Carol for the improvements to the second edition:)
- parthdesai 9y agoThat book indeed is really really good. Though i have one feedback, they should have solutions to "Extra problems" they have at the end of chapter (maybe separately). Have been stuck at closures for couple of days now, where you are supposed to implement your own cacher with hashmap.
- steveklabnik 9y agoI’ll put it on the list!
- debaserab2 9y agoI also just started learning rust over the past few weeks. While I'm still grasping with some of the core concepts of the language (like ownership), I do feel like there's adequate documentation and resources out there that I'll get there. What I really like is how helpful the compiler is. It's fast and the errors feel well explained and relevant to the problem in my code. It almost feels like I'm developing on a REPL. Rust seems to have a very ruby-like approach in trading ceremony for conciseness, and while I feel I will eventually learn to appreciate that more, it does present a challenge while learning. It seems like there are a lot more symbols that have significant meaning in rust - where an average language might only have a few dozen or so "core" symbols that I must learn to use the language, rust has quite a lot more, and many of them follow idioms that I don't recognize from any other language (most of my experience is a pretty typical web dev background). It definitely makes learning by example hard (from actual userland code, not the excellent beginner focused hosted tutorial). Although maybe it just feels this way because I'm on the start of a long journey of understanding and perhaps things look a little bigger than they are.
- zenhack 9y agoThere's definitely a lot of syntax that makes the language look bigger than it is. When I realized Rust's oo-style dot notation/self/Self was just sugar for plain old function calls, suddenly a big chunk of the language I thought I hadn't learned yet turned out not to just not exist.
- jhoechtl 9y ago> An example for this is the lengthy page on Strings: https://doc.rust-lang.org/book/second-edition/ch08-02-string.. https://doc.rust-lang.org/book/second-edition/ch08-02-string.... I don't know how the 2nd edition of the book deviates from the first one, but as you mention the strings section: I had installed rust with rustup, configured my editor environment, bookmarked and read tutorials and was serious about learning rust, dabbling with code snippets. It was the exact chapter you mentioned, strings, which drew me away from rust in disgust. Four string types ... for the beginner? Seriously?
- baq 9y agoRust in general isn't really a beginner's language. You have to understand computers at a very low level to appreciate the design choices. Given some dedication, it'll help you at that but it's not easy, especially if you already know some higher level languages. It's probably easier to teach it as a first language than a second after Python or Java.
- squiggleblaz 9y agoCan you clarify your meaning? I'm a little confused. It sounds like you say "Rust isn't really a beginner's language... it's probably easier to teach [Rust] as a first language than a second after Python or Java". At first it sounds like a contradiction but when I inspect closer I realise there's alternative interpretations. Do you mean "learning a system's programming language is not helped and may even be hindered by experience with general purpose languages"? Are there any good beginners' systems languages, which help Rust?
- steveklabnik 9y agoI think your parent is saying "Rust isn't a great language to learn programming with", that is, if you've never programmed, Rust is not a great choice. I agree, but I don't think it's inherent; I think it's a lack of resources targeted at this demographic.
- 9y ago
- cpach 9y agolet hello = String::from("السلام عليكم"); let hello = String::from("Dobrý den"); let hello = String::from("Hello"); let hello = String::from("שָׁלוֹם"); let hello = String::from("नमस्ते"); let hello = String::from("こんにちは"); let hello = String::from("안녕하세요"); let hello = String::from("你好"); let hello = String::from("Olá"); let hello = String::from("Здравствуйте"); let hello = String::from("Hola"); This is such a beautiful sight for anyone who remembers the bad old days of Extended ASCII.
- golergka 9y ago> let hello = String::from("שָׁלוֹם"); This brings back PTSD for anyone who implemented ad-hoc RTL and UTF-16 surrogate pairs support in an environment that lacked them. Thank g-d I insisted that we at least omit diacritics as nobody uses them and they're a huge pain to implement and QA properly. Also, can we please, please, please keep source code files as pure ascii? Asking as a non-native english speaker. There're a lot of tools that we developers need to use on those, and their encoding issues tend to follow the Murphy's law and appear at the most inconvenient moment. Edit regarding localization: all projects that I've worked on had localization in separate json or XML files, with automatic import/export from spreadsheets that would be filled by third party localization company. This is the line of code I find my cursor on literally the moment I switch to HN: questIcon.Text.text = ("Quest:" + World.current[index].template.trueId + "_title").T(); Where T() is the extension method from localization system. Why on earth would you include user-facing strings in the code itself?
- Dylan16807 9y agoWhat tools care whether a file is ASCII or UTF-8?
- wodenokoto 9y ago> Also, can we please, please, please keep source code files as pure ascii How do you propose that we write programs that interact with non-ASCII compatible language users? All string literals are to be saved in external, somehow non-source code files? How would you go about writing a Chinese "Hello World"? In Python 3, I would write print("你好,世界!") I have no idea how you propose this should be done in pure ascii.
- logicallee 9y ago>I started learning Rust over the weekends and I think the second edition "The Rust Programming Language" is among the best introductory books on a programming language I have read (well half way so far). I'm genuinely curious (this is a straightforward question): have you personally gotten applications you've written to compile yet, or are you still learning theoretically? (I haven't used rust, but have read a few comments about a high learning curve.)
- smoe 9y agoDepends what you mean by application. So far I only worked on simple exercises and translated some algorithms I have previously written in Python. Compiling them is fairly easy since the compiler output is very helpful and IDE integration is quite good for still being new. Main painpoint is, that I haven't managed to get the debugger work yet. Rust does have a high learning curve but to me it seems justified by its goals, the domains it targets and using some concepts that are unique or not the most common. Still I'm fairly confident I would get a simple CRUD web app out in a day if that's what I wanted. Learning curve is not crazy high, just higher than the usual high level languages. My background is mostly in Python/js web development, but I'm currently learning dsp for audio processing and synthesis. And since language doesn't really matter at my current level I alternately implement things in Python, puredata, C++ and Rust. So I won't be implementing full fledged applications for quite a while :)
- logicallee 9y agoThanks for the straightforward answer, and the clarifications too. Starting at the end, a DSP is definitely what I mean by "application" (the reason I used the word 'application' is to exclude a straightforward 'hello world' copied from the exercise book.) For example, have you gotten any audio processing application to work ta you've written, or anything like that? I'm surprised you mention CRUD web apps, as I didn't think Rust was used in that domain much. (i.e. on the server side like php or even Go might be.)
- smoe 9y ago
- wscott 9y agoMy sister ordered me a copy of that book on Amazon for my birthday in mid-2016. Then she was surprised that it was a pre-order and I wouldn't get it until October. It still isn't done. Like a good wine I guess.
- kowdermeister 9y agoLong for sure, but I really miss practical use cases, for example: > Asked how long the string is, you might say 12. However, Rust’s answer is 24: I get that, `.len()` is tricky, but why not include an easy, common way to determine character length of a string in the documentation?
- steveklabnik 9y agoThere are different concepts of length depending on what you need. And not all of them are in the standard library, and hence, the book. “Character length” is not a Unicode concept, for example.
- kowdermeister 9y agoObviously, but it's a page about strings and a hint about how to get exact character length would be nice to have. But sure, the answer is just a googling away.
- steveklabnik 9y agoIt is true that we could point people to the ecosystem more. Historically, we've been worried about playing favorites. However, this can come into conflict with our principles of having a small stdlib. It's tough.