r/teenagersbutcode • C++ • 4d ago

Other discussion How to learn Rust

I have quite some experience with C++, but after considering everything I would have to do, and some inconveniences of the language, I am choosing to switch to Rust.

In Rust, I would like to write my own OS, but first want to get experience by making smaller scale projects. As I already know C++, I primarily need projects where I will write a lot of code (to be familiarized with the syntax and where I will use features such as ownership, lifetimes, borrowing, and Box<T>s to be prepared for making an OS in Rust.

May anyone suggest projects I can work on (without a tutorial, but with a good amount of docs available)

1 Upvotes

10 comments sorted by

5

u/realrealvantheman 4d ago

Dont write an OS in Rust. Trust me, bootstrapping a Rust compiler on a new system is very hard. It will help you a lot if you write it in something simpler.

1

u/CubineGaming C++ 4d ago

ill have the linux ABI and be POSIX-compliant, so I won't need to bootstrap anything

I also won't need to make drivers for the same reason

2

u/realrealvantheman 4d ago

Oh, nevermind then.

1

u/TheFrogg3 3d ago

May not be the best way, but if I want to learn a language, I usually start with a website like w3schools and then go to YouTube tutorials for more advanced topics.

2

u/CubineGaming C++ 3d ago

Both are incredibly slow and I have a library I can use (personally). My main concern is decent-size excercises as I learn best by doing.

When I was doing C++ I kept on trying to read books and watch tutorials but tutorials were slow and easy to get distracted from, while books made it hard to comprehend some things, so I decided to just make a graphics engine and I immediately had a much better time and learned rapidly.

2

u/CIMPBIBAI 4d ago

Make a basic OS by yourself (little to no ai) in C before doing it in rust.

If C is a pain in the ass, rust is going to be a kick in the balls for OS development given:

  • hella unsafe blocks for everything
  • essentially porting rust to your OS if you want to selfhost it
  • less resources or utils for writing oses in uefi or bios.

1

u/[deleted] 4d ago

Bro, osdev is one of if not the worst place to use rust. You'll have to use unsafr blocks everywhere, a bunch of features will be locked, and it'll be an overall pain. Just use c. Even freestanding cpp works. But not rust. It just wasn't made for this stuff. 

1

u/CommunityJazzlike274 4d ago

writing an OS in C is probably easier than rust

i say this as a rust user and lover

1

u/flowicks 3d ago

https://microsoft.github.io/RustTraining/c-cpp-book/ch00-introduction.html

i also use cpp and planning to learn rust sometime not rn tho. Saved this for then, hope it helps.

0

u/rileyrgham 1d ago

Write your own OS? Lol.