tabs/spaces/braces? "The 100% Correct Coding Style Guide"

Started by Darren Dirt, April 04, 2017, 12:30:51 PM

Previous topic - Next topic

Darren Dirt

Finally at long last the debates can end*!

https://medium.freecodecamp.com/the-100-correct-coding-style-guide-5b594a1655f0



*because most of those debates are about minor/simple things at the expense of major/complex things aka #BikeShedding. FTL.
_____________________

Strive for progress. Not perfection.
_____________________

Thorin

Parentheses.  Parentheses everywhere, and everything's a function that takes any number of parameters that you'd like to pass in.  Oh, and everything's a list, too.

Ahhh, LISP, how I despise you.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

Ahahaha

Oh man, this reminds me of a classic Coding Horror article... I'll see if I can find it.
By Grabthar's Hammer

Darren Dirt

#3
Quote from: Mr. Analog on April 04, 2017, 12:55:27 PM
Ahahaha

Oh man, this reminds me of a classic Coding Horror article... I'll see if I can find it.

Yup. I did, indeed, cause that other thread. ( Or, perhaps, yes indeed that other thread was caused by me. #Yoda )


You guys DO get the point of what I posted here, though, right? #DontSweatTheSmallStuff #LetsAllBeFriends #@%&#Standards ;)
_____________________

Strive for progress. Not perfection.
_____________________

Thorin

no no no

The only correct coding standard is whatever is the opposite of what the other dev wants.  He took the last Mars bar and I'm pissed.

And if I have to ride my bike to work when working at a nuclear reactor, I want only the finest sheds to put my bike in.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

Quote from: Darren DirtYou guys DO get the point of what I posted right? #DontSweatTheSmallStuff

Ctrl+K,Ctrl+D

...problem solved...

Honestly I haven't really thought much about formatting for a long time. Actually the only time I can think of somebody getting in a snit over it was because I submitted some COBOL proc that had invisible-to-everyone extra whitespace that was causing compilation errors. Like I was suppose to know the invisible differences between characters interpreted by TWO different DB2 emulators.
By Grabthar's Hammer

Mr. Analog

Quote from: Thorin on April 04, 2017, 02:22:39 PM
no no no

The only correct coding standard is whatever is the opposite of what the other dev wants.  He took the last Mars bar and I'm pissed.

And if I have to ride my bike to work when working at a nuclear reactor, I want only the finest sheds to put my bike in.

HAH!
By Grabthar's Hammer

Darren Dirt

Quote from: Thorin on April 04, 2017, 02:22:39 PM
no no no

The only correct coding standard is whatever is the opposite of what the other dev wants.  He took the last Mars bar and I'm pissed.

And if I have to ride my bike to work when working at a nuclear reactor, I want only the finest sheds to put my bike in.

"Two-Sheds Jackson", is that you?
_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

#8
Quote from: Mr. Analog on April 04, 2017, 02:27:37 PM
Actually the only time I can think of somebody getting in a snit over it was because I submitted some COBOL proc that had invisible-to-everyone extra whitespace that was causing compilation errors. Like I was suppose to know the invisible differences between characters interpreted by TWO different DB2 emulators.

Glad nobody here is a "Brain@%&#" hobbyist ( or maybe the original doesn't care about whitespace while the Danger Zone would be when using one of its https://en.wikipedia.org/wiki/Brain@%&##Derivatives ? ) ... rather unforgiving when it comes to syntax :)



EDIT: boy do *I* feel dumb now. Guess what the uber-creative name of that asshole of a programming language is called? Yup, WHITESPACE.
For example, good ol' FIZZBUZZ: https://github.com/hostilefork/whitespacers/blob/master/lolcode/fizzbuzz.ws
And also, just for fun, check out one of the INTERPRETERS for Whitespace: https://github.com/hostilefork/whitespacers/blob/master/lolcode/whitespace.lol

_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

Wow how funny the timing.

Apparently "Whitespace" was an April Fools Day joke. https://slashdot.org/story/03/04/01/0332202/new-whitespace-only-programming-language (or an accidental duplication of an existing joke language, but w/e... pedant.)
_____________________

Strive for progress. Not perfection.
_____________________

Thorin

Brain@%&# at least is just a hobby language.  I had to write AutoLISP code (well, mostly debug it and fix it) at my first job.  I would try to find matching parentheses to mark the start and end of functions.  It got so convoluted I started putting every start and end parentheses on their own line to show the nesting, indented with two spaces whenever I was going another level deeper.  At one point, the code was indented more than halfway across the second monitor (I had two 19" 4:3 monitors set up side by side).  172 levels deep.  In the end it was one ending parenthesis placed wrong, causing a function to miss one of the parameters it was supposed to get, but it still compiled and ran.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Darren Dirt

#11
Quote from: Thorin on April 04, 2017, 02:55:51 PM
It got so convoluted I started putting every start and end parentheses on their own line to show the nesting, indented with two spaces whenever I was going another level deeper.

Yeah that's definitely "Step Number One" when I have had to maintain some overly complicated formulas over the years ( whether Excel Cell formula, or @Formula in Lotus Notes, or even some JavaScript examples that I was trying to rev-engineer ... hooray for "tidy/prettyprint" websites for JS though! )



Quote from: Thorin on April 04, 2017, 02:55:51 PM
In the end it was one ending parenthesis placed wrong, causing a function to miss one of the parameters it was supposed to get, but it still compiled and ran.
So an obvious candidate for a COMPILE-TIME ERROR doesn't trigger an error when compiled? Wheee fun language to work with! ( Even ignoring the potential for lazy/confused/incompetent developers to do exactly what YIKES they did to you the future dev with the 100+ levels of syntactical wrapping #DIAGFplz )
( Maybe 20-30 years ago they must of had less resources during compile so could only include "some" types of errors? :P https://en.wikipedia.org/wiki/AutoLISP )
_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

Code indenting: tabs not spaces AINEC

Religious argument settled... not by Google in their style "guide"...

https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b

...but by a well-articulated comment -- thank you, Wes Rast, NAILED IT! :)

https://medium.com/@wes.rast/im-always-interested-in-seeing-how-others-work-but-if-there-s-one-rule-that-guaranteed-i-wouldn-t-f10a3fe750bf
"
I know this approaches a religious debate, but here?s the crib sheet on *why spaces are dumb*:

In large teams, particularly those with temporary contract labor, you will always have those who will not abide by your style rules. They *will* do things like alter the space character width for indentation to be comfortable for them, then check it in. I?ve never seen a project where this didn?t happen.

When these changes happen, like a developer beautifying a file so they can more comfortably read it, that file being checked into source control means all lines show up as changed in your source control, rendering it nearly impossible to determine what logic, if any, has changed on the page, obscuring the root causes of any defects found later.

Dictating space character width necessitates you being an asshole.

You saying 2 spaces, or 4, or 8, is guaranteed to not be comfortable for someone else. You have to be a dick and tell them to suck it up, or go be comfortable on another project.

Using a simple text editor like Notepad, or some web-based tools becomes a nightmare of spacebar-smashing in order to maintain accepted indentation style.

Your source files are larger.

*Why tabs are smart:*

Developers can use whatever indentation settings they like without altering the source code, since tab width is only tied to their IDE.

Hence, changes in source control reflect developer intent.

You get to go home that day knowing you weren?t an asshole to anyone because of what key they like to press.

You can use any editor you want, and still only have to hit one key for indentation.

Your source files are smaller.

All the reasons I?ve ever heard that people use spaces involve ?so-and-so said??. There?s no technical reason to use spaces over tabs.

Part of the reason I read this article was in the hopes of finding a technical reason a code giant like Google or AirBnB would make such a foolish decree. I was disappointed. Again.

All this said, for the love of {Insert favorite deity here}, use Prettier...
"
_____________________

Strive for progress. Not perfection.
_____________________

Lazybones

YAML requires spaces and goes hand in hand with PYTHON these days.

Thus it is currently whats in style.

Mr. Analog

By Grabthar's Hammer