
A Gentle Introduction to Rust - blacksmythe
https://stevedonovan.github.io/rust-gentle-intro/readme.html#a-gentle-introduction-to-rust
======
skywhopper
Speaking 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.

~~~
some_account
I 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
> 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
At 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_

~~~
Retra
Arguably, school curricula are driven by the industry's needs. People keep
asking for Java and Javascript developers, so that's what they have students
learn.

~~~
LandR
I guess my response to that would be, if you just go straight into Java then
OK, you've made some Java developers... I think they will be poor developers
who happen to know Java.

But if you teach them fundamentals of structuring software, compiler theory,
how it all works at a lower level etc. _Then_ teach them Java, you will have
good developers, who also happen to know Java.

------
thsowers
Really 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

------
allengeorge
Parsing with `nom` seems like a pretty aggressive introduction to Rust :)

~~~
stevedonovan
I 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'.

------
tempodox
What 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
That 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
> 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.

------
Animats
4th post with this title from this author.

~~~
shrewduser
I would assume they really care about getting new Rust devs.

------
komuW
As 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

------
quickben
Why 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
> 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.

?

~~~
sidlls
> Because it was built to be a C/C++ replacement.

That doesn't mean discussions including it have to bash C or C++. In fact,
there is supposedly a very high standard in the official Rust community
against bashing other languages.

Plenty of languages have completely replaced or circumvented C and C++ (i.e.,
out-competed them) in their respective niches without it being a heated two-
minutes hate every time discussions come up.

~~~
stevedonovan
I approve whole-heartedly of the "no zealotry" rule. (I seriously doubt that
the Jehovah's Witnesses have achieved conversion rates commensurate with the
effort expended.) That being said, C has problems, particularly the assumption
of the "sufficiently smart programmer". Because I'm not smart enough, I
appreciate the nagging of the Rust borrow checker, although to be honest it is
a complete pain at first.

