Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CPColin
Sep 9, 2003

Big ol' smile.

Beef posted:

I'm still afraid to ask why there's an extra space in front of semicolons.

It's for Jesus

Adbot
ADBOT LOVES YOU

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Toshimo posted:

This post could have been an email.

The email could've been a Teams call that keeps ringing on my phone even though I already picked it up on my laptop.

CPColin
Sep 9, 2003

Big ol' smile.
Just deserts for allowing Teams near your phone, imo

Beef
Jul 26, 2004

CPColin posted:

It's for Jesus

Make space for Jesus in your code.

chglcu
May 17, 2007

I'm so bored with the USA.

Beef posted:

I went into a video call expecting a tabs vs spaces discussion when I raised the issue of the baffling seemingly random C code style on a project I'm working on. Sometimes there would be a space between the function name and arglist, sometimes where wouldn't. There are occasional superfluous space after an open brace, which my emacs setups paints in angry red, that I would have to sweep up using whitespace-cleanup before commits.


It turned out every extra space has it's purpose and it is beautiful.

`foo ()` vs `foo()` allows grep to distinguish between definitions and call sites.

The superfluous space is a marker for a codegen tool that inserts markers for code coverage testing using gcov.

We do the space in definitions, not at call sites where I am now (and I actually like it, though wouldn’t really fight for it), but your mention of test coverage even being a thing tells me we’re not at the same place.

e: At the risk of being called a horror myself, I’ve been programming professionally since 2007 and have written precisely 0 unit tests on the job. Game development, so not especially unusual.

chglcu fucked around with this message at 17:56 on Jun 5, 2023

Beef
Jul 26, 2004

chglcu posted:

e: At the risk of being called a horror myself, I’ve been programming professionally since 2007 and have written precisely 0 unit tests on the job. Game development, so not especially unusual.

Now I'm wondering if there are games out there that simulate a player going through the game.

NtotheTC
Dec 31, 2007


Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

the players are the unit tests

Rea
Apr 5, 2011

Komi-san won.

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

Just generally, or in the context of testing?

raminasi
Jan 25, 2005

a last drink with no ice

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

The Talos Principle has this.

neosloth
Sep 5, 2013

Professional Procrastinator

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

Factorio has some really cool tests

https://youtu.be/TCxIghf4Z_0

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Putting a newline between the return type and function definition was an old school C thing to make function definitions easily greppable (with ^foo). I think I hate it less than spaces between the name and parentheses.

Xarn
Jun 26, 2015
Sometimes your return type has 400 characters and giving it (multiple) lines on its own is best way to format it.

Splitting int foo() onto two lines can gently caress right off though.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

Minecraft has a sort of QA-world-on-demand filled with all sorts of “tests” are lined up in a giant matrix, and each one shoot a light in the sky. If a “test” passes, it’s a green light, otherwise it’s red.

https://youtu.be/vXaWOJTCYNg

zergstain
Dec 15, 2005

Xarn posted:

Sometimes your return type has 400 characters and giving it (multiple) lines on its own is best way to format it.

Splitting int foo() onto two lines can gently caress right off though.

Sometimes you need a typedef, or 3 or 4 levels of typedefs.

Canine Blues Arooo
Jan 7, 2008

when you think about it...i'm the first girl you ever spent the night with



Grimey Drawer

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

I built QA tooling and process for a few years, and this was kind of the holy grail for at least a few cases you cared about. The problem is that the game kinda needs to be built with those kinds of hooks in mind from the beginning to make that process easy. If it's not something you can easily just hook, it becomes hard though. There is actually a pile of things you should do with your New Game to set yourself up for production success - if it's possible, this is one of those things.

Tei
Feb 19, 2011
Probation
Can't post for 44 hours!

Beef posted:

Now I'm wondering if there are games out there that simulate a player going through the game.

on some network games, the network traffic can be recorded and played again infinite times, can be used to test the client

Beef
Jul 26, 2004

Canine Blues Arooo posted:

I built QA tooling and process for a few years, and this was kind of the holy grail for at least a few cases you cared about. The problem is that the game kinda needs to be built with those kinds of hooks in mind from the beginning to make that process easy. If it's not something you can easily just hook, it becomes hard though. There is actually a pile of things you should do with your New Game to set yourself up for production success - if it's possible, this is one of those things.

And end up scrapping it because the game design and tech changed drastically during production?

Kazinsal
Dec 13, 2011

Beef posted:

Make space for Jesus in your code.

Any C I write is in desperate need of saviorship from above so I can understand this line of thinking.

Xarn
Jun 26, 2015

zergstain posted:

Sometimes you need a typedef, or 3 or 4 levels of typedefs.

I don't think you can typedef enable-ifs

zergstain
Dec 15, 2005

