Learn Rust as a 1st Lang

Hi, I have a background in genetic engineering. I've suddenly become interested in learning Rust as my first programming language.

People say that Rust is difficult, although this is very subjective. What’s your opinion?

Is this possible? I’m IN The Book (which is excellent) and Rustlings.

1 Like

It is true that Rust is comparatively more difficult to learn than other languages, but at the same time Rust has the characteristic that it's very expressive and it's type system allows more local reasoning. This means that you pay upfront in terms of the time it takes learning things that you would otherwise pay in the long term in other languages (in the form of surprising behaviour at runtime and hours of debugging that).

5 Likes

Rust isn't a language I would recommend a hobbyist programmer to start out with due to its steep learning curve roller coaster.
Then again I'd not discourage anybody either if they proactively chose Rust as their first language out of intrinsic interest.
If you find fun in learning new stuff, Rust's challenges might become part of the fun of learning it.

4 Likes

I was going to comment that I recommend Rust as 1st lang to learn, since quite a lot of the friction of learning Rust comes from prior knowledge of other language. Then I saw this image, and have to say it's somewhat accurate. But for a total beginner I believe it would take a long time to ever reach the roller coaster part, so it's not that relevant I guess?

I believe that Rust can be a very good first language to learn for some personality types, but not for others. Compared to other languages, the Rust compiler is kind of like a really strict tutor that requires you to get all of the little details right from the start, instead of one that will let you do things a little bit wrong to learn from your mistakes.

The tradeoff here is that you'll get to the fun part of creating interesting/useful programs sooner if you start with a "traditional" beginner's language like Python or Javascript. But if you start with Rust, you're less likely to develop bad habits and the programs you do end up writing will be more likely to actually work the first time as you intended.

7 Likes

If you have a background in genetic engineering I think you must already have done some programming? Statistical analysis (R, Python), visualisation, ...

The best characterization that I've ever saw. It's not that it's harder to learn Rust. Rust is actually easier to learn it, than most other languages. It's very logical and orthogonal.

But it's much harder not to learn it (but start using)!

This can be a nightmare for the “stop with your lectures, ma'am, we want to finally turn the ignition key and try to drive that car” types.

2 Likes

I'm pretty certain that anyone who can get their head around genetic engineering will have no problem understanding Rust, even as a first ever programming language.

My only reservation is that the Rust Book and the Rust beginner resources I have found assume the reader is already familiar with programming concepts and terminology from other programming experience. I have yet to see anything for the real programming beginner starting with Rust.

No worries though, you can always ask anything here.

1 Like

+1 on all the comments so far. Functional language acquisition includes unlearning a lot of unnecessary habits. Once acquired, functional programming provides incredible power. By starting with Rust, it's possible to initially avoid such expenses.

But that's also like saying one can avoid buying a dozen cars in life before finally settling on a Porsche. Even then, sometimes one just needs a truck to haul plywood or move their belongings. Tools are what they are...

I suspect from your intro you are here because you've done some research and made some of the same discoveries we have. I'd say "welcome", but I am also new to Rust. So we're also on a similar path of discovery.

I am a big fan of the fewest number of tools in life because I can divide the fixed time we all have in life across fewer diverse methodologies. This improves effectiveness and safety. Getting the same job done sooner, having safer code that is easier to maintain... all good stuff.

I am still weary of claims that Rust is difficult for a first-time programmer. Many useful programs can be written without using any of the difficult parts of the language at all. These tools will eventually be needed, but by then a beginner would have graduated to an intermediate level programmer.

There is a book I always recommend when this question comes up: Introduction - Easy Rust. The reason for my recommendation is because it teaches the language intuitively, rather than assuming previous experience or a background in type theory. It is the perfect introduction for first-time programmers, IMHO.

The author also has a new book, but I haven't read it: Learn Rust in a Month of Lunches.

Compared to other languages, the complete syntactic and feature space is on par with other popular languages. You can build the same trivially useful programs in JavaScript without ever getting into insignificant details like ECMAScript version differences, or generators, or async/await, or functional programming. JavaScript supports all of these features (and so much more), but the majority of the language doesn't have to be learned by beginners. It is the same with Rust.

My gut feeling is that most of the "steep learning curve" reports are from people jumping into the deep end without first learning how to swim. I can only assume that because they already know another language, that gives them a false sense of confidence that they can easily learn any language.

