blog.cemunalan.com.tr

My Migration from MacOS to Ubuntu

26 Ağustos 2020

Yeah, this is one of those articles. You see these pop up in your favorite news aggregator when Apple does something stupid. The last wave was with the butterfly switch keyboards.

Why did I make the switch? Because my Mac got really old and where I live, they are damn expensive to buy. I had to find an answer to my “can there be an equally pleasing work environment without a Mac?” question before spending a bunch of money.

My Workflow

My workflow is a very basic web developer workflow. I’m a backend developer by day but I do lots of JavaScript/HTML/CSS on my side projects. My main editor is PHPStorm for PHP and VSCode for other everything else. I use Docker to run projects on my local environment but working with a low-end Mac, it is difficult. I have really gotten used to Fork and Sequel Pro as my go-to tools when doing development. I use the standard Apple Terminal. That’s about it.

I got the Late 2013 Macbook Pro 13 inch with 4GB RAM back in 2014. It was not impressive when I first got it and it certainly not impressive now. I mean it was not a bad buy. I have been using it for the last 6 years and I can still do some light work on it. Even the battery still holds up for about 3-4 hours after 1200 cycles.

State of the battery

But anything other than light work just does not cut it. Coding in an IDE such as PHPStorm? Docker? Slack, Spotify, and bunch of other Electron apps running in the background? You’ll see the computer crumble with continuous swapping.

So last year I have built a Hackintosh from my old desktop. It worked like a treat even with an AMD CPU. The only drawback was that Docker was not working. That’s a known and sort of unsolvable problem. So after a while, it was a no-go for me.

My AMD Hackintosh a.k.a Ryzentosh

So I jumped the ship. I wanted native Docker speed on my local development workflow and installed Ubuntu 20.04. Here is what happened.

Docker

Yeah, it is amazing. Running your local web app using Docker on Linux gives you incredible performance. There is no hidden Ubuntu VM in between like in the Docker for Mac. It just works natively. Performance and ease of use is alone a good reason to switch to Ubuntu (or any Linux distro, really). If you are using Docker in your local development setup, you should seriously consider switching to Linux.

Here is an example. A simple PHP request with the Laravel framework may take multiple seconds with Docker for Mac. At my last day time job, I used to get a timeout from the server since PHP does not respond in 30 seconds. Yikes. So iterating, doing multiple refreshes on a page was a very slow process. On my Ubuntu setup same request generally takes around 80-100 ms, as it should be.

The Keyboard Layout

I think the MacOS idea of having the “Cmd” key for system-wide shortcuts and leaving “Ctrl” to do it’s on thing in the Terminal is brilliant. You kinda miss that when you switch to Linux as there is no such distinction.

I do still have a Mac so switching between Ubuntu and a Mac was a struggle as keyboard and shortcuts change dramatically. After some time I have discovered Kinto.

It markets itself as “Type in Linux & Windows like it’s a Mac” and I can say that it does it’s job very well.

This is a very noob-friendly tool that runs a program on your computer that listens to your keyboard inputs. It also knows which program is active on the screen so it can make decisions based upon that.

So if you are in Firefox pressing “Alt + C” on your keyboard equals to “Ctrl + C”. Just like “Cmd + C” on a Mac. However, if you are on a Terminal emulator, pressing “Alt + C” means “Ctrl + Shift + C” which is a copy. You have to press “Ctrl + C” on your keyboard to make it register a “Ctrl +C”. So it’s basically the same as using a Mac.

If I didn’t own a Mac, I would suck it up to get used to the keyboard mapping but currently, this setup makes me very happy.

Installing apps: Snaps and AppImages

Snaps are controversial. Since I’m new to the Linux distros, I just wanted to go to the most streamlined way of doing things. I gave the default Ubuntu Software Center and snaps a chance when installing apps.

I would say from a newcomer point of view that they are… fine? To my experience programs are extremely easy to install/uninstall. I think that’s very important especially when you are new to an operating system. You try a bunch of things, explore programs, install them, remove them after 5 minutes, and don’t have to worry about dependencies or configurations left behind.

It keeps the old versions of the programs in the disk so you can do a rollback. This saved me big time the other day as Slack’s latest 4.7.0 release started crashing. I had to revert to 4.4.3 and it was… very convenient. Just a simple command to do the roll back.

