has there ever been a proposal for establishing a formatting style file for programmers? In web programming, we have CSS files that help separate style from ‘code’, so two people can see the same code while each can see it in his/her preferred way.
I was thinking something like this could theoretically be achieved for programming. How many times have you read code from another programmer with a formatting that you can’t stomach? If you change the formatting, you’re changing the source file, so whoever comes after you to read the same file could have the same issue against your formatting that you had.
You could say “define coding standards” but this is usually not done in small or individual teams before the company grows.
Why not separate formatting from code? You could define how you like code formatted (brackets here, new line after this, etc) and the IDE would take the source code and auto-format it to your liking (without changing the source code). I guess it wouldn’t be a trivial thing, but I’m curious if there are languages or IDEs in which this has been done.
Has something like this been done or attempted ever? Is it doable? Could something like this be incorporated in, say, Visual Studio?
10
Yes – but not the way you’re thinking.
What has been done for decades now is ‘beautifying’ code. You supply your code to a program that has a set of configuration options, and it formats your code accordingly.
A VS plugin that reformatted your code when you checked it out would be interesting, but… the huge problem with such things (and a formatting document too) is that your code will be re-formatted when you commit it, which will always create huge diffs so you won’t be able to see the “good” changes from the automated bits.
I guess you could automatically reformat all code before it goes in, using a standard style, which would minimise this problem, but probably not eliminate it.
5
In some way, syntax highlighting, as it is done in most editors and IDEs, could be seen as a form of CSS for program text. It seems however that most programmer do not customise the syntax highlighting according to their needs (if it is possible).