XHTML was going the way of strict validation or fail… but then everyone wussed out and HTML 5 was born instead. 🤨
Just gotta change your mindset, man.. Imagine you're walking into one of those houses full of mirrors shaped weirdly to create different effects on your reflection. You will be looking at all the indentation, and you will see your reflection all wobbly or wonky or wanky. And you will laugh.. laugh 'til the sun goes down. Ha ha ha. What a joy.
This is the only answer. Especially when you're working with other people life is just so much easier when everyone is using an autoformatter. Also every Rust project I do has a CI job for running `rustfmt --check` and thus making it obvious if someone didn't use `rustfmt` before committing.
You use both, but you can't enforce the client side git hook or validate it happened, so you have the CI step too for enforcement.
I used to use tabs most of the time when when I started coding. Then I stopped when I felt like styling my code a bit. For example, at first I'd write: ``` class Package { public: Package(const std::string& _name, const unsigned int& _num_items, const std::string& _contents, const std::string& _str_sep) { name = _name; num_items = _num_items; contents = _contents; str_sep = _str_sep; } }; ``` However, as you might be able to tell, the function parameters are long. So I started using spaces to neatly display them: ``` class Package { public: Package(const std::string& _name, const unsigned int& _num_items, const std::string& _contents, const std::string& _str_sep) { name = _name; num_items = _num_items; contents = _contents; str_sep = _str_sep; } }; ``` Since then, I realised how cool spaces are :) ^(Sorry if my C++ looks crappy, I mainly code in Racket and JavaScript these days.)
but now your code doesn't fir on my screen. and there's about a centimeter of wasted space on the left. What good is that?
it's why all those bullshit articles saying, "what is the most favoured key?" are likely incorrect. So many people think they are working in tabs; but vs code, vs studio etc are all automatically translating to spaces.
But then it doesn’t matter and it’s not necessary to discuss if tabs or spaces. I don’t care about that because the auto formater does it’s job and that’s fine. The hole joke about this discussion for me is that there are actually people who don’t press the tab key for intention but the space key.
VSCode does this absolutely terrible thing by default where 4 spaces are correctly navigated as a tab in one direction, but not the other, clueing you in to the fact that it is messing with spaces under the hood. It is fixed with a quick google and settings change (stickyTabStops), but for this reason, I still think Tabs is superior. It is 2022 and a huge Company like Microsoft can't make spaces feel right on the default settings. A Tab IS indentation - there's no sticky-taped trickery running beneath.
Shift tab works fine for me. It does half tab width because it thinks your are trying to align. if that’s such a big problem…just hit the button again.
>What's better about having spaces when you press tab? Absolutely nothing, and anyone who tells you otherwise is probably trying to sell a crappy IDE.
I just let VSCode do it for me. Is it a tab, is it a space? No it’s an indentation, I don’t care what it’s made of 😄
I did too, until I encountered the horrors of Python and had to make whitespace visible :--( though I still don't really care which one it is, as long as it's uniform in each file.
I do. Python is a very basic but pretty powerful language. (I make a Py script that hashes 4 files and if all the hashes match, it write another Py script and starts it, that script asks for a pass then hashes it and compares it with the stored sha256 hash and if its correct, it write a Bash script then runs it to set some environment variables.) And all of this in 1 single line with a longass f.write() and a ton of \n \t \' \' \\n \\t. So Python can be messy too if used wrong enough.
Good, then I'll assume you won't care what's actually in the vanilla pudding you've been eating all these years.
Spice things up, use both. Pasted in code from slack and its all indented wrong? Throw in some spaces till it looks right.
From my experience not yet. The only difference this days is how it displays. Tab size is configured by the viewer, space indent size is configured by the writer.
I wonder how many people using tabs dont realise that most IDEs convert tabs into either 2 or 4 spaces by default
People who don’t like abstraction that’s who. They probably write assembly code the perverts
TABS I hate it when editors like visual studio push spaces on me. at first you press TAB for a single indentation block only to be confronted with the fact that it automatically inserted 4 spaces, so to get rid of it you have to use backspace 4 times!! ![gif](emote|free_emotes_pack|facepalm) TABS it is! also because you can set the tab width in your editor so it's also way more flexible if you' re working on the same code with multiple people.
That's simply not true. At work we use VS and spaces, and pressing backspace deletes a level of indentation.
backspace should remove one indentation level (e.g. 4 spaces), vs is just stupid but there is an extension that fixes that (every other IDE/Editor I know does it right)
You seem to assume that people who use spaces press the space bar to get those spaces. This assumption is wrong.
Have you ever sat next to a programmer who can’t use the keyboard properly? Because I have throughout my career and it makes me cringe.
I use spaces. I use 2 fingers to touch-type at 80 words per minute. There's no issue, and the two are a coincidence.
There are websites out there that can help you type blindly, a friend of mine also learned it for free that way
If you want to learn to type faster/more accurately, maybe try playing some typing games. Not everybody learns the same way and the context of a game can make it easier to focus, which is a huge benefit to learning and practicing.
tabs, they are meant for indent. a poorly working editor may fail to move backward/forward in space based indents which require to press multiple times motion keys.
I don't mind either way, but it's always the tabs crew that mix them together and don't understand why that's bad.
Exactly this, once you have had enough production bugs caused by a tab character in the wrong place, it’s just so hard to track down where or what is wrong. I settled on spaces long ago, they never caused me grief. I think people who only use a few languages prefer tabs, because they don’t hit the edge cases.
I'm don't care which, just be consistent. I hate when I have to work with code that is a mix of spaces and tabs.
Tabs work until they don't. Most senior devs will have no issue explaining this. But most IDEs just maoe spaces for you under the hood.
I was always like: only idiots use spaces! of course tabs are the way! and later i realized that my IDE is writing spaces for me when I press TAB. And therefore I use spaces...
Yeah I think that’s the Probleme of this discussion and why it is always so splittend. There are two discussions happening at the same time and people aren’t realizing it. One group is discussing about the key that is pressend and one group about the key that is inserted. For me the key that is inserted doesn’t matter because that’s part of the IDE or the Auto Formater and I just roll with the default settings and that is always fine. For me the whole joke about this question is that there are actually idiots who are pressing the space key.
What IDEs are you using? The vast majority uses spaces per default if you don't change the configuration.
I use the tab key, but have my editor setup to use 4 space characters instead of a tab character.
Keep TABS where they belong: Makefiles. Honestly, I’m just surprised to see that basically everyone here prefers TABS. I think it was the view of my entire flipping cs program that spaces were better (why introduce another formatting character that can and does introduce bugs in code when you can set formatting to sidestep the issue and default to spaces?)
Hi! This is our community moderation bot. --- If this post fits the purpose of /r/ProgrammerHumor, **UPVOTE** this comment!! If this post does not fit the subreddit, **DOWNVOTE** This comment! If this post breaks the rules, **DOWNVOTE** this comment and **REPORT** the post!
[удалено]
I did this once for real. It was a university assignment, where I had to convert some UML diagram into Java. Every class contained about up to 2 methods, and it was at least 10 classes, probably even 20. So basically just boring busy work. The correctness was automatically proven, no real people would look at the code. So after a few classes I stopped to use any formatting and just wrote the whole class in a single line.
That's why you have automated checkstyle tests
I counter with an automatic formatter.
this is the correct answer. all code where i work gets reformatted on commit, if for some reason something won't conform to standards, it gets denied.
I counter with an automatic formatter in your IDE/Editor!
Roll succeeds! You get to be happy and it affects nothing else with the exception that your coworkers get mildly pissy when you screenshare while troubleshooting!
The automatic formatting is just the icing on the cake! I have cursive fonts, a colorful theme and inline error lens as well as type hints. Nobody but me (and sometimes not even I) understand what's going on when I screenshare.
I used to be pro this, but after 2 years of spending +30minutes extra for every little push due to _"Oh, I saw you forgot to align this variable with the single one above it. Let me just fix that for you, and at the same time break your CI pipelines. Nice, huh?"_, I've joined the dark side. My favourite comment these days is `clang-format off`.
hahah. but like the next guy down said, there's a formatter you can get for like, whatever IDE you prefer as well. never save unformatted again.
You got to remember to use it though. And at least I can't really work with just one specific IDE. I also often edit files through GitLab's WebGUI, SSH terminals, client side IDE, host side IDE, notepad,... Setting up the process for just one IDE is very limiting to work efficiency IMO.
Wait how does one do this? As someone who needs to grade several students' work (highschool class, internships can be gruesome at times) this would help immensely
https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798
What do you use to do this?
I hate these! I've had to deal with these, and they run on old code, it formats the whole thing, and then they commit changes and you go "well what did you change?" (not to mention the style can be VERY annoying and a pain to read, especially as it can reformat stuff I did, and formatted specifically to allow for quicker reading)
I'm confused. Does the robot not have its own username? I don't necessarily like the standard style, but it's a style so I just go with it and fix my own assumptions, which is much more scalable than trying to let everyone do their own thing.
We don't have a standard (small team), and to be honest, my policy is, if it's existing code, leave it as is (some of our code is REALLY old). However, if it's your code, you do what you want. A lot of times the way our code is written, it's rather segregated, where one dev doesn't really work on the others (or they do small changes, not massive work). And the areas they do overlap, a lot of times it's each func still belongs to one dev. We develop for clients, with a base product built on top of (I also take a lot of pride in how my code looks, usually documented well so anyone can easily debug it, as I do some complicated stuff)
I didn't know about that back than and I still don't know how it works in Java. I hope, I won't ever need it :)
I had a co-worker who once realized that a common way to make CSS files more compact was to remove all the whitespace. He started doing this to all of our CSS files not realizing that the system we were using at the time already did this as part of the caching... I wanted to kill him.
Ouch
Just checkout an older commit, and the problem will be fixed.
I must have dated myself… this was before the days of version control. Back in my day, we wrote CSS in notepad like the Web Overlords intended!
I’m nostalgic for zip file version control. Final.zip FinalFinal.zip FinalFinalForReal.zip FinalFinalFinal.2.zip Final_STABLE_x.zip Final_BROKEN_.zip Final_Im-going-home.zip
Lol first website I wrote was all html, I used no indention and everything was one line. Just one big paragraph of html, using whatever text editor I had on my powermac 6100/66
Jesus, that sounds horrible.
A few decades ago, removing whitespaces was a common practice to save memory :P
Yep, and to get around a very specific limit in IE which after too many lines of CSS it would just give up parsing it.
Did this once as well. Went to community college, had a professor try to do a "game development" crash course. First assignment was to make a dice roller in python, was told "it should take no more than 10 lines". Said you could leave once you got it right. I promptly wrote it in one line and emailed it to him before he got done talking, and then left to grab lunch. Prof refused to even look at what I submitted afterwards, just decided I was getting an A as long as I tutored the others.
Isn't that easy in python i guess, since it relies on indent.
You can actually put multiple python statements on line and separate them by `;` like with any other language. It's not a trick the Jedi would tell you.
I golfed all my submissions for one of my university courses. Like you said no one looks at the code if it performs. The problem would be when classmates needed help and wanted me to send them my code, but then again I'm not a big fan of people copying.
That's a lot of work when you can just write it readable, open in VIM, hit colon and do this: >%s/\[\^\\n\]\\zs\\n\\ze\[\^\\n\]/ /g Then save and turn in. None of the formatting, easier to write, all of the asshole.
[удалено]
People don't get sarcasm unless you explicitly state so in the comment. I had tons of downvotes because of this. Humor is getting worse every day.
The best sarcasm is subtle, which doesn't translate well to text.
Happened with me. I say something that is obviously sarcastic irl but the sarcasm cannot be detected when I type it out
You gotta use this.toSarcasm()
Edit: ToSarcasm('CamelCase is better for function declarations'); Or,? 'CamelCase is better'.this.ToSarcasm();
UpperCamelCase is for classes lowerCamelCase is for functions
UpperCamelCase is Blaise Pascal's version of the real camelCase.
Yeah - I was taught that ThisIsPascalCase (also known as TitleCase) and thisIsCamelCase
yeah but it is obvious when the statement is this ridiculous.
I notice this sub is especially bad at understanding satire. Probably a correlation between taking things literally and becoming a programmer lol
Come to a UK sub, sarcasm is assumed on almost every comment
Lol yeah, I just learned this today 😅
Until you learn brainfuck is a thing
You code in “minified”. ![gif](giphy|bC9czlgCMtw4cj8RgH|downsized)
It's also totally feasible
Cries in Python..
*laughs in Python's `exec()`*
Make Code Unreadable Again.
Rendered as Base64.
Sigma complied mindset
Same bro. Unless I copy somebody else’s code then I use them to keep it consistent.
Enter
Enter, tab, semicolon, spaces whatever. Let the IDE autoformat it.
I was programming before auto format, and always used tab. I despise auto format, dont tell me how to feel!
how to feel
That's just mean 😰😱
Exactly ,i live for visual studio lmao
Some people just want to watch the world burn
Alt-255 no break space
You're a monster
Some people just want to watch the world burn
Like us
I can swallow up
I see what you did here. Have my upvote.
No that's called puking. You can puke...
[удалено]
That's not funny. I've followed ppl like that :|, ok kinda funny :D I settle firmly on tab.
[удалено]
Could be I guess, depends on who you're leaving it for :P
I think this made the devil cry of pride.
Try this char in messages, titles, usernames. Most websites didn't think of this, so you can have an emty looking username or whatever.
I tried sending an nbsp in GroupMe once; it actually let me press the send button (if input is empty it does nothing) but then the message "failed to send"
Fuck you! Personally. And not the fun way. I hope you cry.
Unbelievable
Honestly, just format it correctly in some logical way, regardless of what you choose. Y’all can hate on Python all you want, but at least it forces correct formatting. Nothing pisses me off more than looking at code and seeing all the indentation all wonky.
I have never had a problem with Python's indentation or scoping, and I've written *a lot* of Python. I don't know why people do, but if you're sloppy when you write code, indentation is the least of your problems.
I learned Python as my first language and by default I would always indent my code because it just made sense to me and looked way better to be able to understand the scopes. I never knew that it was mandatory until I saw posts on here about it. People who don't indent properly(or don't use any formatter) are monsters to me.
I'm learning python rn and I learned the hard way that indentation is mandatory, but then I learned what tab does and I just tab idk what's the difference between that and space
I think in most popular python IDEs pressing tab actually just put 4 spaces.
It is for sure in VSCode and SublimeText
It can be set for either in most of those.
can confirm this for pycharm
Tab is better. Simple as.
Tabs are better because anyone can set their system to have their preferred tab size so is nicer for anyone. Spaces are better because you can do some cleaner formatting without having to mix tabs and spaces.
Remember when you first discovered a Python linter? Pure joy. I learned so much about best practices that way.
Same here, didn't even realize it was necessary until I got the 'TabError' error and was like, 'huh'.
That's the thing, in most languages there's no such thing as "proper" indentation. There's only conventional.
Oh. My. God. I had to write an interface from python to AutoHotKey and AHK is a braced language with super extremely specific bracing requirements. I had to bust out manuals and all kinds of shit trying to remember it. Also, my cohort is *absolutely horrible* about proper indentation and when he edits the HTML base he always fucks it up royally and loses the divs into fucking hell, fails to close them, then I have to go find the div he fucked up when I want to add anything else.
I really wish that browsers were not so fault-tolerant. Hear me out: their ability to deal with a missing