Your safety is important! Find all the details of our response to COVID-19 ❯

How to write faster code

Want to roll out your beautiful code faster? Here are five easy, practical tricks that will instantly boost your programming speed.
istock.com/tiero
Andrea Tallarita
Andrea Tallarita

If any of us lived forever, we could always write code refined to perfection. Unfortunately the constraints of time and mortality – and less metaphysically those of our employers – mean that those of us wishing to learn how to code must also learn how to code relatively quickly.

Coding fast is a wholly other skill than coding well. In fact, it is arguably less a skill in its own right than the aggregate of an entire constellation of apparently minor skills. It is important and complex enough a topic that we intend to dedicate two articles to it: the first will explore practical methods to code faster and more efficiently, while the next will consider broader questions of attitude and approach.

To start us off, this is the article devoted to the practical side of coding quicker – strictly without compromising quality, of course. If you want to complement this with a theoretical approach, then part two is right here as soon as you’re done with this one!

#1. Know your editor

Many programmers only learn the basic functionality of code editors like Visual Studio Code, PhpStorm, or Pycharm, perhaps because they feel that studying them in greater depth would steal time from whatever coding project they’re working on. Don’t fall for that trap! You may think that learning keyboard shortcuts, or how to quickly find and open files, will only gain a second or two for every paragraph of code you write – but once you’re doing that instinctively, it can shave off up to 10% of the time you spend in front of the monitor.

Set aside one day and dedicate it entirely to learning and exercising yourself in the more advanced functions of your editor, particularly if you are assigned a project that requires you to switch to a new one. It’s one of the most direct and universally efficient ways to speed up the coding process.

#2. Do copy, don’t paste.

As most professional developers will tell you, copying code that works is not ‘cheating’ – it’s sparing yourself the futility of reinventing the wheel. Thus, we wholeheartedly recommend using Google to look for solutions to programming problems which have been made publicly available, particularly if your aim is to code more quickly. That said, here’s a helpful little trick not many have tried out: don’t paste the above-mentioned solutions into your code, but take the time to manually type them out yourself.

You may think this will rather slow you down – and for the first few weeks, granted, it probably will. But it will also brand the solutions you’re copying into your brain and automate them into your fingertips. Also, and crucially, you will gain a more intimate conceptual understanding of what you’re working with. Eventually you’ll find yourself writing these solutions without copying them from anywhere, possibly without even thinking about them, and you’ll be whooshing through code that would have previously taken multiple stops and starts.

#3. Unit tests

It’s actually surprising how many excellent developers have never been taught the value of unit tests. If you’re unfamiliar with the term, these simply consist in testing small or smaller units of code by themselves, as distinct from integrated tests, which run a program (or a large part of a program) in its entirety.

Running regular unit tests doesn’t mean that your code will be free of bugs, but it does mean that you will find them in a fraction of the time it would take you to reexamine your entire code. Resist the illusion of speed you get from blazing through your entire project in one go, particularly if you’re relatively inexperienced. Instead, keep your units of code short and test each of them methodically. It may feel slower while you’re doing it, but in reality you are preemptively sweeping aside what could be hours of work.

#4. Mnemonics

We all retain and process memories differently, meaning that different learning methods will work best for different people. That said, not many are aware of some of the simple tricks you can use to train your memory and make sure you retain information for long stretches of time.

This is important for programmers because methodically committing to memory ways to cut down loops or to more efficiently exploit dataframes is perhaps the most powerful cognitive exercise to become a faster coder, albeit not the easiest to master. Practice mnemonic methods, and then use them whenever you come across a clever few lines of somebody else’s code (you can find a ton on Kaggle, if you’re not sure where to start). Naturally, you should also make sure you are using what you’ve memorized in your own projects, further ingraining it in your mind. This can take some effort to pull off, but done consistently, it’ll likely push you forward and permanently speed you up more than any other tip on this list.

#5. Start with what you know

You always want to make sure you have a plan before you start a project, but once you do start, go for the easy bits first. Many of us have an instinct to ‘get the hard bit out of the way’ when working, and while this is helpful in many fields, it can actually be counter-productive in programming.

If there is a part of your project that you already understand very well, start there. Write whatever code is the least troublesome first, especially for the projects that are most complicated and ambitious. The reason we give this advice is that problems in programming are frequently sequential – solving the first part makes it easier to solve the next, which makes it easier to solve the next, and so on. Naturally, this isn’t just going to magically solve all of the remaining intellectual or creative challenges, but at the very least it should get you thinking in the right direction. And sometimes that can make all the difference in the world.

(To make sure you’re making the most of coding, check out also our coding lifestyle tips!)

Share this article

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on whatsapp

Related articles

You are your best investment.

Need more information?

We're Here
To Assist You

Get in touch with us, and we will be more than happy to answer all of your questions.

*This field is required.

Get your curriculum

*This field is required.
Thank you very much for your inquiry.

We will get back to you as soon as possible.

Your WBS CODING SCHOOL Team

Thank you for your request.

Please download the curriculum here (PDF, 1.4 MB).

Your WBS CODING SCHOOL Team