49 points · by fanf2 · 3y ago · 60 comments
If we're lifting abstraction one level up - from dumb plaintext to delimited records - maybe it's time to revive the ASCII control characters that were specifically meant for this? I'm talking about ASCII 28 to ASCII 31 - file, group, unit and record separators.
i think you should be able to nest multiple lines within such a 'table cell' by enclosing it between form feed and vertical tab, which are both conventionally considered whitespace, and are therefore allowed already in the grammars of conventional free-form languages like c, java, js, and scheme. nesting tables within table cells permits almost infinitely flexible layouts, as we all remember from the days before css; and, although the layout algorithm is not as trivial as emulating a teletype, it's fairly simple, linear time, and very fast (as long as you don't try to add word wrap or something)
(you probably also want rowspan and colspan; these should be indicated by putting carriage return and backspace, respectively, in the cells spanned into, like \^ in tbl)
a 'terminal emulator' using such a format would probably need an alternative to character-cell cursor addressing; probably the best alternative is to have multiple cursors, with one escape sequence to move cursor X to the active cursor (forgetting its previous position) and another escape sequence to exchange the active cursor with cursor X
there's no need for escape sequences to look like line noise either
further details are in nestable.md in
git clone http://canonical.org/~kragen/sw/pavnotes2.gitThat's exactly what's happening in currently rudimentary implementations like in Sublime Text, where width can be smaller if needed for alignment
The "spec" also doesn't seem to mandate a minimum
int someDemoCode( int fred,
int wilma)
i think it would be better to represent that, where actually desired, by 00000000: 696e 7420 736f 6d65 4465 6d6f 436f 6465 int someDemoCode
00000010: 2820 0969 6e74 2066 7265 642c 0a09 696e ( .int fred,..in
00000020: 7420 7769 6c6d 6129 0a t wilma). .
(note the explicit space following the left paren) and render 00000030: 696e 7420 736f 6d65 4465 6d6f 436f 6465 int someDemoCode
00000040: 2809 696e 7420 6672 6564 2c0a 0969 6e74 (.int fred,..int
00000050: 2077 696c 6d61 290a wilma).
as the more acceptable int someDemoCode(int fred,
int wilma)
which i think differs from gravgaard's intended semanticsBut then in your design how would you Tab to actually add whitespace, not just vertically align? Would then 2nd tab have a width of 1 space?
This won't do much to sway these programmers
We space users all use the tab key. We just make sure our editor replaces them with spaces as we type because of decades of bitter experience with how mixed tabs and spaces behave over time.
The more interesting question is why tab users haven't noticed that we use mandatory auto-code-formatting these days, to make sure all your tabs are belong to us.
;-P
I'm guessing they're using an equivalent of `M-x tabify` running automatically after opening a file.
Excerpt from documentation on `tabify` in Emacs:
Convert multiple spaces in region to tabs when possible.
A group of spaces is partially replaced by tabs
when this can be done without changing the column they end at.
If called interactively with prefix ARG, convert for the entire
buffer.
Personally, I'm a "space user", and I only have `delete-trailing-whitespace` run on save (`before-save-hook`); at work, we have a pre-commit hook that untabifies committed changes (and then another to run language-specific autoformatter).Not all. I've seen people hit spaces repeatedly…
a = 1
ab = 2
abc = 3
becomes a = 1
change = 2
abc = 3
Nobody ever said a word about it.In Elixir projects we've been using the language code formatter for years and it forces a coding style like mine by default.
Honestly, I use spaces because virtually all tooling and coding conventions that exist prefer spaces over tabs, but I don't understand how it came that spaces won over tabs in the programming world. So much energy wasted on counting spaces in text documents, it's absurd.
If I'm in Python I can press tab multiple times to cycle through indentation levels or do it manually with space and the deletion keys.
Who on earth is counting spaces?
We use spaces for indentation. Do not use tabs in your code. You should set your editor to emit spaces when you hit the tab key."
https://google.github.io/styleguide/cppguide.html#Spaces_vs....
Although most coding guidelines seem to have converged towards spaces over tabs (see [1], [2],[3], your source, and many more), it also causes accessibility issues, especially for visually impaired people.
Some people require larger fonts, making space-indented lines go offscreen quicker. Some people require braille displays, which have a limited line length. A tab takes a single character on these, vs multiple (usually 4) for space-indented code. Some people require bigger indents to be able to process them better.
Not even considering disabilities, some people prefer 2 spaces, some 4, and some whatever pleases them. Working with tabs allows everyone to work on the same codebase with their own preference. By definition this is a subjective matter, and trying to enforce a preference across a whole codebase or programming language is needlessly opinionated.
Plus, the 2 first example use case in the article can't be solved either with spaces or standard tab stops.
---
[1] https://peps.python.org/pep-0008/#tabs-or-spaces
> Spaces are the preferred indentation method
[2] https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
> Use four spaces for indentation. Don't use tabs
[3] https://www.oracle.com/technetwork/java/codeconventions-1500...
> Four spaces should be used as the unit of indentation. The exact construction of the indentation > (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4).
While leaving tabs vs. spaces "unspecified", specifying stabstops of 8 spaces actively discourages tabs
>Working with tabs allows everyone to work on the same codebase with their own preference.
This is where the problem starts. As someone who has to integrate code from a dozen devs, it seems that everyone has a sligthly different usage of tabs (TFA adding one more). If we can ever set everyone on the same page with tabs, I am fine with it. It's just that in production it always seems to cause problems. Spaces are easier to specify.
For the case of disability support, I'd risk to guess that different usages of tabs would end up derailing accessibility software just as much as it derails integration. But I'd prefer deferring this opinion to someone who has experience with it.
Do you want to say: Google bad, Google good or what?
- do not indent code that way
- do not align comments on the side
Before
int someDemoCode( int fred,
int wilma)
×(); /* comment */
print("hello again!\n"); /* comment */
makeThisFunctionNameShorte(); /* comment */
After int someDemoCode(
int fred,
int wilma
)
×(); /* nobody */
print("hello again!\n"); /* needs */
makeThisFunctionNameShorte(); /* aligned comments */
This kind of control over indentation and alignment borders on OCD. You should be using a code formatter anyway, so indentation is auto-fixed. int animateIndenting(
int startingIndent, /// Starting indent, in spaces
int endingIndent, /// Ending indent, in spaces
int animationTimeMs /// Animation time in milliseconds
) {
...
}
is tempting. It's an interesting idea. Whether it's a good idea. It's hard to be completely objective when, for a brief time in the 80s, I spent one third of all my coding time maintaining elaborately baroquely indented Pascal comments. (Not my coding standard. It was fashionable at the time).That the formatter doesn't replace tabs with space... quaintly optimistic. A great shame, since requiring that people use editors with this feature for all eternity, or have ridiculously random indentation of comments is a non-starter.
GP’s example is just finicky window dressing based on indulging a personal aesthetic based on what the author things “looks good” on a particular day, with a particular font on a particular screen.
What we should be striving for in code style is the lowest common denominator most bare bones strucure that can be read, understood and modified with the most rudimentary of tools.
EDIT > What happened to "code is primarily to be read, occasionally to be executed"?
Exactly this. Code should be readable for all. It goes through all sorts of other actors and tooling, not just your painstakingly configured IDE.
>> What we should be striving for in code style is the lowest common denominator most bare bones strucure that can be read, understood and modified with the most rudimentary of tools.
> as if, when designing a building, everyone involved - architects, plumbers, electricians, HVAC engineers …
All the above have to abide by building codes, use standardised parts and tools and most have to conform to certified standards which their work is then also validated against.
We have many, many coding standards most of which discourage tabs and fancy formatting but developers get special exemption because “ma creativiteh”
> plaintext code directly is an idea that needs to die.
Yes let’s throw out some things that work perfectly well to accommodate a few malcontent crybabies.
At the end of the day our laws and most of our written communication depends heavily on plaintext and that’s not gona change any time soon just because a few people don’t want to learn how to use it properly.
What happened to "code is primarily to be read, occasionally to be executed"? You're suggesting we should be optimizing for the wrong thing.
To be honest, this is just another unsolvable issue that's a direct result of us insisting on keeping the code as plaintext and insisting we work directly on it and only it, the single source of truth, using bare-bones tools.
It's really as dumb as if, when designing a building, everyone involved - architects, plumbers, electricians, HVAC engineers, decorators, landscapers and others - were forced to use the same, single, canonical, flat technical drawing. You can imagine they'd be wasting much time on endless holy wars on the right drawing scale, right colors, line thickness, where to put the legend, how to make annotations, etc. - where the real problem is that a single flat piece of paper (or digital equivalent) can't possibly accommodate all their needs at the same time.
We're like that, and here we're discussing whether to align labels on the drawing to the left or to the right, in hopes it'll somehow make an impenetrably dense drawing an iota more readable. We're going as far as to play with dark monadic magick, inventing convoluted drawing techniques in order to somehow squeeze layout of cables, water pipes and air vents in a way that makes decorators shut up about not being able to visualize the building in their heads, because the plan is too dense or too non-local or whatnot. And we're so proud that we automated the ability to xerox the plan for different teams to add more squiggles independently, and then merge them into a new unified plan the next day, and even have an audit trail by putting SHAs on everything.
Seriously, our whole approach and tooling ecosystem is tripling down on idiocy. Editing the same, single source of truth, plaintext code directly is an idea that needs to die.
This is a huge logical error. You just proposed to use the lowest common denominator, but then your response to the analogy is that other people are constrained by rules. Yes, they are constrained by rules, that are very complex, and even then, the constraint ensures a minimal standard, it doesn't block you from creativity. Fire prevention rules will define how wide a corridor has to be, but it won't forbid you to build a wider corridor or to paint its walls.
BTW editing your post to answer a post below you wasn't the smartest thing to do…
The code formatters aren't good enough (and also elastic tabstops work realtime)
What matters much more are idioms, matching interfaces and descriptive names.
Once you get over that as well, it's also quite liberating to not be bound by rules. This does go into unlawful-chaotic territory for some people though
,