DEV Community

Discussion on: How do you format curly braces? {}

Collapse
 
sfiquet profile image
Sylvie Fiquet

Option A comes from the C tradition, that's what you find in the K&R.

I think option B came about with JavaScript. JS interpreters tend to automatically add a semi-colon at the end of each line unless there is a clear sign that it shouldn't (like an open brace signalling the start of a code block). Hence the new format. I'm not sure if that reason is still relevant today but by now it's standard in the JS world.

As for me I started with C/C++ and option A. After a long career break, I took up JavaScript and Node.js and switched to option B. It was weird at first but now it's second nature.

At the end of the day, what matters is that the team agrees on a common format. Or uses tools that automate formatting.