Live data from Hacker News

Ask HN: Examples of Unusual Code Formatting Styles?

news.ycombinator.com

11–20 of 22 posts

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#11
post #7

I find the Horstmann indentation style [1], in which code is placed on the same line as the opening bracket, simultaneously disturbing and compelling. If it ever ends up added to clang-format as has been requested [2], it might become more popular. [1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263

I like it too. It makes C code actually look readable. It would be interesting to see it applied to Lisp code.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#12
post #7

I find the Horstmann indentation style [1], in which code is placed on the same line as the opening bracket, simultaneously disturbing and compelling. If it ever ends up added to clang-format as has been requested [2], it might become more popular. [1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263

This is actually very sensible. I don't like the top bracket being its own line, but there's good reason for it to align with the bottom bracket.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#14
post #5

I've seen this in the wild and have been meaning to ask: With the availabily of syntax highlighting including color, has anyone seen merit in skipping indentation altogether? For that matter, what if block color or font size took the place of indentation (under control of syntax highlighting). I'll have to try it by hand.

Code has evolved towards smaller indentation: 2 spaces instead of 4. We might see 1.

However, we have more async stuff than ever before. Heavy nesting is frequent.

And then you have the weird new imperative UI stuff like Flutter/Jetpack Compose where a simple layout is brackets in brackets in brackets in brackets.

Rainbow brackets are a thing though - one of the most popular plugins in many IDEs is something that highlights different colour brackets.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#16
post #12
post #7

I find the Horstmann indentation style [1], in which code is placed on the same line as the opening bracket, simultaneously disturbing and compelling. If it ever ends up added to clang-format as has been requested [2], it might become more popular. [1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263

This is actually very sensible. I don't like the top bracket being its own line, but there's good reason for it to align with the bottom bracket.

Java style formatting removes the "bracket on its own line" problem, so I'm not sure how this new indentation style adds anything of value really.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#17
post #7

I find the Horstmann indentation style [1], in which code is placed on the same line as the opening bracket, simultaneously disturbing and compelling. If it ever ends up added to clang-format as has been requested [2], it might become more popular. [1] https://en.wikipedia.org/wiki/Indentation_style#Horstmann_st... [2] https://bugs.llvm.org/show_bug.cgi?id=27263

It is fascinating that we've developed a sense of aesthetics around this, though I suppose it is to be expected with how much we are oriented around language.

I personally use 1TBS wherever possible. It just looks the cleanest to me.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#18
post #13

I like Google's HTML style where they don't close some tags and omit optional tags like and Example: Saving money, saving bytes Qed. https://google.github.io/styleguide/htmlcssguide.html#HTML_F...

Disgusting. I bet the person who came up with it doesn't close their parentheses.

Re: Ask HN: Examples of Unusual Code Formatting Styles?

#19
post #13

I like Google's HTML style where they don't close some tags and omit optional tags like and Example: Saving money, saving bytes Qed. https://google.github.io/styleguide/htmlcssguide.html#HTML_F...

Disgusting. I bet the person who came up with it doesn't close their parentheses.

Oh no, where will it end
Post reply on HN