3 ms·
I would like an IDE that saves files in a consistent format but displays the code in whatever style the user prefers. This shouldn’t be hard to do and would hel
by rqtwteye 2y ago
I would like an IDE that saves files in a consistent format but displays the code in whatever style the user prefers. This shouldn’t be hard to do and would help version control a lot.
- eddd-ddde 2y agoI have been thinking about this for ages. There's no reason we even have to work on "files". An IDE should be able to show you a module, or function, or call tree, or data dependency graph, anything! There's so much to be improved in this area. The only feature in this dimension I've seen is jetbrains injected language editor, where you can edit a string as it's own language thingy.
- swatcoder 2y agoCan you elaborate? Mature IDE's already customize the presentation of things like annotations or comments, inject inline hints, and provide alternate editors for things like XML, markdown, or established UI description formats, etc
- Etheryte 2y agoImagine you like two spaces and I like four spaces for indents. With the above idea we both get what we want, locally you see two spaces and I see four, and there's no diff for indents whenever one of us edits a file. Similarly for any other formatting preference.
- 63stack 2y agoIsn't this what tabs are for? Or is this /s?
- Etheryte 2y agoSpaces are just an example to demonstrate the idea. You could apply the same logic to braces, whether curlies are on their own line or not, whether there are spaces between some delimiters or not etc. The idea is that specific formatting doesn't matter, anyone could use their own personal preference because the AST behind it is the same.
- xigoi 2y agoNo, tabs are for formatting tables. It’s literally in the name.
- Cthulhu_ 2y agoThat could be hacked together via some git hooks in theory, like, apply code formatter with your preferences on checkout, apply shared code formatter on checkin. But it's probably more complicated than that. Saving files as syntax trees instead of code files / ASCII might also do that, but that's a level of abstraction nobody is ready for yet, because you need a tool that can translate to readable code everywhere. It kinda reminds me of EXI, a proposed XML transfer protocol that wouldn't bother translating the document to a readable text format but just transfer as binary, a set of 'events' like the SAX parser approach to achieve much more efficient transfer. I don't believe it ever took off though, it was conceived when JSON quickly became more popular. It was only mentioned once on HN [0] 13 years ago, with one point and zero comments. [0] https://news.ycombinator.com/item?id=2312746 https://news.ycombinator.com/item?id=2312746
- kmod 2y agoA while ago I talked with someone who was working on clang-format and they said they tried this (at Google, I think) and the results were not good: they found people write different code depending on the format. For example, code written to fit in 120 columns but then formatted to 80 columns will look worse than code written for 80 columns, due to minor variations in verbosity and variable names and what not. I notice this myself a bit when I switch from a fullsize monitor to a laptop screen.