There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

aeharding , in wait what
@aeharding@lemmy.world avatar

Is this real or am I eating the onion

TootSweet ,

You’re eating the onion. I could see some government agency deciding that they as an agency would standardize on tabs, though even that would be a stretch. But not the White House.

bisby ,
Deceptichum ,
@Deceptichum@sh.itjust.works avatar

By adopting a tab-delimited approach to softwaremaking, ONCD is ensuring that the technical community’s expertise is reflected in how the Federal Government approaches these inconsistencies. Creators of software can have an outsized impact on the Nation’s shared security by factoring standardized tabulations into the development process.

For anyone who doesn’t want to read that whole thing.

pcouy ,

Lol I almost fell for it. I just Ctrl+F’d the link, no occurence of “tab” in the press release :D

CptEnder ,

You mfer you made me actually read

bloubz ,

🧅

TootSweet , in wait what

'Bout time.

  • a Go fan.
treechicken , in wait what
@treechicken@lemmy.world avatar

Man how are we gonna write all of our Whitespace programs now?

LinearArray , in Stop using floats
@LinearArray@programming.dev avatar

Stop using float

SzethFriendOfNimi , in wait what

I know it’s a joke but I prefer the tab option. It’s easy to convert tabs to any particular spacing or code point width. It can also vary, if wanted, based on terminal or editor type.

People with worse eyesight can have a wider indentation while those who choose can opt for something more compact

kakes ,

I can’t imagine it would be difficult for an IDE to scale the width of spaces found at the start of a line, to emulate this same customization while still preserving my sanity as a fervent space-indenter. I’ve never seen an IDE that does this, but it’d be an interesting compromise.

Maestro ,
@Maestro@kbin.social avatar

It's not difficult at all, and many editors and IDEs already support this, making the entire point moot. Just do whatever the style guide says. I'm into PHP and Python so for me it's spaces all the way.

LaggyKar ,
@LaggyKar@programming.dev avatar

How can it tell the difference between spaces used for indentation and spaces used for alignment, if you use the same character for both?

lud ,

I guess the indention sizer thing knows how the formater works and adjusts accordingly. I can’t imagine it would be too much of a problem.

Iirc Jetbrain IDEs has a feature called dynamic tabs/space (or something like that) which uses exclusively tabs until it needs to align something and a tab doesn’t fit, so it uses a few spaces instead.

coloredgrayscale ,

Maybe alignment more for the righthand side of assignments. If you have a block of variables with different name lengths, or within a constructor / function call.

MotoAsh ,

All parsers ignore a shitload of whitespace already. Just compare unformatted code, COMPLETELY unformatted code, code without character returns, and it’ll become obvious how any given language is interpreted around whitespace.

Also fun to see just how infrequent a semicolon is ‘actually’ needed to tell when the end of a statement is here.

fidodo ,

What if instead of having the IDE special case space characters at the start of a line, we had a special character that could represent a variable width space?

kakes ,

What if we did that, and then wanted to align something?

fidodo ,

Then you use the variable width space for code indentation, then, when you’re at the code indentation level, you’d switch to spaces for alignment. If the IDE special cased all space characters at the start of the line you wouldn’t have that flexibility. You could also easily create a linter that ensured that the variable width space always has the correct indentation level, and ignore the standard space characters after it.

kakes ,

You’re entirely correct. Plus, I hate the idea of changing the width of spaces for any reason lol.

fluckx , (edited )

Honestly I always preferred tabs for indentation and spaces for aligning. It doesn’t break anyone’s experience. And if somebody wants two spaces for a two-space-tab-width for indentation and other people prefer four. That will work just fine.

I hate seeing 2 space indents. Unreadable AF ( to me ). At least this way I can easily work in the same codebase without somebody being annoyed ( except for the crying about the tabs )

jadero ,

Why not tabs for both indentation and alignment? (Actually, I see indentation as just a specific use of alignment.) Word processors have been doing it for decades (and typewriters for over a century!). Surely we can convince our code processors to use user-definable, fixed position tabs instead of relative position “tab = x spaces”.

