It amazes me that XCode still actually puts formatting information in the file itself, IMO, it would be better to store source files with no white space and reformat it as per the users preferences when they open the file.
That would make source code unreadable in other text editors, in ‘git’ diffs, on Github, etc. It would probably also completely break merging in any source control system, since that’s always based on source lines. Source control would probably treat the file as binary and refuse to do any diffing/merging. That way, we could all views comments and format it how we like to see it. For instance, some people like the K&R Style and some don’t, some like to indent code, some don’t. This is how Think Pascal worked IIRC (was a *long* time ago!).
Yeah, and about ten years ago I dug up an old floppy with some interesting Pascal code I’d written back in 1989 and wanted to have a look at. Only I couldn’t read it, because THINK Pascal saved source files in an proprietary binary format. I had to dig up an old copy of the app (on another floppy) and find an old Mac that it would run on, so I could open the files and save them as text. If that happened now I would probably just give up. :-p
I think the most reasonable solution is what Go does — there is one standard blessed official style, and Go ships with a tool that reformats source code into that style. Generally you want to always check in code in that style, so a lot of editor plugins will automatically invoke “go fmt" to reformat your code whenever you save. I like this a lot, actually.
—Jens |