There are of course some problems. For example, they are incredibly slow to boot up. Like opening up a calculator takes multiple seconds. Makes you think you are using an HDD instead of SSD.

I believe due to some sandboxing problems, clicking links on Slack and Skype was not working for me. It simply does not open the links in the default browser. You have to dive into the forums and figure out what the hell is going on.

So there are definitely some problems with them but I also benefited features that are not in “apt-get” quite a lot.

Some of the apps I use are not distributed as snaps but rather as AppImages. Those are quite common, especially with Electron apps. These AppImages resemble installing a regular Mac app that you drag and drop to your Applications folder and just click to execute.

On Linux it might not be straightforward as your Desktop environment (Gnome or KDE) may not pick up the icon of the app to show in dock or it might not create a item in applications list (For example for Gnome you should add a desktop item manually). You once again have to learn how to make your app appear in your desktop environment and read some forums. So not as convenient as I hoped it would be.

Web Development Tools

I think there is no point arguing whether if there are enough web development tools in Linux. All of the IDE’s released by JetBrains are in Snap Store, ready to be installed with one click. Electron apps are not efficient in terms of resource management however I’m grateful that they exist now that I’m on Linux. A lot of the apps that would normally not see the light of day on Linux are now readily available.

So it was very easy for me to find replacements for my web development tools.

In terms of the terminal, I was not expecting anything fancy since I was a Terminal.app user on a Mac. Gnome Terminal does the trick for me.

I was a huge Sequel Pro user. Sequel Pro is very unique that it basically does not have a replacement in any platform and people keep using it even though it’s very buggy. It literally crashes if you close a tab or a window and yet, multiple people at my last work including me was using it daily. So I was not expecting to find a feature-parity alternative on Linux.

First, I gave CLI tools a go. “mycli” is an amazing CLI tool for MySQL. It also has a PostgreSQL equivalent called “pgcli”. It features a very solid autocomplete and generally more convenient than using the default MySQL CLI tool. I’m mostly using that for accessing databases.

As a backup, I have been using DataGrip if I want to do things in GUI. It’s very big and feature-full compared to the Sequel Pro but it’s a good backup. You may also want to take a look at Beekeeper Studio.

As I have mentioned before Fork was my daily driver when it comes to git GUIs. Unfortunately, there is no Linux version of it. I gave GitKraken a go but it feels very slow, bloated and you have to create an account to use it… It does not feel like a computer program, but more like a Startup-y SaaS-y thing. Then I found out about Sublime Merge and I was pleasantly surprised that it does a very fine job. The user interface is very different from popular git GUIs but it’s fast and reliable.

bash vs zsh

I try to keep thigs as default as that makes migrating from one computer to another computer very easy. I tweak very few things in my IDE. Just the default light theme and Vim emulation mode. In terminal, I try to use the default terminal application of the operating system.

One of the major things I was not using in default was my shell. I always used zsh and oh-my-zsh. I have no recollection of how I got to use them. I guess they looked cool and oh my zsh made it easy to extend things. This time I wanted to go the other way and decided to stick with bash as that is the default shell for Ubuntu and MacOS. I don’t do shell scripting so zsh’s features around shell scripting go above my head.

I started by opening up the default .bashrc that comes with Ubuntu. Boy, that thing is bloated. I did my research and deleted most of the things that come with it.

One thing I can’t live without is the git branch on prompt. There is really no need to install “zsh” just to get that. It’s just a one Google search away. As a plus you get to learn a bit of bash scripting, what is a “prompt”, what is PS1, and all that.

Small Cuts

Terminal, commonly used apps, development environment… Those are the big points you think about when you migrate from one operating system to the other. I have managed to find my comfortable setup there as I have explained above.

However, there are other types of things that you don’t really think about before making the migration. I refer to them as small cuts. You don’t generally plan for them but they hurt your day to day flow.

Here are some of them.

Preview: I miss this software every day. It’s dead simple to highlight stuff on images/screenshots, sign documents, resize photos, and lots of other stuff. Losing this app hurts a lot. I’m sure there is a great online editor out there but I have yet to find it.

iCloud: If you like iCloud and depend on it on a daily basis plan this one ahead of time before making the switch. There is no great way of natively syncing things. Don’t rely on it. I back up my files on iCloud and use the Apple calendar. I can get away just using the web interface of iCloud but I have to admit, that web interface sucks big time.