Not using the official formater is just stupid. Who in the god damn thought it would be a good idea to maintain an exactly equivalent formatter?Goland had their own formatter, which had a bug in the early versions. Oh, what fun that was when your IDE reformatted one way and then you ran go fmt in your Makefile - and you wondered why the hell your git was showing all these changed files to commit.
Maybe it wasn't even a bug, but just a different reading of the Go style guide. Not longer an issue anyway.
Interesting. I believe I developed that style independently. I've only ever used open sourced RDBMs. But it's entirely possible that I saw it somewhere, latched onto it, then retconned it to be my own invention.SQL:
Code:SELECT u.id, u.name, u.email FROM users AS u INNER JOIN address AS a ON u.id = a.user_id WHERE a.state='CA' AND a.country='USA' ORDER BY u.id ;
What is wrong with that? I happen to have written SQL over the last 30 years with that same convention. And where did I learn that 30 years ago? The Oracle and IBM DB-2 manuals.
INSERT INTO users (id, name, email) VALUES
(1,'me','me@my.com')
,(2,'you','you@my.com')
,(3,'him','him@ymy.com')
;
SELECT u.id, u.name, u.email
FROM users AS u
INNER JOIN address AS a
ON u.id = a.user_id
WHERE a.state='CA'
AND a.country='USA'
ORDER BY u.id
;
Besides being easier to read, having SQL formatted like this can actually prevent some forms of SQLi. While the real solution for SQLi is bind variables and/or static prepared queries, I still see SQLi in new code. Most SQLi payloads rely on the -- end of line comment to discard the remaining SQL so the injection works. New lines will break that - and prevent the exploit from working.This is true, you ALWAYS use space indentation for SQL, because SQL has NO indenting structure to make it easier to read (it's technically just one line with all runs of spaces, tabs and newlines considered as a single space), and lining up the operands like you did is by far the best thing to do if you ever want to be able to read it again later.
Yes, and it's now a configuration option. Though that does mean you can put something else in....Not using the official formater is just stupid. Who in the god damn thought it would be a good idea to maintain an exactly equivalent formatter?
People who like loose syntax usually say it's more expressive. It's like I'm always telling my friends, "Wow, this code was written so expressively. It sure is easy to read and maintain!"Removes pointless characters that don't add information.
Strictly enforces good layout.
And so is easier to write and read.
That's a really common view. But no offence I actually really hate that attitude.We're on page 5 of this thread and it is a prime example of Religious Wars in coding and software development.
The zeal and righteous certainty displayed by some posters (you know who you are - and are probably proud of it) at the level of dogma of topics more akin to the "sandal vs gourd" fights in Life Of Brian is what makes me happy that I am approaching retirement age and can soon leave it all behind.
I'm certainly glad I don't have to work with some of those people (anymore - I certainly have had to in the past).
Between "the tab key is an outdated construct and should be abolished" to "Nobody that slings code for a living uses spaces for indentation". I'd pay money to get those 2 sides into an arena to fight it out!
Well, joking around about tabs vs. spaces is like throwing kipple into a koi pond.. what did you expectI should have said, in that initial comment, that nobody used spaces for indentation WHEN IT MATTERED. I apologize for overgeneralizing, and while I thought I was being funny, I can see that it totally went flat, and that's totally on me. My apologies to everyone for writing an over-sweeping anachronistic generalization, though I will say in my defense it was mostly for comedic purposes, see toilet paper cascade comment. I included this apology back in the original article.
It almost never matters anymore, because hardly anyone codes in a character-mode text editor these days in a commercial or group setting, and mostly, good riddance. Go back a decade or so (say, to the point where Silicon Valley had a joke about it), and it was still a bit relevant.
I appreciate that wasn't the purpose of your comment. But It furthers the narrative there isn't an actual concern in here that affects people we actually need to discuss.
$data.open_tag('user')
.add_element('name',$name)
.add_element('email',$email)
.close_tag() # user
.open_tag('address')
.open_array()
.add_element('state',$state)
.add_element('country',$county)
.close_array()
.close_tag() #address
;
Downvoted for pineapple on pizza. Sorry, unacceptable.I too am a filthy tabs person. And I prefer vi over emacs (though these days nano is common). I also put pineapple on pizza.
Exactly. 40+ years here. Tabs only ever permitted in makefiles.I've worked in software development for 20+ years, most of it in evil big tech (sigh...) but I have never worked in a codebase where tabs were permitted
Javascript is a morass of things that are hard to read no matter how you format them. Lambdas especially are infuriating to read when you don't very carefully control where your closing parens, braces, and semicolons go.Since I'm making people angry, I'll throw out one of my favorite experiments.
I was doing some complex data structure work with chaining. It was better that the indentation structure matched the data structure instead of the code. I no longer have access to the code, but I remember it to be something like
Feels like I was doing something in XML?Code:$data.open_tag('user') .add_element('name',$name) .add_element('email',$email) .close_tag() # user .open_tag('address) .open_array() .add_element('state',$state) .add_element('country',$county) .close_array() .close_tag() #address ;
Of course somebody auto-formatted the code about 7 days later.
Indeed, not something we will fix on an ars forum! I'm just saying be careful because I'm not kidding I really have tried to have these discussions with the people who set the standards. That attitude bleeds straight through and you can't do it. It's very hard to even get the idea there's an important point in here taken seriously by anyone. The issue has too much baggage which does lead (with some justification I fully appreciate) to the view it's just a holy war.Indeed it wasn't and if the focus was to address the concerns you raised, then we should be having those conversations and try to resolve them with a correct solution to the best of our ability and knowledge.
But that's not what these comments are about, sadly. As becomes blatantly obvious pretty quickly.
I believe the 3, the trinity is holy and sacrosanct. I consider 2 too dense and 4 too sparse. Practitioners of 1 or anything else should be considered beyond redemption.The key reason I switched to (and like) tabs is that it separates the content from the presentation.
As in, I can set the tab size on my editor to whatever number looks great for me (which is 2) - meanwhile others can set it to whatever number looks great for them.
[edit] I lied. I just checked and must have switched my tab size to 4 some years ago. Thankfully I don’t need to go back and update all my old code.
I've had easy to read lambda's, written in Perl. But you really have to go out of your way to write readable Perl.Javascript is a morass of things that are hard to read no matter how you format them. Lambdas especially are infuriating to read when you don't very carefully control where your closing parens, braces, and semicolons go.
PS: with one exception that you mentioned: a couple of years ago, I gave TDD a try to see what the fuss was about.
Their destination is a clearing in the forest that looks like a landing strip. But the only airplane present is a full-size wooden replica of a light aircraft. On one side of the strip lies a control tower made of bamboo. On the other sits a satellite dish built of mud and straw. Undeterred by the apparent lack of any actual aviation technology, some of the men light torches and place them alongside the runway. Others use flags to wave landing signals. Everyone raises their gaze to the sky in anticipation.
They wait. But the planes never come.
Yeah.. We use vs code at work and and it sucks with python.I use those as well (in fact they ended up as my Trinity of Languages over the years, it just happened). Python is a dream to debug in something like PyCharm. C# - hmm, yes, used to use it a lot then just returned to it after some years and I find I'm frowning a lot. What they've done to the language is what I'd call "PL/1-ificiation" (yes, I still was exposed to that, barely). "we don't just need the kitchen sink thrown in, we need all the appliances and those from the laundry room too".
Still will take C# over Java.
I use an editor that automatically converts tabs to spaces. So even though I use the tab key, it just replaces the tab character with 3 spaces. I prefer it being spaces in the file and not tabs. Don't get me started on variable width fonts. There's a guy at work who does this and it looks like an unholy mess every time we stare at his screen when we're doing code reviews.As someone who knows just enough about code to be dangerous...I'm completely confused why you would EVER want to use spaces instead of tabs. Tabs are an inherently superior way to separate things in every use case I've ever had for them. Would love to hear from someone here who actually likes using spaces.
Up next: support for non-integer number of spacesI use an editor that automatically converts tabs to spaces. So even though I use the tab key, it just replaces the tab character with 3 spaces. I prefer it being spaces in the file and not tabs. Don't get me started on variable width fonts. There's a guy at work who does this and it looks like an unholy mess every we stare at his screen when we're doing code reviews.
YAML is designed to be read and written by humans or computers.
JSON is designed to be read and written by computers.
Horses for courses.
Yeah.. We use vs code at work and and it sucks with python.
Yeah, c# over Java.
For what I do work wise I like go for giving me ease of doing something along with ease of doing it with decent performance.
I can't decide if you're trying to date us or turn us off?Tabs > spaces
TP over > TP under
Diagonal cut > straight cut (sandwiches)
Pineapple on pizza is delicious
Ketchup on a hot dog is fine
GIF and JIF sound the same
Glad we could clear all that up.![]()
I too am a filthy tabs person. And I prefer vi over emacs (though these days nano is common). I also put pineapple on pizza.
I believe the 3, the trinity is holy and sacrosanct. I consider 2 too dense and 4 too sparse. Practitioners of 1 or anything else should be considered beyond redemption.
Spaces all the way here.. have been that way since the early 90s. I set my tab stops in vim to be 2 spaces and all my code is indented as such. Why would I care if I can just view the code how I want to view it in vim? Well for the simple reason that vim isn't the only place I view code. Sometimes it's a more command sometimes cat, sometimes it's pasted into a rocket chat code block. With spaces my code will look the same no matter where it's viewed -- especially in places that don't let me configure the tab length.As someone who knows just enough about code to be dangerous...I'm completely confused why you would EVER want to use spaces instead of tabs. Tabs are an inherently superior way to separate things in every use case I've ever had for them. Would love to hear from someone here who actually likes using spaces.
We for better or worse use office, azure, teams, ect. As for vs code I really just care about the standardization at work. One guy got permission to use a jet brains ide and I had to debug why a json file he created was breaking in a tool I wrote. It was because by default the ide was adding some stupid invisible char at the start of the file.Oof, there's another can of worms I'd rather not open in this thread.
Every so often I try VS Code. Load it with all the addons I need, all the language plugins I require.
And stop, go back to Jetbrains within days. I pay for my own universal sub and you can pry it from my cold dead fingers.
But some people will likely bring "Thou shalt use VS Code" torches and pitchforks.
What a great solution, an imaginary number of spaces would surely satisfy all parties.Up next: support for non-integer number of spaces
This.The key reason I switched to (and like) tabs is that it separates the content from the presentation.
As in, I can set the tab size on my editor to whatever number looks great for me (which is 2) - meanwhile others can set it to whatever number looks great for them.
[edit] I lied. I just checked and must have switched my tab size to 4 some years ago. Thankfully I don’t need to go back and update all my old code.
I work with a PLC programming tool. The default font for the system is Times New Roman. Seriously. And nobody seems to care about readability (or code quality) except me. So in every installation of this tool that I encounter I sneakily set the default to Consolas.What kind of maniac uses a proportional font to write code?
You monster.I too am a filthy tabs person. And I prefer vi over emacs (though these days nano is common). I also put pineapple on pizza.
I sincerely wish that surprised me about the embedded world. I've heard horror stories, such as that of an enthusiastic young support tech just out of college who decided to update firmware on aaaaaallll the devices on a site he was helping to bring back up after a maintenance period. You can guess what happened next.I work with a PLC programming tool. The default font for the system is Times New Roman. Seriously. And nobody seems to care about readability (or code quality) except me. So in every installation of this tool that I encounter I sneakily set the default to Consolas.
I remember that episode. The protagonist meets a girl. But the relationship was doomed. He's a tab person and she's spaces.I clicked the Tabs vs Spaces link expecting to be transported to YouTube for an episode of Silicon Valley. Instead I was linked to an old Ars article. Disappointment. Clearly missed reference.
The key reason I switched to (and like) tabs is that it separates the content from the presentation.
As in, I can set the tab size on my editor to whatever number looks great for me (which is 2) - meanwhile others can set it to whatever number looks great for them.
[edit] I lied. I just checked and must have switched my tab size to 4 some years ago. Thankfully I don’t need to go back and update all my old code.