Rust for the Brave and True
Tags: rust, linux
Published: 2019-06-11 13:12:29

---
title: Rust for the Brave and True
published: true
description: If you want to learn Rust, go all in
tags: rust, linux
---

![thinkpad and linux](https://thepracticaldev.s3.amazonaws.com/i/jtwjm41l472ciamvqzi6.jpg)

A few years ago, I wanted to make the switch from Frontend to Backend. One day I fell down the YouTube rabbit hole and (partly) watched a few tech talks. I realised that many of the really good talks were held at Clojure conferences. I looked into it, and decided to learn Clojure. 

The lust for learning a new programming language often times comes from the sheer boredom of your old work, so you also want to redo part of yourself. After a bit of research, I found the book called ["Clojure for the Brave and True"](https://www.braveclojure.com/), and absolutely loved it.

After a few weeks however, I gave up. The book wants you to jump all in and learn emacs at the same time as well, since it provides, according to the book, the best environment. I really liked the idea, but abandoned the project also due to the lack of Clojure positions for Juniors in my area (Berlin, Germany).

# Rust

A few years later, today, I started to learn Rust and got excited about the whole ecosystem, community and possibilities. I read, wrote and programmed a lot in Rust during the last few months. So much so that I got a Rust position at a company starting August (yay!).

# Brave

But, as I digged deeper and deeper into the language, and watched tutorials, I figured: I can't do Systems Programming on a MacBook Pro running macOS. Don't get me wrong: Once you mastered a skill, it doesn't matter where you operate it on. Also a different machine doesn't make a huge difference.

Although, I might disagree a bit with that. Take loosing weight for example. Just cutting down a few kcal per day won't make a huge difference. Your fridge has to look completely different so you are less tempted to eat all the bad things and naturally will nurture your body in a more healthy way. 

> I remembered the "Clojure for the Brave an True" concept, and wanted to apply it to my Rust environment

This is exactly what I aimed for when I ordered a Thinkpad X1, with the intention to install Arch Linux on it. Instead of nurturing my body, I wanted to nurture my brain in the right way. If I want to learn about TCP/IP for example, I don't want to `brew install` the right package every now and then.

### My reasons:

- I want to spend almost all of my time on the command line
- I realized that even macOS is constructed as a perfect source of leisure and wasting time: I wanted a pure work machine instead
- My plan was to spend idle time not in front of a screen, but read a book or write
- I wanted less distractions from my operating system
- I wanted to feel closer to the machine


# True

![vim and Rust on Arch on a Thinkpad X1](https://raw.githubusercontent.com/gruberb/dotfiles/master/code.png)

After receiving my Thinkpad, I removed Windows and installed Arch from a USB stick, [following these steps](https://github.com/gruberb/dotfiles). After 4 tries I finally succeeded. When I booted the first time, I installed [`i3`](https://wiki.archlinux.org/index.php/I3) and [`alacritty`](https://github.com/jwilm/alacritty) as my terminal. Next to this, I installed `Firefox` for browsing. That's it. I need a terminal, a window manager and a browser. I barely touch my mouse any more.

### What I learned from it

- Using my browser to keep up with Slack and E-Mail, I finally reached my goal of just checking it twice a day (because it's just less convenient).
- Just installing Arch made me touch so many aspects of an operating system (again), and it's not all that hard to understand certain areas 
- I can buy books like [The Linux Programming Interface](https://nostarch.com/tlpi) or [TCP/IP Guide](https://nostarch.com/tcpip.htm) and dig deep into the system
- I can read the [2600 magazine](https://www.2600.com/) and follow along the tutorials
- It made me less distracted during work, since I literally have no notifications or other distractions

Working under macOS, I constantly opened other programs while I didn't know how to proceed on a task. With Arch, it's much harder to do so (and less fun). I have a physical notebook instead next to me and I will, if I can't proceed on a problem, note down my thoughts in the notebook and stare out of the window to think again.

I am excited again to be closer to the hardware I operate on. Being able to master `nvim` and setup a proper `tmux` setup is so much faster then doing the same workflow inside Visual Code or other editors.

# Rust Coding Environment

I am using:

- [NeoVIM](https://neovim.io/)
- [tmux](https://github.com/tmux/tmux)
- [Rust Langauge Server](https://github.com/rust-lang/rls)

With the following PlugIns for NeoVim:

- [neovim-airline](https://aur.archlinux.org/packages/neovim-airline/)
- [LanguageClient NeoVim](https://github.com/autozimu/LanguageClient-neovim)
- [Deoplete Autocomplete](https://github.com/Shougo/deoplete.nvim)

That's it. You can easily setup a `tmux` session, split the window where you have your code inside `nvim` and on the other half of the window `cargo run/watch`. 

Moving through code like that makes it really hard after a while to use a normal code editor again. Allthough you can install `vim` bindings to VS Code I guess.

# 2 Warnings/Hints

- Always have a workable Live-USB stick with Arch installed with you in case of an emergency. I tinkered with the startup script and got myself into a loop. I had to boot from the stick, decrypt and mount my hard drive and then revert the changes to be able to boot again.

- In addition to my Thinkpad, I operate a remote server (for around 10 Euros/month) for backups (via [`rsync`](https://wiki.archlinux.org/index.php/Rsync)) and other fun activities. It can help to have another machine for backups just in case you want to take a snapshot of finally perfect configured Arch installation.

# Additions

In addition to the Thinkpad, I got a [vertical mouse](https://www.amazon.com/Vertical-Mouse-Ergonomic-Optical-Wireless/dp/B07HSMS6Y2/ref=sr_1_11_sspa?keywords=vertical+mouse+csl&qid=1560258082&s=gateway&sr=8-11-spons&psc=1) and a [proper keyboard](https://mechanicalkeyboards.com/shop/index.php?l=product_detail&p=4322). Both of which even increase the fun of my setup. My monitor is a Dell 4k 27" which is hooked up on a monitor stand.

This is so nice to work with that I even don't miss the beautiful 5k LG UltraFine at all, which I previously had.

# Summary

I provide [the basic dotfiles and steps](https://github.com/gruberb/dotfiles) for my setup on my GitHub account. It's good to run contrary to certain environments. The iPad for example became so powerful that the casual user doesn't need a Notebook anymore to do every day tasks. That's a perfect time to reconsider your relationship with your tools you are using.

If you follow the steps, it's really simple to operate within Arch on a Thinkpad. You need to tinker with HDPI here and there, and adjust some hibernate functionality. But overall it's what I wanted: The bare minimum to get to a comfortable coding environment, with almost no distractions. 

In the end, the Thinkpad also has a much better keyboard than the MacBook Pro. Also the form factor is just perfect. A bit bigger than the 13" and smaller than a 15" model.