5 ms·
I was always wondering how it would be if IDE could treat curly braces blocks as virtual indentations. So you could work with language that uses curly braces as
by zigzag312 5y ago
I was always wondering how it would be if IDE could treat curly braces blocks as virtual indentations. So you could work with language that uses curly braces as if it used indentations. Text file would still contain braces, but IDE would display them as indentation blocks.
I'm not completely sure if UX would work out. There would be less visual noise, so reading would be easier. Writing is harder to solve as IDE would need to be smart and convert indentations to pairs of braces underneath in appropriate contexts.
This feature would of course need to be togglable on/off.
- marcosdumay 5y agoWhat is the gain of deriving the braces from the indentation instead of deriving the indentation from the braces? You still have one character to start (tab?) and end (backspace?) a block, but now they are overloaded with the edition keys, and still need to keep track of the block with the same visual aid (indentation). The small changes I see are to the worse, that is overloading the keys and not letting you see the text verbatim.
- zigzag312 5y agoBraces by itself are very poor visual indicators of a block, so they are almost always (except in one liners) coupled with indentation of the code inside the block. So, in a raw text form (ignoring newline and space chars) it's two characters to start a block (brace and a tab). Sure, a good IDE will automatically create indentation when you type '{', so you need to only type a single character to start the block. We could actually say '{' is a shortcut key to start a block. IDE creates an indentation and draws a vertical line to enhance visual presentation of the block. Visually, braces are more or less just a noise, so removing them would improve "signal to noise ratio" and enhance reading experience. However, logically braces are better at defining blocks of code than tabs. With braces we have start '{' and end '}' characters, but with tabs each line needs to be indented by a correct number of chars (tabs/spaces). I am wondering, if we can have best of both worlds. In some cases we are trying to draw visual indications with text. Wouldn't be better, if we let the IDE do the drawing? Eg.: two vs four spaces of indentation? It doesn't matter, if you can configure visual indentation depth on the fly in the IDE.
- z3t4 5y agoI've made a web based editor (https://webide.se/ https://webide.se/) that does automatic indentation. You can copy any JavaScript code into it and it will parse and indent. When using other editors i find it annoying to have to manually manage indentation and I do not miss the syntax errors that comes when there is a block mismatch and you have to figure out where that missing } should be... There are languages like Python that uses "significant white space" where there are no curly braces and instead you use indentation to decide where a block ends. The problem with Python is that my editor has no way to know
- CRConrad 5y ago> Braces by itself are very poor visual indicators of a block And that's why better languages use the keywords "begin" and "end" in stead.