Autopergamene

Back

Gotta Go Fast

Published a year ago
13mn to read

It's safe to say programming, and everything around it, evolved tremendously since the Internet's beginnings. If you've ever created a Frontpage website or battled with Dreamweaver and Flash applications you know we've traveled a long way to get where we are now, and all along this way great strides were made to improve how we work. We got better languages, better tools around them, better integration and interoperability. We tried to standardise things, rethink how we worked, all in the spirit of making it easier and easier to implement ideas.

And yet, yet things also didn't change all that much did they? When you look at what constitutes a day of work, for a lot of programmers it still amounts to looking at lines of code on a plain background, looking at a terminal window, typing the same commands again and again. Why did that not improve as drastically as everything else? Or did it and have we just all grown so accustomed to learning just enough to be functional that we've forgotten to seek improvement? How many people use Git daily and know at best three or four commands?

Being a fast programmer isn't all about architecture and reasoning and solving problems. While it accounts for a good chunk of it, once you remove the "coding" part from "coding" what makes a programmer faster than another? The answer is the ability to reduce friction – everyday micro-slowdowns that happen in and around every task and that we've all (maybe) let fester into our workflows.

So what can you do to get faster and remove these slowdowns? Let's review some great starting points to help you be a more productive self.

Hocus Focus

The first thing we need to eliminate, is distraction. Imagine you have an issue to work on, you know precisely how you're going to implement it, all that is left is the dirty work. The first thing you should try, is to get some additional focus. The internet is the Great Bastion of distraction, its only purpose is to grab your attention and hog parts of your brain capacity. So a great first step is to kill everything else but the task at hand: quit Slack, quit your email, put your phone into silent, maybe put some nice ambient music.

By removing external distractions around you, you allow your brain to focus entirely on the task at hand instead of letting it "multipurpose" and think about notifications and other tasks etc. And it will make it that much easier to "get in the zone" and achieve great strides in productivity. Think about all the time spent alt-tabbing to check a notification that you didn't even need to care about in the first place, think about all the brain time occupied at thinking on multiple levels, this is the first chunk of slowdown you need to eliminate. So first step: create some head space around you to comfortably work in. If you're working from home, try working from a different scenery, as long as it also helps reduce the amount of distractions.

A great way to have "Focus Time" quickly is to create an Automator quick action workflow that quits all annoying applications:

1jVwqoM

Then from any application you can go to The App → Services → Your Quick Action and it'll get you started.

Once you're used to focusing regularly, you need to remember that with great focus comes great responsibility, and another aspect people often overlook is to take small regular breaks. Those help "clean your palate" between two tasks and prepare your mind to focus more intensively. You cannot have one without the other, if you want to dedicate yourself to one task, you also need to learn to let go of others.

Terminal Velocity

Once you've achieved some calm, let's first look at the terminal. The terminal should be every programmer's best friend, and if you've always put off learning to use it you're definitely preventing yourself from reaching full speed (even though there's some amazing GUI tools out there).

Aliases

The most important thing you need to learn is to create and use aliases. For this you need to think about all the commands you type in the day and think of which ones you're tired of typing. The key is to realize an alias doesn't have to be a full command, an alias can be partial, per example alias gco=git checkout and then gco my-branch.

You can put all your aliases in any file loaded on login (.zshrc, .bash_profile, etc.), don't be afraid to create a lot of them even if you don't memorize them. You can at any time look for a particular alias by doing alias | grep checkout. Calling alias alone will list all registered alias, and grep will allow you to easily find aliases for whatever command you're currently typing.

If you're not creative with aliases, then install some! You can find some great aliases on the web, and if you're using zsh with per example oh my zsh or the excellent zplug then you can install plugins which will come with loads of aliases ready to use so I'd recommend to start there.

History

Another thing I see very little people use is your history. Did you know you can lookup any command you've typed and just redo that command? Does that seem like magic, because it is and you should absolutely know about it. To start using it it's very simple, press Ctrl + r in your terminal, start typing your command, and press Enter! That's it, this one simple trick will save you hours and hours of typing commands, doctors hate me.

