4 ms·
Can you expand on this? Prepending spaces (or tabs) to strings is one of the most basic operations there is, so that can't be where the difficulty is. Keeping t
by WJW 4y ago
Can you expand on this? Prepending spaces (or tabs) to strings is one of the most basic operations there is, so that can't be where the difficulty is. Keeping track of what the current indentation level should be also seems like something that any tool which outputs source code already does.
- nordsieck 4y agoThere is a whole range of programs that fit in between "output a single block string of text" and "yer a compiler, Harry!". And maybe the right answer is to import a compiler's worth of tooling to output a bit of code. But to me that seems like needless overhead, since meaningful whitespace isn't really a positive to begin with.
- MadcapJake 4y ago> Keeping track of what the current indentation level should be also seems like something that any tool which outputs source code already does. The challenge you are refuting is about building said tools. Just because existing tools have pushed through this challenge doesn't mean it's not both tech debt for those existing tools and a challenge for any new tool in the space. I think the best argument imo is that whitespace has to be properly maintained per line which adds computational cost and statefulness.
- TylerE 4y agoHow hard is it really? Instead of write(“{“) it’s indent += 1 and write(“ “*indent) and the start of each line. Decrement where you’d have a }