Is building stuff from scratch a valid way to learn?

(I wasn't sure which category to put this in, let me know if it would fit something else better)

Heyo. Before getting into Rust a few days ago I had been learning Lua, and I kept finding myself trying to build things that I now realize definitely already exists in some library or another.

So going into Rust, I know my natural inclination is to attempt to build something, as opposed to finding something.

And I'm curious, is this a valid way to learn, or would I be better off making sure to use crates when I can?

You'll always learn more by building something than finding something which does it for you. So as with all things: it depends.

In general, I'd recommend setting a task to solve, then

  • for problems core to that task, build the solution yourself, but
  • for problems incidental (e.g. "I need serialization") to the task you're directly working on, use a library to help.

A really nice thing about Rust and Cargo is that you can always just look at the source of the libraries you're using (including the standard library) and look at how they're doing something.

7 Likes

This is the approach I recommend to people when the end goal is learning. In an ideal world, you could rewrite everything from scratch and learn how your entire system works, but the world is often too complex for that to be practical.

It also helps if you pick projects which don't require you to add loads of dependencies to get started. For example, when writing a HTTP server it's practically mandatory to pull in some sort of framework for HTTP and libraries for database access. You can't be expected to write things like HTTP request parsing and routing and a custom Postgres driver from scratch unless you are already an expert in those areas, so it becomes more of an exercise in correctly composing things in a way the framework expects.

On the other hand, something like a compiler has a lot of depth (many books and courses are dedicated to the topic), but it's quite realistic to write the entire thing using just the standard library.

4 Likes

Thanks for the answers! I'll try to adopt this mindset.

It's not harder to write a tiny HTTP server than to write a tiny language. Just maybe less fun.

As for the question that topicstarter is asking about...

Here is job description of Software Engineer. Here is job positions of Application Engineer. Same company, yet different roles: first guy is supposed to, mostly, write new code from scratch while second guy is supposed to know certain frameworks well and would, mostly, connect components together to produce working result.

In smaller company these position wouldn't be distinct but these are, most definitely, different skills.

Usually you need both, but some jobs would be closer to one end of spectrum and some close to the other end.

2 Likes

An addendum...

  • Find a crate you use / like, pick a bug, then fix that bug using the style and techniques of that crate. This has helped me learn how to be "Rusty" from the good folks who blazed the trail.
2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.