Now whenever you need to type something, and I mean absolutely anything that is more than 5 characters, I want you hitting that History like a drumkit. Checking out a branch? You've probably already checked it out in the past. Running some scripts? Probably already done it at least once too. Whatever you're typing, you've probably already typed it because we type dozens of the same commands again and again every day so no more. Stop losing time typing the same things, a quick ctrl R, type three letters, enter and bam. You're not a code monkey, this isn't where your value is, so stop losing so much time on typing commands.

If you feel the default UX of ctrl R is average, then you can install fzf which is an amazing tool bringing fuzzy search to most autocompletions which will allow you to lookup commands by any string of characters in them and even more advanced stuff.

Directories and moving around

Another huge source of friction, is moving around on your computer. Here again there are some great tricks to put into practice. But the best tip I can give you is to install z and call it a day. It's a terminal tool that will remember every folder you've been in and allow you to do per example z foo and immediately go to the most visited folder containing "foo" in its path. It's dead simple but with it you'll never have to type a path again, just z projectA or z Sites or z myUsers etc. As long as you've been in that folder once, it'll find it.

Besides that the best trick is to create some great aliases to move around like the ones that come with Oh My Zsh (eg alias ....=cd ../../../../ etc). I also see a lot of people not knowing about cd - which lets you go back to the directory you were in before the current one, which is very very useful if you want do one quick action in another folder and go back (and it also works for Git branches!). There is also a great plugin called jump, again in Oh My Zsh, which lets you manually bookmark folders and go back to them.

Git

Finally I've mentioned before that most people know very little Git commands. This isn't to say this is a bad thing, more a reflection of the fact that you can accomplish so much with so few commands. You can have been in the industry for years and still get by just with checkout , commit and push. So there again, use aliases, please don't type git checkout my-super-long-branch ten times a day, even if you use Tab to autocomplete it.

If your project uses Git flow, don't hesitate to install aliases for this and the great gitflow-avh binary which will turn long commands you type a lot like these:

git flow feature start my-feature

Into the much more condensed gflfs my-feature. That alias may seem cryptic but it's purely initials (Git Flow Feature Start) so once you know one alias you know them all.

Editorments

The terminal is of course only half the story, most of the time your work is done in an editor, or IDE. Most of those tools have one goal and one goal only: make you as productive as you can be when writing code. Yet very often, like for Git, people stop once they reach "minimal productivity" and never really bother to check all the features their editor or IDE have.

The first thing people ignore, and it's very akin to aliases, is keyboard shortcuts. It's something people aren't curious about, they learn four or five and spend years using just those, never bothering to learn shortcuts for actions they do ten times a day (run a test, gotos, refactors). So my #1 advice is to take 10 minutes to learn one or two shortcuts from time to time, and your future self will thank you. It'll feel hard at first, because it's all pure memorization but I guarantee you someone who truly utilizes their editor and their shortcuts can be almost as fast as someone going full speed in Vim.

Extensions are another great places to look, most editors and IDEs have extensions that provide code templates, snippets, things you can "expand" into boilerplate code per example for React components or PHP classes and such. Also use autocompletion as much as you can, good editors will automatically import classes/modules and such when autocompleting them. How many times have you typed import React from "react" in the past week? If your answer is any number above one, I recommend you take a look at those. Emmet is another great multi-platform extension with a big load of snippets ready to use, and it works even in JSX and such to allow you to easily wrap elements, generate huge chunks of HTML etc.

IDEs tend to be more feature-full than editors, so look into special productivity features in those as well. The whole IntellijIDEA suite per example (so all the products in it, PHPStorm, Webstorm, PyCharm etc) has a very helpful Help → Productivity Guide listing all the tools the IDE gives you, how many times you've used them or not, and what they're for so definitely check what your editor can do for you because chances are you're severely underutilizing it.

AnfGOi5

