by VeejayRampay · 12y ago · 0 comments
What really bothers me is that editors in general force people to share a codebase formatted for a given style that may or may not satisfy everyone.
And the worst is that I don't see why that has to be. Ideally "code" would be some form of abstract syntax tree and the editor would apply a user-generated "stylesheet" on top of it to display the code as the user wants to see it.
Upon save, all the style would go away and only the abstract representation of the code would go to the shared repo.
Not an easy thing to make happen for sure, but that'd be awesome.
It will save A LOT of time later.
If we can do it for web pages (with CSS) there's no reason why we couldn't be able to do it for a source file.
I agree with you that having CSS-like option would be better, since code is data, CSS is formatting options. But you'd have to teach all other tools you use to work with this CSS approach. For example for git source files are just text. Git doesn't understand code semantics. For its diff routine tabs changed to spaces == every line of code changed.
There's no much use for a VCS if every commit changed everything.
That I think the editor should take care of. For more serious issues like your example of poorly named variables, there's nothing it could do (and is really the core of the problem, as you pointed out).