I knew this was template bullshit.

Guessing there's a level or two of nested template arguments. Can't typedef any of those either? Maybe a proposal should be submitted to the standards committee if one doesn't exist already.

Presto
Nov 22, 2002

Keep calm and Harry on.
Get rid of the enable_if return type and slap a big ol' static_assert inside the function.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
You can extract out a template using that checks a complex condition for a type.

I’m not sure what we’re arguing about anymore, though.

Also, never base your code style around the crankiest member of the team. You’re just feeding their crankery, and eventually they’ll be spending a summer rewriting all your code to use their own arcane system of typedefs.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Xarn posted:

I don't think you can typedef enable-ifs

#define doesn’t care about your templates

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug
This isn't exactly a horror but it is very irritating to me and has been driving me crazy, and the thread's been dead for a while.

I'm working on a project that's a python based CLI tool; using click as the main framework. The guy who put the design together for it did a reasonably good job, except that he's clearly a Java dev, and he's implemented some patterns that are driving me crazy.

Some background for those of you not familiar with Python: Python is an OOP language, but it's not as strict as Java or C#, and it has a lot of odd quirks if you're coming from those languages. For example, in Java (and many other languages) you have private object attributes, generally denoted by a _ before the name. If you create a ThingHandler object, you won't be able to access any private object attributes at all, only the object itself can interact with these. To expose one of these attributes, you generally use a getter/setter pattern where you have a public attribute that then gets or sets the private attribute.

Python retains this practice, but there's no actual implementation; you still preface all messy internal logic stuff with _ but it just mostly is there as a warning - 'Hey, please do not gently caress with this, even though I cannot stop you.' and is a good way to get your Github issue closed quickly.

So what does that have to do with coding horrors? Well, dear friends, here is how he set up the very first example class in the suite:

Python code:

class ThingToucher:
	_this_is_a_list: List[str]
	_this_is_another_list: List[str]
	_this_is_a_bool: bool
	_this_is_a_str: str
	
	@property
	def this_is_a_list(self):
		if not self._this_is_a_list:
			self._this_is_a_list = list()
		return self._this_is_a_list
	
	@this_is_a_list.setter
	def this_is_a_list(self, value):
		self._this_is_a_list = value
	
	@property
	def this_is_another_list(self):
		if not self._this_is_another_list:
			self._this_is_another_list = list()
		return self._this_is_another_list
	
	@this_is_another_list.setter
	def this_is_another_list(self, value):
		self._this_is_another_list = value
		
	@property
	def this_is_a_bool(self):
		if not self._this_is_a_bool:
			self._this_is_a_bool = True
		return self._this_is_a_bool
	
	@this_is_a_bool.setter
	def this_is_a_bool(self, value):
		self._this_is_a_bool = value
		
	@property
	def this_is_a_str(self):
		if not self._this_is_a_str:
			self._this_is_a_str = ""
		return self._this_is_a_str
	
	@this_is_a_str.setter
	def this_is_a_str(self, value):
		self._this_is_a_str = value

Please note that the above code is functionally identical to this code:
Python code:
class ThingToucher:
	this_is_a_list: List[str]
	this_is_another_list: List[str]
	this_is_a_bool: bool
	this_is_a_str: str
	
	def __init__(self, list, listtwo, bool_val, str_val):
		self.this_is_a_list = list
		self.this_is_another_list = listtwo
		self.this_is_a_bool = bool_val
		self.this_is_a_str = str_val
OH AND ALSO WE DON'T HAVE FOUR VALUES, WE HAVE LIKE EIGHT. IT'S A HUNDRED loving LINES OF CODE THAT DOES NOTHING AT ALL.

I should note that I am not exaggerating. None of them have any side effects. None of them do anything useful. They just expose the :airquote:"private":airquote: variables through this pattern - and on top of that, these aren't inherited anywhere! They're not for reuse! Nobody else other than this program will ever use or touch them! I raised concerns early on and was told "oh no this is the best way to write this, because it doesn't evaluate on creation" and I backed off because I was very new to the team and didn't want to ruffle any feathers.

I should have set something on fire.

We have about a dozen people working on this project, many of them just for one feature and then leaving, and everyone has cargo culted this into their code as well. I've given up trying to get them to fix it either. People just refuse. They can't explain why, they just go 'well I already put it in.'

We're just hitting feature complete for the phase and I'm going to go in and remove every single loving instance of this in a PR here shortly and by god if anyone argues with me I'm pushing them out a window and finding another reviewer, until we either run out of developers, run out of windows, or it gets merged.

Edit: oh also he didn't use type hints anywhere at all, and so not only is this all extremely verbose, it's impossible to parse through an IDE. I've been going through and adding them everywhere as I push changes, but it's a huge pain in the rear end.

