DEV Community

Bastian Gruber
Bastian Gruber

Posted on

Rust for the Brave and True

thinkpad and linux

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", 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

After receiving my Thinkpad, I removed Windows and installed Arch from a USB stick, following these steps. After 4 tries I finally succeeded. When I booted the first time, I installed i3 and 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 or TCP/IP Guide and dig deep into the system
  • I can read the 2600 magazine 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:

With the following PlugIns for NeoVim:

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) 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 and a proper keyboard. 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 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.

Top comments (17)

Collapse
 
jesusgollonet profile image
jesús gollonet

Damn this hits it really close to home for me. I've been mulling on switching to arch linux for quite a while for pretty much the same reasons. I already spend my life on a terminal and linux servers.

Main reason for me not to do it is now down to evernote + ios (as user, not dev), which are quite key to my (work|think)flow.

It will happen eventually

Collapse
 
gruberb profile image
Bastian Gruber

Just pick a browser solution and the transition is easier!

Also: You could see the new iPad with ipadOS as a org/computer replacement, and use the Linux hardware to work and tinker.

Collapse
 
jesusgollonet profile image
jesús gollonet • Edited

Just pick a browser solution and the transition is easier!

That's fine for the tools that I want to use less but not the key ones. For me using evernote from a browser would be similar to running my editor from a browser. Technically possible, but not something you want to do every day.

I need a proper desktop replacement with keyboard shortcuts, instant sync across devices and seamless mobile experience.

iPad with mosh and a remote instance is also something i've played with and need to research more to see if it could be a full on replacement

Collapse
 
davidchase profile image
David Chase

Nice write up!

I found the book called "Clojure for the Brave and True"

Thanks for that suggestion !

What are your thoughts on Arch Linux?, thinking about trying out that distro too

Collapse
 
gruberb profile image
Bastian Gruber

It's not as comfortable, as lets say Ubuntu or Debian. However, it's nice that you really know what's on your system since it's completely bare bones and every addition has to be installed.

Collapse
 
davidchase profile image
David Chase

Yeah thats what i heard, ive used both Ubuntu and Debian before along with some others.

Guess im going to just give a go :)

Collapse
 
johncsimon profile image
John Simon

Building and rebuilding a work environment is a kind of yak shaving, and after a certain point I have to say Enough and get on with actual work.
But, yes, if someone is doing anything at the systems level for the first time, the blog posts are culturally geared toward Linux and anything else would be a kind of friction.

Now the question is "What to work on?" and
"Should I just be learning or should I be contributing to an existing project?"

Here's fifteen hours of live coding TCP in Rust youtube.com/watch?v=bzja9fQWzdA from Jon Gjengset (who is clearly a lot more confident in a top down interface based approach than I am).

I suppose a good first networking project would be to rebuild netcat in rust.

I'm also looking at github.com/uutils/coreutils which is remaking BusyBox in rust. There's lots of interaction with the file system there.

Collapse
 
r7e98kva profile image
Markus

What's the big difference between brew install an yay install/Pacman install?

Even on osx you can use an alternate window manager very similar to i3 🤷🏼‍♂️

Collapse
 
itsjzt profile image
Saurabh Sharma • Edited

Disclaimer: Not the original author

I think the difference is the feeling you get when you use something more near to metal.

I also got same-ish feeling by using knex.js instead of some ORM

Collapse
 
vjancik profile image
Viktor Jančík

Awesome resource! Thanks for putting this together.

I went down this rabbit hole myself two weeks ago. Two days spent tinkering with Arch + i3, ended up ditching it for Manjaro i3 and springboarding from there. Saved me a lot of blood and tears for essentially all I really wanted from the basic setup.

It did not work out for me however, because I have a Dell XPS 15 with an external graphics card that I actually need (for work), and there's terrible support for internal/external GPU switching on Linux.
So I can either have the GPU or I can have my battery (Nouveau / Nvidia drivers halve my battery as they run the GPU all the time).

So right now, I'm exploring WSL (Windows Subsystem for Linux) and with the release of WSL 2, and the expanding capabilities for Remote development in VSCode, I have to say it's working out so far.
Still no GPU bridge of course, but at least it's out of the box functionality with my graphical applications (Firefox, WebGL) running optimized in Windows.

It's worth checking out if you ever get bored of your current setup. :)

Collapse
 
gklijs profile image
Gerard Klijs

I just use my macbook with IntelliJ for all. Mostly Java, but Clojure is nice with Cursive, and the Rust plugin is great for Rust.

Collapse
 
moonpalace4 profile image
websealevel

Thanks for this wonderful article. It hits me, currently having the same approach and desires, to be closer to the machine. Free distraction environment. It is so rewarding to build your own environment and workflow from "low level" constructs

Collapse
 
jonathans profile image
Jonathan Sundqvist

Out of curiosity what prevents this?

I can't do Systems Programming on a MacBook Pro running macOS

Collapse
 
gruberb profile image
Bastian Gruber

I should have been more specific. I meant that if you read books/tutorials on TCP/IP, they all assume Linux command line tools. So yes, I can install them and all is fine.

However I like to be on the same machine as those writing the tutorials. At least for the time being. Who knows a few years down the road, but for now, I decided to "have a healthy fridge", as the analogy in the article would say.

Collapse
 
shenril profile image
Shenril

Let's ask the real question here
Why would you feel the need to buy another keyboard when you already the thinkpad one? :D

Collapse
 
russoue profile image
Mohammad Husain

Do you have links to the Thinkpad and the Dell monitor you bought?

Collapse
 
gruberb profile image
Bastian Gruber