In my experience, that has never been the case. Trying to learn Python after JavaScript was a huge pain. Trying to learn Clojure after C was even worse. Very few assembly languages share anything in common, and after the first half dozen you'll be well aware that skills acquired for one architecture do not readily transfer to others. Don't even get me started on Verilog or VHDL.

So yes, Rust is a good first language. Just humble yourself and remember that every language will be your first language.

4 Likes

AFAIK, the biggest trouble is that I don't know of any "I'm completely new to programming" resources to point you to that start with Rust.

I wish they existed, since I think that starting with Rust might be a great way to have some of its limitations feel more natural, rather than being confusing because they're different from Python.

I keep hoping that some university professor puts together a CS 101 course using Rust. I'd love to see the outcome of it.

4 Likes

I would love to see that, too. Because currently when you look on most Rust tutorials (including “The Book”) and see stack and heap and pointers and complicated data structures somewhere in the very beginning… one just wants to weep.

It's as if someone tried to teach you to drive car by first explaining how clutch works, how carburetor works, how octane rating is defined… and only then teaching to use the key to start the engine and pedals to control it.

It's much easier to understand how stack and heap work if you first learn about ownership and borrow system (and to teach about these you only need to teach someone about how functions are working) then to learn ownership and borrow system from knowledge of stack and heap!

The only reason most tutorials today teach ownership and borrow system on the basis of stack and heap is because their authors learned them in this order…

1 Like

This thread contains a lot of smart posts, there is not much I could add. But my feeling is that it would be very difficult or perhaps nearly impossible to create a Rust tutorial for the absolute beginner with no prior programming experience -- and that is indeed a bit sad. It is not only that Rust is a very complex language. I think the core point is, that Rust tries to protect about dangers like invalid pointers, dangling references, double frees, uncaught exceptions, race conditions, and such, that beginners might have never experienced. Teaching that by use of unsafe Rust might be an option. But I typically recommend to just use a language for a short period of time where you can have all these issues: C, Pascal, Modula, Oberon, maybe Zig, or even Nim would be candidates.

The other obvious problem with Rust as the first languages is, that my feeling is that in these days people interested in programming at all typically start early, maybe in the age of 12 to 15 years. I would not recommend to these kids spending hundreds of ours learning Rust. This is even more true now where AI is so fast developing, that we can not know if typical programmers are still needed in a few years.

I wouldn't worry about this too much. The exact same kinda of optimism (and worries) happened in the 70's and 80's, but just led to AI winter - Wikipedia

1 Like

True. However back in the day, before personal computers, we young teenagers in Technical College were introduced to programming via BASIC and within weeks expected to start becoming familiar with assembler. I cannot believe an introduction to programming using Rust would be harder than that.

As for AI, well if the AI is learning and doing everything for me where is the fun in that? So far I'm happy that Rust is so fussy, it manages to stop the slop I have had AI generate for me progressing anywhere important.

1 Like

I don't think there is enough time in CS101 - MIT is teaching python, and before that I think it was scheme.

Alto University in Finland did put out this online course - I think someone recommended it earlier (@ZiCog?). May also be of interest to OP.

1 Like

Looks like it wasn't designed as a first language:

Prerequisites

  • Basic programming skills
    • This should include at least operating with functions, conditions, loops and basic data structures. Knowledge about functional programming or object oriented programming is also beneficial.
  • Familiarity with working on the command line
  • Familiarity with using programming environments
1 Like

Yep, I recommended that online course at Aalto. I went through it after already getting Rust into production for a few years. Learned a few things. Got 3 credits towards a degree!

And, yep, the course is not aimed at rank beginners to programming. Actually it's so hard to get into Aalto all the CS students I have met there knew their way around programming before ever getting there.

I will check that out! - I have started and stalled on learning Rust a few times now - I don't have the consistent time available . . I'm not a beginner but maybe that book will suit my situation . .

In that case you could also try my "Rust for C-Programmers". You don't have to know C, but it would help if you know some basics about systems programming.

For the "Easy Rust/Rust in a few lunches" book: I read a few pages of that when I started with Rust at end of 2023. It might be great for people being afraid of any type of formal lectures. It uses the style of a 14 years old telling their 12 years old sister about Rust. "The heap memory is not that fast. Well, it is not really slow, but ..." :slight_smile: Well, it is a great attempt to make learning Rust easier, but I have some doubts that it really helps adults that much. The other free beginner book, which is not that easy to find, is The Rust Book (Abridged) | The rs Book. If I had known that earlier, perhaps I would never have started with my one. But my feeling is that the author has mostly retired now. But actually the official Rust book is quite OK.