3 ms·
The problem here is that our editors aren't smart enough to wrap code appropriately. Word processors know to wrap lines on word boundaries; a smart code editor
by stickfigure 6y ago
The problem here is that our editors aren't smart enough to wrap code appropriately. Word processors know to wrap lines on word boundaries; a smart code editor should be able to wrap lines and indent parameters in a human-pleasing way as you drag a window wide or narrow.
- saagarjha 6y agoI think most editors these days do a pretty decent job? It's not perfect, of course, but 99% of the time it's fairly readable.
- wallacoloo 6y agoMore generally though, there's an argument to be made that line-wrapping should be a thing your editor does as part of the rendering process -- not a thing it encodes into the actual source file. Modern languages come with excellent auto-formatters which can make the code look nice at just about any line length. What we need to do is integrate the auto-formatting into the editor (likely via a language-server) so that it can adjust to the width of the editor dynamically instead of running it directly on the files at some width that's forced to be the same for every user of the codebase in every setting.
- williamdclt 6y agoWe could stop storing code as text, just store an AST and let the editor parse it and render it respecting the preference of the user (I think this is a terrible idea, but also got me thinking if there's something interesting there)
- falcolas 6y ago> We could stop storing code as text Why is this terrible? Syntax errors would no longer exist, it would allow editors to work directly with the AST and not text... I think this is a fine idea personally. Our current editors already try to do this - letting you work with syntax and not text - via smart completions, boilerplate templates, and syntax highlighting. Working with an AST directly is only taking it a step further (and better, it removes the reliance on context-insensitive regex based tooling in the editors).
- em-bee 6y agodidn't some variants of BASIC do this? smalltalk is storing the code together with the compiled result in an image, so it could do the same, but i am not aware of any implementation that does that.
- stickfigure 6y agoIt's readable, but not so good that people use it and stop fighting over line length and indentation rules. Four years ago I wrote a stackoverflow question about this and included some pictures: https://stackoverflow.com/questions/31414385/is-it-possible-to-make-intellij-perform-smart-soft-wrapping https://stackoverflow.com/questions/31414385/is-it-possible-... I got a link to a dusty now-9-year-old issue in Jetbrains' tracker: https://youtrack.jetbrains.com/issue/IDEABKL-6076 https://youtrack.jetbrains.com/issue/IDEABKL-6076
- gwillz 6y agoPerhaps this could be a new feature for the language server protocol? Or is it already in the works...?