QuarkJets
Sep 8, 2008

Falcon2001 posted:

OH AND ALSO WE DON'T HAVE FOUR VALUES, WE HAVE LIKE EIGHT. IT'S A HUNDRED loving LINES OF CODE THAT DOES NOTHING AT ALL.

Yup, that's a Java developer

Beef
Jul 26, 2004
Another cargo cult Java dev brain damage story:

I was told once that I should put each of my python functions in a separate file, because that's more modular.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Beef posted:

Another cargo cult Java dev brain damage story:

I was told once that I should put each of my python functions in a separate file, because that's more modular.

In C putting each function in a separate translation unit helps with code size reduction :eng101:

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

Falcon2001 posted:



Python code:

class ThingToucher:
	...
	_this_is_a_bool: bool
	...
	@property
	def this_is_a_bool(self):
		if not self._this_is_a_bool:
			self._this_is_a_bool = True
		return self._this_is_a_bool
	
	...


just so you know, and obviously it might not be present in the real thing since this is just an example, but that `if` will fire if the bool is false as well as none

smackfu
Jun 7, 2004

Love mixing snake case with underscore prefixes. Super clear code.

Chin Strap
Nov 24, 2002

I failed my TFLC Toxx, but I no longer need a double chin strap :buddy:
Pillbug

smackfu posted:

Love mixing snake case with underscore prefixes. Super clear code.

That's fine and common python style.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

quote:

in Java (and many other languages) you have private object attributes, generally denoted by a _ before the name.

This is actually not true for Java, although it may be for some other languages. The official Java style guide states:

quote:

Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed.

Your coworker is just brain poisoned by C.

MrMoo
Sep 14, 2000

It’s wrong in most languages as an underscore prefix is reserved for the compiler vendor

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug
Well poo poo that underscore part is probably me being wrong. Or if it they way in csharp?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Falcon2001 posted:

Well poo poo that underscore part is probably me being wrong. Or if it they way in csharp?

This is a C# thing, yeah.

Dijkstracula fucked around with this message at 17:42 on Jul 1, 2023

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I've seen leading (or trailing, lol c++) underscore as a marker for "private" in all the languages mentioned so far. Seemed common to me, though not at all universal.

MrMoo posted:

It’s wrong in most languages as an underscore prefix is reserved for the compiler vendor

C++ contains multitudes but calling it "most languages" is a bit much.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Beef posted:

Another cargo cult Java dev brain damage story:

I was told once that I should put each of my python functions in a separate file, because that's more modular.

that’s not even a thing in java!

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug

Soricidus posted:

that’s not even a thing in java!

I mean the one class per file is a Java thing though right? And in Java you can't have just a function hanging out by itself, it has to be contained within a class, so probably that's where that particular brainworm comes from.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I guess there was the "one method per class" idea which would result in one method per file, but that was one of the more insane OO things that didn't catch on.

MrMoo
Sep 14, 2000

pokeyman posted:

I've seen leading (or trailing, lol c++) underscore as a marker for "private" in all the languages mentioned so far.

Trailing underscore precisely because of the conflict with the vendor, i.e. random poo poo in headers. Other languages often carry the baggage of C and C++ in mindset, which also includes the silly m_ prefix.

Fortran posted:

All Fortran library procedure names have double leading underscores to reduce clashes with user-assigned subroutine names.

Python posted:

__var__ : double leading and trailing underscore variables (at least two leading and trailing underscores). Also called dunders. This naming convention is used by python to define variables internally. Avoid using this convention to prevent name conflicts that could arise with python updates.

I've seen a superbly amazing ex-Googler use underscores for all variables in bash of all things, :wtf:

Ironically underscore as a leading prefix for private scope comes from C itself,

Perl posted:

A utility subroutine exists only to simplify the implementation of a module or class. It is never supposed to be exported from its module, nor ever to be used in client code.

Always use an underscore as the first “letter” of any utility subroutine’s name. A leading underscore is ugly and unusual and reserved (by ancient C/Unix convention) for non-public components of a system. The presence of a leading underscore in a subroutine call makes it immediately obvious when part of the implementation has been mistaken for part of the interface.

MrMoo fucked around with this message at 21:00 on Jul 1, 2023

Adbot
ADBOT LOVES YOU

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

MrMoo posted:

Trailing underscore precisely because of the conflict with the vendor, i.e. random poo poo in headers. Other languages often carry the baggage of C and C++ in mindset, which also includes the silly m_ prefix.



I've seen a superbly amazing ex-Googler use underscores for all variables in bash of all things, :wtf:

Ironically underscore as a leading prefix for private scope comes from C itself,

C has static for TR-scoped things, it doesn't need dumb underscore rules for fake static.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply