hotkey,

You know how you look at old pictures and cringe?

Well, I found old code from a C++ class project in 1997 (first year uni)

That cursed indentation style 😱
The Variables With Capital Letters!
Calling a destructor directly to clear an object (lolwut)
I'd put in more spaces too.

(pretty sure the variables names in French and the "over-comment everything" requirements were required by the teacher)

bpruneau,

@hotkey Je code encore mes noms de variables et de fonctions en français. Ça me permet de rapidement différencier mon code du code de librairies externes.

Bon, évidemment, c'est toujours quand c'est pour des projets à l'interne, hein...

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@hotkey
Just what is wrong with the indentation style?! 😉

hotkey,

@YouShallNotPass taps the sign

rick,
@rick@ricko.social avatar

@hotkey @YouShallNotPass Okay, yeah, that's cursed.

Here's a pair of baby sandhill cranes for brain bleach.

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@rick @hotkey
It's also missing several I've seen in the wild which could only be classified as crimes against decency and logic.

hotkey,

@YouShallNotPass Oh I'd loooove to see those 😆

(I mean, like watching an horror movie: it's fine as long as you're not living it)

@rick

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@hotkey @rick
I haven't collected appalling code styles in a while, unfortunately. Got out of the habit when I stopped reading other people's code. But let's just say that I once saw C code with no indentation at all, and have also seen it with very few line breaks in blocks because this person apparently never wanted anyone to read their code again. I'm not sure what those styles are called but they're like trying to read illuminated manuscripts from before the invention of spaces between words.

In all seriousness, I don't really care what style people use (mostly), I just find Allman to be the most navigable. I learned K&R from the K&R book, but once I found Allman it just stuck with me. But I write verbose code because I don't have to fit it onto a floppy disk anymore. Idgaf about including extraneous whitespace. It's not in short supply.

hotkey,

@YouShallNotPass This 100%

I don't get people who do cryptic short names and code as dense as a black hole.

I mean sure file size was important in the 70s but I think we can spare more spaces and characters now.

(ok I don't mean the crazy Java 80 character functions name. I mean, calm down Java.)

At my old job there was a guy that coded everything so... densely... gave me a headache every time I had to read it.

Code needs to breathe!

@rick

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@hotkey @rick
In fairness, back in the bad old days of the web, coding that way also made a difference in load times, but minifiers came along pretty quickly and yeah, now you've got no excuse.

I once heard a rationale that every line of code should be a semantic whole, and therefore blocks should all be on one line. This has the benefit of cutting down on the levels of block you use, but it's still unreadable.

And you'd probably hate my code because I write a fair number of Java-style variables. No Hungarian notation though. Autocomplete is my friend.

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@hotkey
K&R is wrong too. The only acceptable style is Allman, using tabs not spaces.

hotkey,

@YouShallNotPass I mostly do Allman but I'm getting more and more into K&R...

... come... to the dark side...
We have ice cream.

Tabs vs space: tabs are only a problem because people use them to align things.

As one of my old coworker used to repeat (/yell):
"tabs to indent!,
spaces to align!"

( https://dmitryfrank.com/articles/indent_with_tabs_align_with_spaces )

But it's too complicated so people said fuck it, all spaces. And now we can't change the indent size with the flip of a switch ¯_(ツ)_/¯

Tabs lost the war unfortunately.

YouShallNotPass,
@YouShallNotPass@chaosfem.tw avatar

@hotkey
Tabs are only dead if we allow them to be. They'll stage a comeback any day now 😜

I see the advantages to both styles, but for me K&R boils down to avoiding an extra line in your program, and again, I like whitespace. Allman putting the opening and closing bracket on the same line makes it slightly easier for me to scan for them. I admit that a good IDE should do that job for me, but I still prefer it slightly. I do admit that K&R puts the statement that initiates the block on the same line as the closing bracket, which makes a certain degree of sense. But I can read both without difficulty.

Stay on the other dark side. We have cake. 😁🎂

mikolaj,
@mikolaj@chaos.social avatar

@hotkey Speaking of overcommenting, in uni the embedded C teacher required us to use verbose names in Systems Hungarian notation for everything, even for simple loop counters. So even a single-line-body for loop looked like this:

for( unsigned char ucCharCounter = 0; ucCharCounter < LENGTH; ucCharCounter++ )
{
...
}

hotkey,

@mikolaj urgh. Freaking Hungarian notation 🤬

mikolaj,
@mikolaj@chaos.social avatar

@hotkey Why "boolean" instead of "bool"? I thought C++ had "bool" in 1997.

hotkey,

@mikolaj This probably was Borland C++ 3.x that didn't have bool if I recall correcly.

In my project I used an enum:

enum boolean {FAUX,VRAI};

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • ngwrru68w68
  • osvaldo12
  • magazineikmin
  • tacticalgear
  • rosin
  • thenastyranch
  • Youngstown
  • khanakhh
  • slotface
  • mdbf
  • kavyap
  • InstantRegret
  • GTA5RPClips
  • JUstTest
  • Durango
  • cubers
  • modclub
  • cisconetworking
  • tester
  • everett
  • ethstaker
  • Leos
  • anitta
  • normalnudes
  • provamag3
  • megavids
  • lostlight
  • All magazines