What Are Linters and Why You Should Use Them

Arvin Fernandez
3 min readJun 23, 2021

--

The first time I heard about linters I was watching a recorded zoom event about how to break into the tech industry as a bootcamp grad. I remember the speaker, a technical recruiter, mentioning that as a way to reduce the high number of applicants he wrote a script that downloaded code from the applicant’s GitHub and ran it through a linter.

Im not sure how many companies actually use this strategy but I am not gonna take any chances. I immediately did some googling and was impressed at the benefits that linters had on your code. If I can do anything to improve my chances of landing my first tech job best believe I will do it especially if it requires little to no effort on my part.

What is a Linter?

According to Wikipedia, linter

‘…is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.’

A static code analysis tool is a kind of tool that you can use against your software without actually running the code, basically your source code. Similar to those red squiggly underlines when you forget to close off a parentheses.

The term originated from a tool called ‘lint’ that analyzed C source code created by Stephen C. Johnson in 1978. Since then linters have improved. Checking for more errors and expanding to all languages. Regardless of your programming experience I can guarantee that you will began to utilize linters once you see the benefits they can provide.

Fix Programming Errors

In compiled languages errors can be caught during compile time making the need for a linter less immediate. Compilers are programs that convert the code into machine executable instructions for the computer to perform.

In interpreted languages , however, since there are no compilers it can be harder to find the source of programming errors. This is where a linter can help developers fix their code before execution.

Some compilers have the capability to detect possible bugs before execution but most don’t. This is where a linter may benefit by identifying and warning you about possible bugs in your code. Regardless of your language being compiled or interpreted.

Bugs suck. They also slow down your productivity and performance, which leads us to the next benefit.

Performance Improvements

We all know the importance of having performant software but not many of us beginners know how to improve it. And even a senior programmer might miss a technique or two on to improve their code’s performance.

So why not let an automated tool do it for us instead? We are programmers and we are lazy so any task we can automate we will automate. Luckily for us most linters offer performance recommendations and rules that we can apply to our code.

Code Standardization

Standardizing your code is a great way to improve productivity. As less time is spent figuring whether to use tabs or spaces, or placing a line break after a certain number of characters.

Having a consistent style throughout your code base improves readability and reduces the cognitive load of reading and maintaining code. This extra time can be used to focus about on more important issues such as possible bugs, edge cases, and security issues.

Increased Security

Security is a crucial topic in software. While there are specific static code analysis tools that can help improve security, and probably would be best to use these if security is your main focus, linters may also help to improve the security of your code.

Working the same way as they do for other errors. The linter scans the file flagging errors and warning about potential security vulnerabilities. Then you decide whether or not to make changes recommended.

Conclusion

Linters improve code readability, remove error before execution, helps with code standardization and security. Therefore making your code easier to understand, maintain, and evolve. So why wouldn’t you use something that could potentially make you more productive, efficient, and might even be the the deciding factor between whether or not you get an interview with your dream company?

--

--

Arvin Fernandez
Arvin Fernandez

Written by Arvin Fernandez

Junior Developer trying to help other developers(and myself) better understand programming.

Responses (3)