Finally one last tip that has saved me countless hours in various situations: learn to use multiple cursors! They're an incredible way to repeatedly write multiple lines of code that only diverge slightly. Imagine you have a value objects with various setters, instead of writing the code to set the values manually, use multiple cursors. Place one cursor at each setter method, copy it, and paste the multiple lines somewhere else where you can write them all in one go, no matter whether your VO has 5, 10 or 50 setters. This is one of the features I use the most every day and once you start using it you'll start seeing how often you need to write multiple lines in a redundant way.

Code Speed: You!

Finally, once you've tamed your tools a bit better and have achieved greater "idea to implementation" speed, don't forget to look at friction in and around your code. This can be a lot of things.

Code Formatters

The first one I want to talk about and one I'm very passionate about, is to use code formatters. If you ever commented "The indentation looks wrong here" or "There's an extra comma on this line" on a pull request, you are absolutely wasting hours a year doing menial work that tools can now do better than you.

I'm not going to dive too much into which formatters as every language has their own top dogs, but I will absolutely recommend Prettier for just about every language, even PHP (but with CS fixer on top or something). My point is: if your tool only warns you about incorrect code style, you're not using it right. Use tools that can reformat the code for you, and FORGET IT for real. Stop worrying about code style, use one code style, for everything, and LET IT GO. This is legitimately a very deep sink that has caused billions of lines of angry ranting to be written, so let it go once and for all and you will quickly see how much time in your day you spent mindlessly moving bits of code neatly around.

Documentation

Another huge time sink when working on an issue, is looking things up, Googling, wandering around the internet. So instead find a good place that has all the documentations centralized (like Dash on mac or DevDocs online) and use that. Stop googling the attributes of input for the 50th time, instead with these tools you can quickly press a shortcut to bring them up, type like html:input and have the docs ready to go, offline or online, just a few keypresses away.

dash s2

It's absolutely normal to still look stuff up all the time, because some things aren't necessarily worth remembering if they can be checked any time (like HTTP status codes). But you shouldn't have to go find the page again every time, save yourself some time instead and bring the documentation to you. There's even great integrations for these tools into a lot of editors, IDEs and even Alfred/Spotlight.

Generally speaking, if you're alt tabbing between a couple of the same applications all the time, try to think about how you can centralize them. Per example use your editor/IDE's terminal instead of your own, use Spotlight/Alfred to alt tabs application faster, etc. The less you have to run around like a headless chicken between a couple of applications, the more you'll have time and mental energy to dedicate to the current one without losing track of your thoughts. If you've ever alt tabbed to the wrong application 4/5 times before succeeding, when you could have just popped up Spotlight, typed two letters and enter, this is for you.

Context Switching

Finally, but this is something that requires much more work: make it easy to quickly ship out a feature. Setup CIs on your pull request, have lots of tests, have even more tests, use hub to create pull requests from the terminal. The goal is that you can pick up a feature, just do it© and send it off without having to worry while you move on to the next issue. CI will run, and do its thing, people will review, but the more you reduce the time before/after working on a feature, the more you make it easy to chain multiple issues without a hitch and easily context switch between one and the other, while someone else (CI) checks it for you.

If you're working on multiple projects, again use aliases, use tools like captain to quickly up/down containers. I even personally setup projects related aliases to more easily go from one to the other:

alias work_project="up the containers && start my editor && open the board in the browser"

Think really hard about your work day, and think about anything you're doing multiple times needlessly, and if it can be an alias or a shortcut, make it one. Basically: you need to minimize the time it takes you to be functional on any given issue, and the rest will come easily.

Conclusion

We've covered a lot of ground in this article but most of it can be summarized easily in: if you're doing the same things all the time, don't do the same things all the time. We spend countless hours as developers identifying patterns and abstracting them away. So apply that expertise to yourself; consider yourself a codebase in serious need of DRY-ness, and take action accordingly.

What I listed here of course only scratches the surface, I'm by no means the fastest programmer in the world but I pay attention to it and I do believe it makes me faster than I was some years ago. And it took very little effort to progress, so if you're looking for good ways to have more productive days, look into it a bit. Try to see if you can ease your own load, and you'll only have yourself to thank for it in the end.


Cover photo by Marc Sendra Martorell on Unsplash

© 2020 - Emma Fabre - About

Autopergamene

