Holy wars…over standardized code formatting

Michael Corrieri
3 min readApr 20, 2021

I think we can all agree that when we first learn programming, whether it be Ruby, JavaScript, Python, or Malbolge it can seem impossibly hard. New words, concepts, programs, and syntax can turn our brains into soup and make us question if the words we are typing are even words at all. It seems like a lot, and it absolutely is. However, people smarter than us have already been there done that, and like any good programmer would, created shortcuts and programs that make our lives easier.

As a brand new programmer I was getting tripped up and wasting an enormous amount of time reading through my failing code to add a missing parentheses here or a semi-colon there. Finally, after complaining for what was probably hours, my roommate (who just so happens to be a web developer) said hey man, why don’t you try getting Prettier. I told him I had been trying for years and I’m not sure how that would help with my code.

Prettier is a code formatter that allows you to automatically format your code when you save. It also supports a multitude of languages including JavaScript, CSS, HTML, and more. With the click of a couple buttons (⌘S for Mac) Prettier can turn your ugly, boring code (which may or may not have been written in under 2 minutes for this example) from this:

To this…

So the benefits are boundless right? Prettier can add little things here and there to make sure our code is correct and it can also format that code to make it much easier and dare I say…prettier to read. However, I have noticed that not everyone uses code formatters. And that brings us to the main discussion and thought to take away from this blog. Should the use of code formatters be standardized?

Pros for enforcing the same code format:

  • Similar code is easier to read
  • Makes it faster to spot errors
  • Meaningful changes only
  • Simpler merges

Cons:

  • Can be annoying to clear up small errors thrown by the formatter
  • No standards = any code goes “sloppy code is a pain in the ass to read”
  • Some programmers do not want to be told how to write code

Kind of like choosing to use only one tool for a job, this idea of standardized code comes with both many benefits and some issues. I will assume that most experienced developers already know about various code formatters, but for those who are new to programming they can be an extremely useful tool. Even if you don’t choose to use one.

--

--

Michael Corrieri

Software Engineering student at Flatiron School. Environmental & Occupational Health Sciences MPH. Based in Brooklyn, NY