Learning Rust at Hacktoberfest in Eight Hours

Tricks for mastering this relatively new technology

Sergey Dubovyk
Oct 14 · 8 min read

This year’s #hacktoberfest became a great opportunity for me to start learning Rust. In this article, I will share a couple of tricks on how to start mastering this relatively new technology.


Motivation

You rarely buy a car when you are happy with your current one. It’s the same with technology. I mostly use JavaScript (or TypeScript) with Node.js or Python at the moment.

These are great languages for their purposes, but as with everything, they have some limitations. Specifically, CPU-heavy tasks or things that demand the processing of large amounts of data. There is a movement towards solving those problems, however, it’s not that significant.

That’s where Rust comes in. I heard it is a strong static-type language which inherits the best of C/C++ and provides amazing performance, as well as guaranteeing memory and thread-safe execution.

What an amazing thing it must be! I thought so for months but never had time to test it.

And then I heard about Hacktoberfest from my team members at Redoc.ly who were organizing the event. “That’s it! My chance to switch and learn something new,” I thought. Also, I wanted to give myself the challenge of learning new technology fast.

So, I waited until the local Hacktoberfest event, went there, and started learning.


What Is Hacktoberfest?

Hacktoberfest 2019 logo

Long story short. Hacktoberfest is a great way to contribute to open source and get a cool T-shirt for it.

A bit more info: It is a month-long event by Digital Ocean and DEV. During the event, everybody who creates four or more pull requests for open-source projects hosted on GitHub gets a chance to win a cool T-shirt.

The event gets more popular each year and in 2019, the are more than 500 on-site events where you can join a bunch of other programmers and solve some issues during the day.

For my experiment, I decided to go to the offline event as I hoped to get some help in case I would need it and also offer some of my experience with JavaScript or Python to other participants.


Getting Rust

To start, I navigated to the official Rust website. The first good sign was that it is really clear and intuitive. Just go to the installation page and copy-paste one single command into your terminal.

And that’s it. You only have a Rust environment manager (which is called rustup and manages all the toolchains you need), a package manager (cargo), and a bunch of other useful tools.

When you have the basic installation ready, go to the terminal and type rustup --version and cargo --version. That should print versions of the compiler and package manager installed.

Checking we have installed the Rust toolset

Another awesome thing is that Rust suggests a bunch of editors/IDE’s plugins that make the development process painless in most of the existing editors (VS Code, Atom, IntelliJ IDEA, and others).

For me, I chose to use VS Code which I use for my daily tasks.

Now, we are ready to start hacking.


First Steps

First of all, let’s create a simple Hello World application to familiarize ourselves with the basic syntax of the Rust.

The official documentation is a great place to start with that. It gives a simple example of a guessing game that I have used to get some understanding of the language.

I won’t even provide it here, as the official tutorial is just awesome and iterates from literally a Hello World to a functional game.

The final result is the following code, which shows a basic example of flow control, I/O, and Rust’s very special approach called ownership. It might be somewhat mind-blowing at first glance, but after some practice, I saw the elegance of this solution.

The guessing game source code is in the official Rust tutorial.


Checking the Toolbox

Sometime after the Hello World I was wondering, how rich is Rust with tooling for testing, linting, and so on?

As I have already mentioned, it has a bunch of editor plugins, but it also turned out that Rust has already developed an ecosystem for most use cases we might need during day-to-day tasks.

Screenshot from the Rust’s tools page

Getting Your Hands Dirty

That’s all fine, but it might become boring pretty fast to learn from such synthetical examples. So, I decided to go wild and use Rust for some real projects.

Generally, it’s a brilliant idea for any Hacktoberfest participant to find issues to work on before the event.

In our location, that was a major problem, as lots of people came with no ideas on what to do, so they spent a lot of time crawling over GitHub looking for any viable issues. It’s much easier to spend an hour or two a couple of days before.

I didn’t have any ideas for open-source and neither do we use Rust for main projects in my job (at least, for now). So, what can a programmer do, when they want to write some code but they’re not sure which code?

Browse open source, of course. A couple of days before the event, I opened my browser to find some issues to work with. There are a whole lot of projects written in Rust on GitHub.

Quite a large part of them are popular and have some active issues. I used the Advanced search to find Rust repositories with more than 500 stars.

For myself, I found two projects to contribute to:

  • Hyperfine (A console benchmarking tool that I am using day-to-day.)

And that is another good point here. Try to find a project you already use. For some main-stream languages (such as JavaScript or Python), it’s easier as they have much more tooling written with them, but it’s also possible for ones like Rust or Go.

After a quick review of the repositories, I found one issue for each of them to work on. Both well-defined, which is extremely useful for a new language and project.

Issues are self-contained, so I didn’t have to dig through the whole codebase of the project to get those tasks done. A good idea was to contact the repository’s maintainers.

It allows you to:

  1. Ask if the issue is still relevant (as one of them was quite old).

Authors of both projects responded fast, so I finished my preparations and was waiting for the event. I was not completely sure if I would be able to finish them in time, so I booked the next day to be able to finish contribution on time.

I will not go into details of the implementation as that’s quite project-specific. Here are just a few things I would like to mention about this experience, both regarding the Rust language and my approach in general:

Ownership

It blew my mind the first time I read about it. Then, I spent some time trying to understand it. Gave up. Tried again. Gave up. Decided to do something useful and eventually got the idea. After that — enjoy it.

Timing is important

It is important for every activity, but the format I participated in was an offline event. So it was twice as crucial as with the online-first approach.

So, plan, maybe even create some reading lists for top five problems you believe you might encounter.

Networking makes a difference

Working on issues was not that hard, so I had plenty of time to spend on networking.

And, even though there weren’t all that many participants, it was a great opportunity to borrow some experience from different ecosystems with which I rarely interact.

Outcome and Thoughts

I didn’t learn Rust in eight hours. However, it was an amazing start after which I:

  • Started to contribute to open-source software.

Such activities might not be necessary for your development as an engineer, but, I believe it will help with that.

So, I strongly encourage you to check the Events page of Hacktoberfest and if there’s an event coming near you — visit it to have an amazing time.


Additional Resources and Tutorials

If you have heard about Rust (or other tools that you have never tried out), I strongly encourage you to give it a try!

Life’s short and we should use each opportunity to learn something new and potentially useful. Especially if the learning process will bring some value, not only for us but for the whole community as well.

If you, like myself, tried or are going to try Rust, you might end up liking it, looking for more information and tutorials.

In this part I will list the ones which I find the most useful:

  1. The book is an overview of the language from the first principles up to quite complicated approaches.

Also, there are two books which tend to be highly appreciated on the web, as a good starting point. I did not read them yet, but will mention them here to show you the full picture:

  1. The Rust Programming Language. This is a guide to Rust, written by two members of the Rust core team, with feedback and contributions from 42 members of the community.

Finally, there are some useful questions and answers which you can find on Stack Overflow.

That’s the end of this piece, but I hope it’s the start of your experience with Rust. Keep hacking!

Better Programming

Advice for programmers.

Sergey Dubovyk

Written by

Software engineer (JavaScript, Python, Golang, Rust)@ Redoc.ly lurking around searching for amazing stuff

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade