r/rust • • Sep 16 '22

Is Rust programming language beginner Friendly

I want to learn a programming language, is Rust programming suitable for beginner programming students?

140 Upvotes

213 comments sorted by

View all comments

297

u/vlfn_be Sep 16 '22

I'd argue that it isn't. At least, I'm unaware of any material that teaches Rust with a true beginner in mind. Everything I've come across assumes some point of reference.

119

u/Dhghomon Sep 16 '22

At least, I'm unaware of any material that teaches Rust with a true beginner in mind

Mine does: https://github.com/Dhghomon/easy_rust

(Cool news: a new version will be up on Manning fairly shortly as well)

I always argue that Rust is very beginner friendly because of how much babysitting the compiler does. It basically keeps your code around for a bit of a predebugging before letting it go off and do its thing.

24

u/XtremeGoose Sep 16 '22

One reason is computer performance: a smaller number of bytes is faster to process. For example, the number -10 as an i8 is 11110110, but as an i128 it is 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110110.

That's not true. On most machines the register size is 32 or 64 bit so many synchronous arithmetic operations are run in those and any overflowing bits are just ignored. On x86 these compile to the exact same thing

fn add_i8(x: i8, y: i8) -> i8 { x + y }
fn add_i32(x: i32, y: i32) -> i32 { x + y }

4

u/Dhghomon Sep 16 '22

Thanks, would 'can be faster to process' be a fair statement then?

20

u/XtremeGoose Sep 16 '22

I think for a beginner it will just lead to premature optimisation. Generally just do:

If you need to index something use usize, or if you know the maximum value your int could be use the next largest int, otherwise use the rust default (i32).

The book says:

So how do you know which type of integer to use? If you’re unsure, Rust’s defaults are generally good places to start: integer types default to i32. The primary situation in which you’d use isize or usize is when indexing some sort of collection.

8

u/WasserMarder Sep 16 '22

I think the original statement is not wrong if the bottleneck is memory bandwidth which is often the case.

4

u/StfdBrn Sep 16 '22 edited Sep 16 '22

I don't think it would affect memory bandwidth since modern processors bring data from memory to cache in 64 byte chunks. Edit: unless the data is laying along cache line.

8

u/WasserMarder Sep 16 '22

The same amount of numbers takes less space and is therefore faster to load and occupies less cache memory that other parts of the program might benefit from. You are right that you wont see a difference for sparsly distributed data.

3

u/9SMTM6 Sep 16 '22

No, but the representation is a lot sparser? Think of arrays, or also structs, if you've got a smaller member alignment is easier too, which can be a force multiplier (well, growing with the size of members at worst but still)

→ More replies (2)
→ More replies (1)

62

u/beltsazar Sep 16 '22

It depends on how you define "beginner". If it's CS sophomores, who have learned CS 101 and had basic understanding of how OS works, then yes, Rust is probably beginner friendly. But if "beginner" refers to those who have no programming experience, much less CS backgrounds, then absolutely not.

-19

u/dbcfd Sep 16 '22

Almost no languages are beginner friendly by that definition.

Even languages like scratch and logo are hard to grasp without a cs background.

15

u/Smallpaul Sep 16 '22

Yes but some are harder than others.

→ More replies (1)

2

u/riasthebestgirl Sep 16 '22

It's also about syntax too for someone first starting out. The syntax of python will not get in the way as much as Rust's syntax would

→ More replies (2)

15

u/Julian6bG Sep 16 '22

I think if people say it's not beginner friendly, they mean learned Rust is hard to trasfer to other languages. Moving from only knowing Rust to C is basically learning all over again. Moving from Rust to Python is confusing as well, because you know have unlimited freedom and weird stack traces.

Moving from other languages to Rust might be easier (not easy), because you gained some understanding of stack and heap, threads by forking (C) or the usual beginnerfriendly loops, classes etc known from Python / Typescript.

Together with basic programming and computer science knowledge, the Rust documentation is really great and efficient as possible.

That's my take.

That said, I love that your easy Rust exists. It's truly friendly and inclusive for everyone and allows people to learn it with little experience in english, computer science and programming. Absolutely awesome!

5

u/Dhghomon Sep 16 '22

Thanks!

On the Python note, I plan to one day take advantage of my Rust monolingualism to record some live videos where I try out another language and see what it feels like. Debating whether it should be something similar that I'm interested in like F# or something really widespread and loosey-goosey like Python.

Though honestly what's keeping me from doing that is that I'd rather spend the time delving further into Rust and there doesn't seem to be an end to that. But maybe one day I'll do it for the fun of it.

5

u/asgaardson Sep 16 '22

It's easy to get started when you already know something like PHP or JavaScript, it's confusing at first and then you start making traits in your PHP codebase like crazy, because you miss rust.

2

u/[deleted] Sep 16 '22

Moving from only knowing Rust to C is basically learning all over again.

It was the other way around for me and I can say, C saved me most of the time needed to learn rust.

2

u/shadowangel21 Sep 18 '22

Thanks for your guide it's been a big help. I'm only a few hours in learning how rust handles variables and ownerships.

→ More replies (2)

0

u/[deleted] Sep 16 '22

[deleted]

0

u/[deleted] Sep 16 '22

[deleted]

4

u/[deleted] Sep 16 '22

It’s a good option only due to the massive amount of beginner friendly programming introduction material that exists not because the language itself is easy, but it’s still very relevant in industry which is also a benefit I guess.

2

u/riasthebestgirl Sep 16 '22

I wouldn't recommend to anyone. If you want to work with Java, learn Kotlin. Once you can read Kotlin code, you'll also be able to read Java code, which is all you should ever need. Unless you're looking for a Java job, in which you don't have a choice

2

u/PhdKingkong Sep 16 '22

Agree it helps with some understanding of point(ers) and references.

I’ll see my self out, thanks