Gotta Go Fast

Back

Gotta Go Fast

Published a year ago
13mn to read

It's safe to say programming, and everything around it, evolved tremendously since the Internet's beginnings. If you've ever created a Frontpage website or battled with Dreamweaver and Flash applications you know we've traveled a long way to get where we are now, and all along this way great strides were made to improve how we work. We got better languages, better tools around them, better integration and interoperability. We tried to standardise things, rethink how we worked, all in the spirit of making it easier and easier to implement ideas.

And yet, yet things also didn't change all that much did they? When you look at what constitutes a day of work, for a lot of programmers it still amounts to looking at lines of code on a plain background, looking at a terminal window, typing the same commands again and again. Why did that not improve as drastically as everything else? Or did it and have we just all grown so accustomed to learning just enough to be functional that we've forgotten to seek improvement? How many people use Git daily and know at best three or four commands?

Being a fast programmer isn't all about architecture and reasoning and solving problems. While it accounts for a good chunk of it, once you remove the "coding" part from "coding" what makes a programmer faster than another? The answer is the ability to reduce friction – everyday micro-slowdowns that happen in and around every task and that we've all (maybe) let fester into our workflows.

So what can you do to get faster and remove these slowdowns? Let's review some great starting points to help you be a more productive self.

Hocus Focus

The first thing we need to eliminate, is distraction. Imagine you have an issue to work on, you know precisely how you're going to implement it, all that is left is the dirty work. The first thing you should try, is to get some additional focus. The internet is the Great Bastion of distraction, its only purpose is to grab your attention and hog parts of your brain capacity. So a great first step is to kill everything else but the task at hand: quit Slack, quit your email, put your phone into silent, maybe put some nice ambient music.

By removing external distractions around you, you allow your brain to focus entirely on the task at hand instead of letting it "multipurpose" and think about notifications and other tasks etc. And it will make it that much easier to "get in the zone" and achieve great strides in productivity. Think about all the time spent alt-tabbing to check a notification that you didn't even need to care about in the first place, think about all the brain time occupied at thinking on multiple levels, this is the first chunk of slowdown you need to eliminate. So first step: create some head space around you to comfortably work in. If you're working from home, try working from a different scenery, as long as it also helps reduce the amount of distractions.

A great way to have "Focus Time" quickly is to create an Automator quick action workflow that quits all annoying applications:

1jVwqoM

Then from any application you can go to The App → Services → Your Quick Action and it'll get you started.

Once you're used to focusing regularly, you need to remember that with great focus comes great responsibility, and another aspect people often overlook is to take small regular breaks. Those help "clean your palate" between two tasks and prepare your mind to focus more intensively. You cannot have one without the other, if you want to dedicate yourself to one task, you also need to learn to let go of others.

Terminal Velocity

Once you've achieved some calm, let's first look at the terminal. The terminal should be every programmer's best friend, and if you've always put off learning to use it you're definitely preventing yourself from reaching full speed (even though there's some amazing GUI tools out there).

Aliases

The most important thing you need to learn is to create and use aliases. For this you need to think about all the commands you type in the day and think of which ones you're tired of typing. The key is to realize an alias doesn't have to be a full command, an alias can be partial, per example alias gco=git checkout and then gco my-branch.

You can put all your aliases in any file loaded on login (.zshrc, .bash_profile, etc.), don't be afraid to create a lot of them even if you don't memorize them. You can at any time look for a particular alias by doing alias | grep checkout. Calling alias alone will list all registered alias, and grep will allow you to easily find aliases for whatever command you're currently typing.

If you're not creative with aliases, then install some! You can find some great aliases on the web, and if you're using zsh with per example oh my zsh or the excellent zplug then you can install plugins which will come with loads of aliases ready to use so I'd recommend to start there.

History

Another thing I see very little people use is your history. Did you know you can lookup any command you've typed and just redo that command? Does that seem like magic, because it is and you should absolutely know about it. To start using it it's very simple, press Ctrl + r in your terminal, start typing your command, and press Enter! That's it, this one simple trick will save you hours and hours of typing commands, doctors hate me.

