Propose to use clang-format to enforce hotspot codestyle

Andrew Haley aph at redhat.com
Thu Mar 12 09:55:39 UTC 2020


On 3/12/20 9:30 AM, Liu, Xin wrote:
> For Andrew’s concerns, I think I got answers.

> Sometimes, hand-craft code is better indeed.  Clang-format provides
> a directive which can temporarily turn it off.

That's not really adequate. The programmer has a choice to format
their code in an informative of slightly nonstandard way, but only if
they clutter up the source with /* clang-format off */ markers. So
most of the time they won't do it, and something will have been lost.

Code layout adds information for the reader. That's why today we
mostly use free-format languages. Back in ancient times ( :-) it
wasn't like that, but people learned that a program is a text, to be
read by people not just computers, and layout can help with that.

Of course HotSpot's guidelines are important to ensure a consistent
style across many patches written by many different authors. I'm not
saying otherwise: without consistent layout it'd be harder for people
across many organizations to work together. But applying a fixed set
of rules regardless of context is too naive an approach.

Don't misunderstand me, I like auto-formatters. I use one all the
time, and my patches follow the guidelines. But occasionally any
auto-formatter gets it wrong and then I have to fix things up by hand.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the hotspot-dev mailing list