@kubikpixel When learning a new language, doing so with a concrete, but not too complex, use case in mind is certainly the way to go. With the advent of code you get the benefit of being able to compare your solutions with others written in the same language (i.e. search on GitHub for adventofcode, year & language being Rust).
A web service with a simple scope (don't they all start out like this? 😅) will be a great toy project. With Rust, you need to be aware, if your not already, that it's standard library doesn't include HTTP or TLS protocol implementations (like C, C++, but unlike Python or Go). Since implementing HTTPS on a raw socket, multi-threaded is a bit of a steep learning curve, I would recommend to use a well supported library or framework for that part of your project, so you can focus on the logic you want to implement. This seems a good comparison list, ranked by how high level they are.
From the high-level ones I can recommend Actix web and Rocket (I've used the latter more, but the former seems to be more popular these days). Hyper (part of the Tokio stack) would be a level below, interesting if you wanted to build some kind of HTTP(S) API where you'd do all the routing yourself or it has only a single function (like, a lambda function). For HTTPS clients, reqwest would provide a more convenient interface over hyper's client library. All of these are built on top of each other, Actix and Rocket as well as Reqwest use Hyper and the former two also use other parts of the Tokio stack to handle multi-threading and dealing with the network sockets and packets.
@kubikpixel@JohnLaRooy The good thing about Advent Of Code is that many people will be doing the same problem and you can just ask them about it or check their uploaded answers :D
But I don't know how much of good fit they are for Rust beginners. I didn't do any Advent Of Code yet. This year will be my first :D
You should definitely finish at least the first couple of chapters in the official Rust book though :D
@kubikpixel dont be so hard on yourself. what matters is that you continue! if you keep at it you'll be able to look back in a year from now and appreciate that the delays getting started didnt actually matter.
@kubikpixel I'm using #Helix for #Rust programming and I love it. If you're going to give Helix a try then definitely follow the built-in tutorial first by typing (on the command line):
hx --tutor
And make sure to install the rust-analyzer tool so that Helix can highlight errors and warnings each time you save. Can be tricky to get the pieces to work together at first, but on re-reading the online instructions it becomes clear eventually.
@kubikpixel Not sure why people make things so difficult. Traits are pretty similar to interfaces, just better in certain regards.
Also, I assume you don't have a background in Haskell, otherwise, that would be relatively easy.
@kubikpixel I get that, and it's a great language. I am just saying people seem to have a tendency to not make comparissons that aren't 100% accurate. And saying "a Trait is like an interface" is not 100% accurate, but it is a good basic mental model, especially if you take into account things like the default methods of Java interfaces.
@kubikpixel traits are pretty essential. just printing out any non-string type will already use traits like Display or Debug to convert it to a string.
@kubikpixel It is good to learn traits well. The whole language is built around traits and any slightly more complex code base will make heavy use of them. I made the same mistake initially, thinking I can do traits later. But then I hit a brick wall when trying to write my first project.
@kubikpixel Really like the thread! And all the helpful comments too. Also fighting my way through the rust book myself. But you are way ahead, as it seems. Keep on, really want to here more. 🥳👍
@kubikpixel I would highly recommend Axum because it has more momentum and builds on an existing ecosystem (hyper, tower, tokio). I have blog posts about getting started with it with SQLx:
@mo8it@kubikpixel I’ll just add that another axum’s strength is that it uses the type system for its magic and not macros.
While axum (similar to #bevy game engine) sometimes feels like magic – it’s much easier to understand how it works and extend than (plain- and proc-) macros based frameworks.
Also, it’s basically just a library layer on top of request handling, so you can get pretty low-level with it, close to using hyper directly, if you wish/when you need.
Oh well, now I've moved on from "Hello, world!" in #development with #Rust to a simple form #web page. In that sense I've learned a lot, although very slowly, because I'm not mentally fit today. I still learn a lot every time I do the #RustLang. Well, then I'll configure the #Helix editor first so that I like it and it's easy for me to use 🧬🦀
@kubikpixel Using #Helix certainly boosted my productivity when developing in #RustLang. Used #NeoVim before but was unable to configure it such that it is as effective for me as Helix is out of the box.
Phew... I am challenged after a ~1⅔ month break with #learn'ing #Rust. Due to holidays and other circumstances, I had a (too long) break from learning #RustLang. I tried a simple #website with #Axum today but the first two hours were spent searching for instructions that would help me in a rudimentary way. Then I discovered the one from @mo8it and didn't finish but tomorrow I should be able to continue nitting my head 😅🦀
Since I am learning #Rust again and for other reasons, it takes longer for me to understand #RustLang. Well, today I solved the above mentioned problem. I #learned not to be annoyed by error messages when compiling because the written code does not work. Just read it carefully and take it into account and the #errors are solved and for me these are mostly sapalotte typos – tomorrow it goes on positively ➕🦀
@kubikpixel rust error messages looked like a foreign language when I first started working with the language. As I've gained practice learning to ready them, I can't imagine working without them.
I've heard rust folks say that if an error doesn't contain enough information to let you know how to it, they consider that a bug. That's just an amazing philosophy.
(Of course, it takes practice to learn how to read them to get the info so it's not an instant thing, but it's awesome)
Add comment