r/adventofcode • u/matth_l • 3d 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,
21
Upvotes
2
u/RiyaOfTheSpectra 3d ago
I am trying to learn Lua right now, this way. It is fun. The manual really should tell you things like, printing
table.concat(array)requires you to specify a separator, though. Spent like, half an hour debugging what was perfectly fine code yesterday.8
u/Kip167 3d 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
4
u/Maximum_Expression 3d ago
Yes, last year I learned elixir during the AOC and then went on with exercism. Amazing language
1
u/flwyd 3d 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
rustcdoesn'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 3d 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!
1
u/vancha113 3d ago
Yeah, but it feels like relearning at this point :(
3
u/wubrgess 3d 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/Fadamaka 3d ago
Did AoC in Rust in 2023. I kind of agree with DHH's take on the language. I find no fun in Rust. I feel like you can use C++ in clever ways to solve certain AoC problems but Rust is so strict that you can almost only use it in the inteded way. But for AoC you need the language with the biggest footgun potential because being a footgun means it has a lot of freedom.
2
u/daggerdragon 3d ago
Changed flair from
OthertoHelp/Question. Use the right flair, please.2
u/R0b3rt1337 3d 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.
2
u/Morphon 3d ago
Using it to learn Odin.
Kinda similar. :-)
2
u/Psychological-Tap834 3d ago
I feel like I should just to tell if rust is as simple as I think. I know the borrow checker is annoying to understand at first but I've read the first bit of the rust book a few times and it doesn't seem too bad. I just never really had a project I wanted to make that rust would be good for when I was learning rust so I never bothered really using it and lost interest. However, this year I'm doing using AoC to learn common lisp.
2
u/MrS0phisticati0n 3d ago
Learning Zig with it.
2
u/Da-NKP 3d ago edited 3d ago
I've done that in the past, and I generally use AoC to "learn" a new language. This time I'm tag teaming Lua and Gleam. Boy howdy, is it whiplash going from an extremely simple, imperative, OO language to a complex declarative, and functional language like Gleam...
Edit: just finished day 2...twice. Did day 1 Gleam then Lua, which made the Lua kinda frustrating—_why can't this language just do the thing_. This time, I did Lua _then_ Gleam. Good. Gravy. Trying to mentally shift gears like that with one solid but entirely inapplicable answer stuck in my head was no joke.
1
u/Alesek2 2d ago
I tried to learn with it a few years ago but I feel like AoC is too short to get comfortable with Rust.
I gotta say though, I think it is a great way to learn Rust's quirks when trying to speed up your code.
For example, the pathfinding days taught me to use arrays instead of hashmaps, because indexing a stupidly big array is still faster than Rust's hashing
1
u/CCC_037 3d ago
I learned Rockstar a few years back.
Then I tried to learn MLP++ and, well, let's just say that until I did that I had no idea how good I had it with Rockstar.
I've pretty much stuck with Rockstar for AOC since then.