Now whenever you need to type something, and I mean absolutely anything that is more than 5 characters, I want you hitting that History like a drumkit. Checking out a branch? You've probably already checked it out in the past. Running some scripts? Probably already done it at least once too. Whatever you're typing, you've probably already typed it because we type dozens of the same commands again and again every day so no more. Stop losing time typing the same things, a quick ctrl R, type three letters, enter and bam. You're not a code monkey, this isn't where your value is, so stop losing so much time on typing commands.

If you feel the default UX of ctrl R is average, then you can install fzf which is an amazing tool bringing fuzzy search to most autocompletions which will allow you to lookup commands by any string of characters in them and even more advanced stuff.

Directories and moving around

Another huge source of friction, is moving around on your computer. Here again there are some great tricks to put into practice. But the best tip I can give you is to install z and call it a day. It's a terminal tool that will remember every folder you've been in and allow you to do per example z foo and immediately go to the most visited folder containing "foo" in its path. It's dead simple but with it you'll never have to type a path again, just z projectA or z Sites or z myUsers etc. As long as you've been in that folder once, it'll find it.

Besides that the best trick is to create some great aliases to move around like the ones that come with Oh My Zsh (eg alias ....=cd ../../../../ etc). I also see a lot of people not knowing about cd - which lets you go back to the directory you were in before the current one, which is very very useful if you want do one quick action in another folder and go back (and it also works for Git branches!). There is also a great plugin called jump, again in Oh My Zsh, which lets you manually bookmark folders and go back to them.

Git

Finally I've mentioned before that most people know very little Git commands. This isn't to say this is a bad thing, more a reflection of the fact that you can accomplish so much with so few commands. You can have been in the industry for years and still get by just with checkout , commit and push. So there again, use aliases, please don't type git checkout my-super-long-branch ten times a day, even if you use Tab to autocomplete it.

If your project uses Git flow, don't hesitate to install aliases for this and the great gitflow-avh binary which will turn long commands you type a lot like these:

git flow feature start my-feature

Into the much more condensed gflfs my-feature. That alias may seem cryptic but it's purely initials (Git Flow Feature Start) so once you know one alias you know them all.

Editorments

The terminal is of course only half the story, most of the time your work is done in an editor, or IDE. Most of those tools have one goal and one goal only: make you as productive as you can be when writing code. Yet very often, like for Git, people stop once they reach "minimal productivity" and never really bother to check all the features their editor or IDE have.

The first thing people ignore, and it's very akin to aliases, is keyboard shortcuts. It's something people aren't curious about, they learn four or five and spend years using just those, never bothering to learn shortcuts for actions they do ten times a day (run a test, gotos, refactors). So my #1 advice is to take 10 minutes to learn one or two shortcuts from time to time, and your future self will thank you. It'll feel hard at first, because it's all pure memorization but I guarantee you someone who truly utilizes their editor and their shortcuts can be almost as fast as someone going full speed in Vim.

Extensions are another great places to look, most editors and IDEs have extensions that provide code templates, snippets, things you can "expand" into boilerplate code per example for React components or PHP classes and such. Also use autocompletion as much as you can, good editors will automatically import classes/modules and such when autocompleting them. How many times have you typed import React from "react" in the past week? If your answer is any number above one, I recommend you take a look at those. Emmet is another great multi-platform extension with a big load of snippets ready to use, and it works even in JSX and such to allow you to easily wrap elements, generate huge chunks of HTML etc.

IDEs tend to be more feature-full than editors, so look into special productivity features in those as well. The whole IntellijIDEA suite per example (so all the products in it, PHPStorm, Webstorm, PyCharm etc) has a very helpful Help → Productivity Guide listing all the tools the IDE gives you, how many times you've used them or not, and what they're for so definitely check what your editor can do for you because chances are you're severely underutilizing it.

AnfGOi5