Keeping the [TAB] character in the file then allows everyone the layout they like.

Or has working solo for 40 years fried my brain?

fluckx ,

What I mean with tab = x spaces is only visually and not actually ( there will ( obviously) still be a tab character in my preference. Not sure if that was clear.

Because alignment are fixed characters compared to indentation. For indentation the only question is how many characters the next indentation needs to be.

For alignment it is not fixed. As an example of PHP code:


<span style="color:#323232;">function test(</span><span style="color:#0086b3;">&amp;</span><span style="color:#323232;">obj) {
</span><span style="color:#323232;">$obj->doSomething()
</span><span style="color:#323232;">....->doSomethingElse()
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span>

The dots would be spaces because in IDEs people generally use a font where every character is equally wide.

If I would tab again instead of spaces it could work out if my tab length display is ( for one or more ) adds up to the width of the variable $obj. If somebody else has a tab width of 2 rather than somebody who has 3. It would only align for one of the two people.

Does make sense? I typed it out after a gym session on my phone.

Additionally. The whole problem is resolved by using spaces for both alignment and indentation. But in the cursor would still jump one space at a time rather than the whole tab ( although there are keyboard shortcuts for jumping words which would jump all of em.

I don’t know. Call me old fashioned. I like what I like :/

jadero ,

If I correctly understand what you are saying, you are describing “relative” tabbing, where /t moves a constant distance from the current position. I prefer “stopped” tabs where /t moves to the next tab stop. If my /t doesn’t create the spacing/alignment I’m after, I just tab to the next position.

Thus, I would set mine with the first tab position (for indenting) at 1.5 cm and subsequent tab stops at 3, 4, 5, … cm. That way I’d get perfect alignment with both fixed and proportional fonts.

I’d also set line-wrap or line-continuation to use a hanging indent based on the start position of the line being wrapped or continued.

I’d also set a boundary between code and comments so that lines always wrapped before the boundary and using the comment character at the end of a line would jump to the other side of the boundary with optional leaders (the characters, usually periods that connect the end/beginning of a gap). In an ideal world, I would be able to “hide code”, pulling all the inline comments into a “hanging indent” structure with their “parent” comments.

Yes, before the advent of IDE editors and all the fancy intellisense stuff, I used word-processing software for coding. 😀

vithigar ,

If I correctly understand what you are saying

You did not, but he also picked an example that could be conflated with the 4-spaces issue.

They’re talking about situations where you might want to align text by a number of spaces that isn’t divisible by your tab size. I’ll expand on their example:


<span style="color:#323232;">function test(&obj, &obj2, &a) {
</span><span style="color:#323232;">$obj->doSomething()
</span><span style="color:#323232;">....->doSomethingElse()
</span><span style="color:#323232;">
</span><span style="color:#323232;">$obj2->doSomething()
</span><span style="color:#323232;">.....->doSomethingElse()
</span><span style="color:#323232;">
</span><span style="color:#323232;">$a->doSomething()
</span><span style="color:#323232;">..->doSomethingElse()
</span><span style="color:#323232;">}
</span>

Again, dots are “visible spaces” in this example, and being used to align chained methods with the length of the object name.

jadero , (edited )

Edit: Bear with me while I sort out the difference between my display and the resulting code block. Ok, close enough.

Ok, thanks. I would instead (and prefer to ) do something like this:


<span style="color:#323232;">function test(&obj, &obj2, &a) {
</span><span style="color:#323232;">$obj---->doSomething()
</span><span style="color:#323232;">---->--->doSomethingElse()
</span><span style="color:#323232;">
</span><span style="color:#323232;">$obj2--->doSomething()
</span><span style="color:#323232;">---->--->doSomethingElse()
</span><span style="color:#323232;">
</span><span style="color:#323232;">$a-->--->doSomething()
</span><span style="color:#323232;">---->--->doSomethingElse()
</span><span style="color:#323232;">}
</span>

In this case, the “>” are showing the tab stops and the “-” the resulting white space. Note how all the calls are lined up. (My preferred alignment style, not necessarily anyone else’s.)

Yet another edit: I see that I missed addressing alignment on other than tab boundaries. To me, that’s just sinful! 😀

fluckx ,

Correct. The way I’m used to it ( and how I thought the world worked ) is that the IDE gives tab a fixed length or characters. If you set it to 4 it would be the equivalent of 4 spaces or 4 letters or whatever.

If my tab is set to 4 it would take up the width of 4 characters. If I need two indentations I would press tab twice.

If bob then checks out my code and calls me a maniac and sociopath for using indentation and swears by “2”, the code would just look more condensed. The alignment would still work out because that’s done through spaces.


<span style="color:#323232;">var user_name = "Bob"
</span><span style="color:#323232;">var user_age[tab]= "Bob"
</span>

This would align the = for Bob, because it needs two characters to align and that’s what his tab width is. It wouldn’t align for me because my tab width is 4. So I would.pur two spaces instead of the . That way it is aligned for everybody regardless of their tab width settings.

The way you explain it sounds like how tabs works in MS Word ( or other word processors ).

I don’t think I could work like that. I’ve only ever used IDEs to code ( regardless of how primitive they were back when I started). Interesting take though :D

jadero ,

The way you explain it sounds like how tabs works in MS Word ( or other word processors ).

That is exactly how they work, and after 40 years, I still struggle with the whole “tab as a shortcut for spaces” thing. It’s not that I started with word processors, either, just that as soon I started working with them, everything got so much easier for me.

There are some code-specific things that keep me from just going back to a word processor, but I think our code editors are missing some useful features that are found in word processors.

fluckx ,

Generally I’m not very preoccupied with it as the IDE just formats it the way I like it on save :D.

azertyfun ,

The fact that you had to explain this is the reason why tabs are inferior in practice. People just don’t get it and then in collaborative projects you get a completely misaligned mess because not everyone has the same tab size.

fidodo ,

Yeah, I understood the arguments against using tabs for alignment, but never really got the argument against using them for indentation.

kureta ,

I agree, tabs are better but I have been using spaces for so long I can’t even imagine switching to tabs. also I’d have to reformat all my abandoned projects.

Solemarc , in Bugs fixed

I love when I make a small code change and then I make my PR, CI runs and some piece of code entirely unrelated fails and it’s now my job to work out how these two unrelated things are related.

xmunk , in wait what

The enlightened among us use spaces for indentation and tabs for alignment.

GissaMittJobb , in Bugs fixed

This is why tests and the Beyonce-rule exist, friends.

threelonmusketeers ,

Beyonce rule?

GissaMittJobb ,

If you liked it, you should’ve put a test on it.

Basically, any attribute of the code in question that matters to you should be under an automated test verifying the attribute.

It comes from Google. You can read more here: abseil.io/resources/swe-book/html/ch11.html

Traister101 , in wait what

Tabs are objectively the better choice as it allows each dev individually to decide tab width in their editors. Spaces in contrast don’t allow this same flexibility as they are used for much more than simply indentation, for example you likely put a space after each argument or operator IE func(arg1, arg2) or 1 + 2.

zea_64 ,

Also, a lot of editors won’t unindent on backspace of spaces indentation, so I end up messing up the indentation with a 3/4 indent

coloredgrayscale ,

Autoformatter should fix that, unless you use python. (but even then they might fix it to the closest proper indentation level)

Traister101 ,

Sometimes. I love auto formatting, I spam the shit out of it more than I spam save but it’s definitely not perfect. It gets real confused with inconsistent indention like that. Especially with Python it’ll fuckup

mexicancartel ,

Yeah you need an auto formatter, which is worse than not needing it. Also yes its terrible in python like languages

expr ,

That just sounds like a shitty editor, tbh. Pretty basic functionality.

driving_crooner ,
@driving_crooner@lemmy.eco.br avatar

Too much waste of space imo, func(arg1,arg2) or 1+2 is faster to write and to read.

andnekon ,

Stilltoomuchwasteofspace

I_am_10_squirrels ,

Whyusemanywordwhenfewworddotrick?

expr ,

Code can be viewed in more than just an editor. It might be in a terminal, rendered in a browser, etc. Sometimes you might even have to view it in an environment you don’t control. I am very disinterested in configuring each and every tool to have sensible tabstops, if such a tool can even be configured.

Traister101 ,

Then don’t? The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width. You won’t like this but the same exact argument can be made for spaces yet I’d bet you haven’t even once configured the width of those.

I don’t actually change tab width, it’s the default 4 spaces equivalent for me but just because I don’t take advantage of the ability doesn’t mean I should prevent others from doing so.

lemmyng ,
@lemmyng@lemmy.ca avatar

The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width.

That is provably wrong. The default tab width in vim is 8 spaces, and the default indentation in yaml is two spaces.

Traister101 ,

What’s yaml have to do with anything? It’s like python with syntactic whitespace which is unrelated to this discussion. The Tab vs Space debate is entirely around non syntactic whitespace which doesn’t effect how the code is parsed. And yes Python technically does both tabs and spaces but it’s all sorts of fucky.

Terminal editors while still used a ton aren’t really what I was referring to. Newer terminal editors such as Helix have tab width configured per language most of which default to a width of 4 spaces but toml/yaml both default to 2 spaces. I was mainly referring to GUI editors as frankly that’s just what most people use nowadays. JetBrains IDEs, Visual Studio, Eclipse, VS Code, Notepad++ were primarily what I was thinking of as I’ve used all of them and they all default to a tab width of 4 hence why I said nearly universal. Also I said nearly terminal editors being the only editors I’ve used that don’t default to a width of 4 seems like a fair usage of the term.

lemmyng ,
@lemmyng@lemmy.ca avatar

Now you’re just shifting the goalpost.

expr ,

This is simply false, many systems have them configured by default to 8, particularly most CLI tools. Git, for example, is 8, and btw, changing it is not readily done and requires you to hack around it by using a custom pager command. In fact, all core gnu utils (and even bash itself) default to 8, as well vim, emacs, nano, gedit, etc.

I use 2 spaces since I work in Haskell, which is a significant whitespace language where you want certain syntactic constructs to exist at a different level of indentation from your main code block. So yes, I have configured it. 2 spaces is also exceedingly common for HTML (browser Dev tools renders HTML with 2 spaces, even).

There is not a universal indentation width, though it is almost always universal within a particular language or perhaps project, in which case it’s much better to have everything standardized. Code formatters enforced on a project are the norm, and those are way more impactful on how the code is read. But they are valuable because consistency is valuable. And yet, somehow you don’t have huge scores of developers complaining about being forced to format their code in a way they don’t like.

As I said, you don’t necessarily control the environment in which you are viewing code. A common example is reading code over a shared screen. So you can easily end up reading code in a way you don’t like anyway, so it may as well be some reasonable (if not preferable) standard that everyone is using.

Traister101 ,

Looking at code on somebody else’s screen is entirely missing the point of using tabs over spaces. The entire point is that mine looks like how I want and theirs looks like how they want even though the file is identical. We can each have wildly different tab width yet it’ll look wildly different to each of us when we program. That’s again the point.

Code formatters are great! I love them. Using tabs over spaces is objectively a better formatting option. One of my favorite features in code formatters is that they’ll swap out spaces to tabs for you insane people who insist on mashing the space bar to indent.

lemmyng ,
@lemmyng@lemmy.ca avatar

No, it’s not missing the point. The premise that you’re always looking at code on the same screen is false, and you don’t always have control over how all screens are configured.

expr ,

Umm, you do realize no one manually enters all of the spaces, right? Basically all editors support an expandtab feature which inserts the amount of spaces you want whenever you hit the tab key.

Code formatters behave exactly the same regardless if you’re using tabs or spaces, so not sure what you’re talking about.

I did not miss the point. I fully understand that’s why people want tabs. I just think it’s a pretty stupid and petty reason to make for a worse experience when viewing code in places you don’t control. I still don’t know why using spaces is an issue when we enforce standards in literally every other facet of contributing to a codebase. We enforce coding styles. Indentation is part of the coding style.

dust_accelerator , in wait what

Feels relevant

Just make everything Shittier

ParsnipWitch , in What’s in a name?

How could they forget Pascal :/

mlg , in Stop using floats
@mlg@lemmy.world avatar

uses 64 bit double instead

Fades , in wait what

Hell yeah tabs

PhobosAnomaly , in dont();

Don’t

simple really

GregorTacTac ,
@GregorTacTac@lemm.ee avatar

"Whatever you do, don’t.

HerbalGamer ,
@HerbalGamer@sh.itjust.works avatar

holy shit that’s a cool project

Mango ,

Wot

SlopppyEngineer , (edited ) in dont();

The car now phantom brakes for anything remotely suspicious, like a shadow from a tunnel or light fixture, causing numerous pileups behind it

tryptaminev ,

The rules for driving demand to keep at least enough distance to the vehicle before you, that you can safely perform an emergency break, if the vehicle should do so too.

In driving ed i learned that you need to keep at least 2seconds distance to the car in front of you, one second to react and one second to perform a similiar break maneuver like them. If your vehicle is heavier you need to increase that distance.

Whenever i drove like this the only result was people taking it as an invitation to swear in between the car in front of me and me. I want undercover cops in plain cars to just drive and record everyone violating the safe distance or takeing the space that is left as safe distance. We could resolve muncipal debt and drop the amount of deadly accidents by at least 50% this way.

exocrinous ,

Cops can’t solve bad driving. Fear of punishment is not an effective deterrent. We know this because we’ve done the psychology and looked at the numbers. Unsafe driving is an infrastructure problem. In my country, people leave enough space between cars. It’s not because we have more police than yours, it’s because we have safer designed roads. Every traffic accident that causes a death is an infrastructure failure.

tryptaminev ,

It is both.

Germany often sees reckless driving compared to its neighbouring countries in similair road conditions. Lack of enforcement and small penalties do play an imporant role in that. The infrastructure is similiar, but other countries actually enforce things like speed limits much more actively. At the end of the day if bad driving equals unsafe driving, the person shouldnt drive.

UndercoverUlrikHD ,

Surprised to hear the rule is 2 seconds in Denmark, it’s 3 in Norway

tryptaminev ,

I’m in Germany

UndercoverUlrikHD ,

Ah sorry, got it mixed up with feddit.dk I think

jadero ,

Canada used to recommend 1 car-length for every 10 miles per hour. Along with metrification, that was changed to 2 seconds, but it’s been set at 3 seconds for a long time.

I’ve yet to drive in traffic where even 1.5 seconds is manageable. More space than that and some slips into the gap, even if that leaves something like a loaded tractor-trailer hanging a second off their rear bumper.

BaardFigur ,

deleted_by_author

  • Loading...
  • SlopppyEngineer ,
    NocturnalEngineer ,

    Technically it’s always hitting the road & air, so it simple just doesn’t move.

    Hamartiogonic ,
    @Hamartiogonic@sopuli.xyz avatar

    This has the way. A god strategy to minimize the probability of an accident is to never move at all. Someone else might still hit you though, but that’s their fault.

    Clent ,

    No one can enter the vehicle because this is a collision. The vehicle automatically moves away from anyone that approaches it.

    nexussapphire ,

    That’s nothing new, my mother’s 2014 charger slows down to a complete stop if there’s a crisp shadow of a bridge in the right place on the road.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines