What news from AWS re:Invent last week will have the most impact on you?
Amazon Q, an AI chatbot for explaining how AWS works.
Super-fast S3 Express storage.
New Graviton 4 processor instances.
Emily Freeman leaving AWS.
I don't use AWS, so none of this will affect me.
Software Development

Source{d} Can Help Solve Your Own Tabs-Versus-Spaces Debate

Mar 7th, 2019 3:00pm by
Featued image for: Source{d} Can Help Solve Your Own Tabs-Versus-Spaces Debate

The debate over tabs versus spaces has been going on for decades and, despite all attempts to end it, it is ongoing. StackOverflow co-founder Jeff Atwood once wrote of the debate, “It doesn’t actually matter which coding styles you pick. What does matter is that you, and everyone else on your team, sticks with those conventions and uses them consistently.”

And to that end, among others, source{d} offers machine learning and analysis to ensure a consistent coding style adapting to various codebases. In other words, source{d} can solve this debate for you, not by asking those in charge and enforcing the style from the top down, but rather by analyzing your existing code base, extrapolating in-practice norms, and enforcing them across your entire code base. If you’ve ever attempted to enforce a uniform style using a style guide, you may be familiar with the feeling of futility that comes along with it, but it’s easier, says source{d} Vice President of Product Francesc Campoy, when a machine can do it for you.

“Companies try to enforce style with style guides. It’s a waste of time to have humans enforce these things,” said Campoy. “We understand your source code and that you want consistency. We extract rules from the source code you’re writing and apply them to new contributions. Rather than enforcing specific guidelines — it’s too late to apply retroactively — what we’re enforcing is consistency.”

Earlier this year, the company released its machine learning assisted code review with the source{d} Lookout analyzer, which “understands that each codebase has its own nuances and learns to model the codebase style as precisely as possible, as opposed to relying on global style practices,” according to a company statement.

Campoy explains that Lookout goes beyond style, however, to not only make it easier to read and focus on the code itself, but also to make sure the code is as efficient as possible.

“If you have a common way of writing code when people read it, they’re not paying attention to how it looks, so instead they pay attention to more valuable things — what the code is doing, whether or not there are mistakes,” said Campoy. “Copy/pasting code is not a great technique and we’re able to detect that kind of thing. We use fuzzy logic to determine the similarity between code, and then we can comment that the code looks similar and suggest using a function instead.”

Source{d} employs GitHub Suggested Changes to make committing code changes as easy as possible and offers a demo repository on GitHub to demonstrate this functionality. Currently, the style analyzer only works for JavaScript, but Campoy says he expects Python or Java support to come next.

In the end, Campoy, who used to work on the Go team at Google, points to gofmt — the industry standard formatting tool for Go developers — as a case in point, noting that “the important fact of the gofmt is not how it formats, but the fact that there’s one tool that everyone agrees with.”

Feature image via Pixabay.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.