Swizec Teller - a geek with a hatswizec.com

Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

Senior Engineer Mindset cover
Learn more

    Simple trick that lets you code twice as fast

    Basic idea from THE Bret Victor talk

    Immediate feedback.

    No really, it's that simple.

    Most of our a developer's revolves around verifying code. After hitting the limit of how fast you can type, the only way to think faster is getting feedback instantly.

    There's actually two parts to this trick.

    1. Automated testing

    First of all, you should write tests. No need for full on TDD writing tests before writing code, just have tests, any tests. Because eventually you will want to know if this thing you've just coded works.

    Your first test is: does it run?

    Mocha automated automated testing

    The next test is: does it do what it's supposed to?

    Without an automated test suite this one is tricky. It takes ages. _Decades _compared to how easy it was to write. At worst, you have to check your whole program after every change. Good design alleviates a lot of this burden due to isolation, but still ... effort.

    I still remember when every change meant some 20 minutes of clicking around to check if things worked. And I only remembered to click around the thing I just changed, never you mind any ripple effects in the codebase.

    Horror.

    Automated testing reduces those 20 minutes to, say, 30 seconds.

    Your life becomes:

    1. Write some code
    2. Hop into a console of some sort
    3. Possibly compile things
    4. Run the test suite
    5. Wait while it runs
    6. Give in to the urge to quickly check twitterredditfacebooksomething
    7. Go back to coding long after the tests finished

    Great, it's just taken a minute (not counting twitterredditfacebooksomething time) to find out if something works. I do this every ~5 minutes, that means a waste of 10 minutes per every hour worked.

    2. Automated automated testing

    One hour and twenty minutes every full workday.

    Man, that's some non-negligible time right there!

    Then again, I've got an automated test suite, why am I running it manually? Wouldn't it be better if something ran the test suite every time I hit Ctrl+S?

    And that's exactly how it's supposed to be!

    Let automated testing run automatically and just glance at the results every so often. You won't break concentration, you won't be tempted to check twitter while the tests run, you won't have to get out of your text editor.

    Win-win-win.

    Right now I use two tools to do this (and am looking for more)

    Mocha's got a wonderful -w option for running node.js tests - it watches files for changes and reruns the suite every time you save. And Mocha is just generally wonderful, but that's a different post.

    For frontend development, I'm using _Live CSS Mod - _a Chrome extension, which refreshes a page every couple of seconds. But it's smart enough to do this in the background and only show the changes if there's anything different. This means you don't lose state all the time because that would be annoying.

    Now all I need are these sorts of tools for the other stacks I'm using. (Django/python and Haskell).

    Published on October 8th, 2012 in Automation, Programming, Quality assurance, Test automation, Test suite, Uncategorized

    Did you enjoy this article?

    Continue reading about Simple trick that lets you code twice as fast

    Semantically similar articles hand-picked by GPT-4

    Senior Mindset Book

    Get promoted, earn a bigger salary, work for top companies

    Learn more

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️