Finally one last tip that has saved me countless hours in various situations: learn to use multiple cursors! They're an incredible way to repeatedly write multiple lines of code that only diverge slightly. Imagine you have a value objects with various setters, instead of writing the code to set the values manually, use multiple cursors. Place one cursor at each setter method, copy it, and paste the multiple lines somewhere else where you can write them all in one go, no matter whether your VO has 5, 10 or 50 setters. This is one of the features I use the most every day and once you start using it you'll start seeing how often you need to write multiple lines in a redundant way.

Code Speed: You!

Finally, once you've tamed your tools a bit better and have achieved greater "idea to implementation" speed, don't forget to look at friction in and around your code. This can be a lot of things.

Code Formatters

The first one I want to talk about and one I'm very passionate about, is to use code formatters. If you ever commented "The indentation looks wrong here" or "There's an extra comma on this line" on a pull request, you are absolutely wasting hours a year doing menial work that tools can now do better than you.

I'm not going to dive too much into which formatters as every language has their own top dogs, but I will absolutely recommend Prettier for just about every language, even PHP (but with CS fixer on top or something). My point is: if your tool only warns you about incorrect code style, you're not using it right. Use tools that can reformat the code for you, and FORGET IT for real. Stop worrying about code style, use one code style, for everything, and LET IT GO. This is legitimately a very deep sink that has caused billions of lines of angry ranting to be written, so let it go once and for all and you will quickly see how much time in your day you spent mindlessly moving bits of code neatly around.

Documentation

Another huge time sink when working on an issue, is looking things up, Googling, wandering around the internet. So instead find a good place that has all the documentations centralized (like Dash on mac or DevDocs online) and use that. Stop googling the attributes of input for the 50th time, instead with these tools you can quickly press a shortcut to bring them up, type like html:input and have the docs ready to go, offline or online, just a few keypresses away.

dash s2

It's absolutely normal to still look stuff up all the time, because some things aren't necessarily worth remembering if they can be checked any time (like HTTP status codes). But you shouldn't have to go find the page again every time, save yourself some time instead and bring the documentation to you. There's even great integrations for these tools into a lot of editors, IDEs and even Alfred/Spotlight.

Generally speaking, if you're alt tabbing between a couple of the same applications all the time, try to think about how you can centralize them. Per example use your editor/IDE's terminal instead of your own, use Spotlight/Alfred to alt tabs application faster, etc. The less you have to run around like a headless chicken between a couple of applications, the more you'll have time and mental energy to dedicate to the current one without losing track of your thoughts. If you've ever alt tabbed to the wrong application 4/5 times before succeeding, when you could have just popped up Spotlight, typed two letters and enter, this is for you.

Context Switching

Finally, but this is something that requires much more work: make it easy to quickly ship out a feature. Setup CIs on your pull request, have lots of tests, have even more tests, use hub to create pull requests from the terminal. The goal is that you can pick up a feature, just do it© and send it off without having to worry while you move on to the next issue. CI will run, and do its thing, people will review, but the more you reduce the time before/after working on a feature, the more you make it easy to chain multiple issues without a hitch and easily context switch between one and the other, while someone else (CI) checks it for you.

If you're working on multiple projects, again use aliases, use tools like captain to quickly up/down containers. I even personally setup projects related aliases to more easily go from one to the other:

alias work_project="up the containers && start my editor && open the board in the browser"

Think really hard about your work day, and think about anything you're doing multiple times needlessly, and if it can be an alias or a shortcut, make it one. Basically: you need to minimize the time it takes you to be functional on any given issue, and the rest will come easily.

Conclusion

We've covered a lot of ground in this article but most of it can be summarized easily in: if you're doing the same things all the time, don't do the same things all the time. We spend countless hours as developers identifying patterns and abstracting them away. So apply that expertise to yourself; consider yourself a codebase in serious need of DRY-ness, and take action accordingly.

What I listed here of course only scratches the surface, I'm by no means the fastest programmer in the world but I pay attention to it and I do believe it makes me faster than I was some years ago. And it took very little effort to progress, so if you're looking for good ways to have more productive days, look into it a bit. Try to see if you can ease your own load, and you'll only have yourself to thank for it in the end.


Cover photo by Marc Sendra Martorell on Unsplash

© 2020 - Emma Fabre - About