Hacker News new | past | comments | ask | show | jobs | submit login

> Formatting

> The solution here is to always use an automated code formatter.

Spot on. Python got that part right.




My experience is that Python handles this wonderfully on the reading side, because code will always be consistently formatted.

But on the writing side, it's harder (impossible?) to have tools that format an entire file, because without braces, various things could be at different levels of indentation. You have to indent as you go, and changing the level of indentation can be a little painful.

In curly brace languages, you can sometimes work very fast by crapping things onto the page and then formatting the entire file.

I don't know which I absolutely prefer, but there is a tradeoff to whitespace based blocks. That said, I think C & Java suffer for the combination of optional braces and lack of a standard format tool.


Surely you mean Go? There is one for Python, but it's not official.


Python won't run without specified indentation, and leaves no freedom for brace positioning. On the C side, we've accumulated a variety of formatting styles [1].

[1] https://en.wikipedia.org/wiki/Indent_style#Styles


You can automatically format C.

Python, not so much.


Both of you make the mistake of confusing formatting with indentation. Indentation is just a tiny part of formatting. There are tools to automatically format Python (but they do obviously require that the indentation is somewhat correct before you run them) and they work fairly well. :)




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: