r/adventofcode • • 2h ago

Help/Question Joining the big leagues

Anyone else using aoc to learn rust?

I feel genuinely lost, and I love it, it feels like past times (pre ai bs) again, never built anything with a lower level language,

8 Upvotes

7 comments sorted by

3

u/Kip167 2h ago

not this year, but previous years i used it while learning different languages like go. amazing for getting a good grasp of the basics and the syntax

2

u/Maximum_Expression 2h ago

Yes, last year I learned elixir during the AOC and then went on with exercism. Amazing language

1

u/wubrgess 2h ago

I stick to writing solutions in perl because my work moved on to more modern languages but it's such a fun one to write in.

1

u/R0b3rt1337 42m ago

I'm doing the same but with Zig. I've dabbled a couple of times in both Zig and Rust but never really gave it a serious try for a bigger project so I'm using AoC to prepare for that. Thinking through the puzzles is always fun and the ascii art you get to see after completion is a nice reward.

1

u/flwyd 23m ago

Is there anything you find particularly challenging? What higher-level languages are you more familiar with?

I recommend starting an AoC puzzle in Rust by focusing on getting any workable solution, then take a step back and think about what about it seems awkward. There's probably an idiom or library that can help make the awkward bits smoother—or that can improve the efficiency of a solution—but if you start by trying to write the most idiomatic, most efficient solution you may struggle to come to a solution at all. One nice thing about Rust is the compiler error messages often tell you what code you might need to write to fix the problem. So try something, and if rustc doesn't like it, you might be able to copy the code it will accept.

I spent a bunch of time in October reading The Rust Programming Language (maybe the best introduction to a language I've ever read), then spent about half of November putting it into practice on AoC 2019. Having already read the book, I didn't find much that was particularly challenging about the language (the compiler still needs to tell me where to add or remove an & or * though), but that might be because I was able to map my existing understanding of ALGOL-family languages to Rust concepts, and its functional-style features are similar to those found in several modern object-oriented languages. If I hadn't read the book first, I probably would've been pretty confused about a bunch of things, in part because I would've been trying to mash Java-style patterns onto a language with a different approach.

1

u/wjholden 7m ago

Are you going in completely cold? As in, did you already read the Rust Book or other material?

Asking because I did exactly that a few years ago. I sat down on December 1st, downloaded the compiler, and tried to just start coding. It didn't go well. I had done this with Julia and Python in past years, but those languages are a lot more forgiving. I gave up on Rust at the time, went back to Julia, and didn't touch Rust again for a few years - by reading the book.

It will be worth it, but it really is a challenging language to learn. Have fun!