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
Hughlander
May 11, 2005

Scaramouche posted:

Hah I remember inlining ASM into Turbo Pascal. Now that was a feature!

It wasn't until I believe 2012 that I worked on a game that didn't have some inline assembly somewhere in the code, and that was because it was for iOS.

It was really liberating to just drop
code:
__asm { int 3 } 
Into some code and let it run for a time...

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hughlander posted:

It wasn't until I believe 2012 that I worked on a game that didn't have some inline assembly somewhere in the code, and that was because it was for iOS.

What’s the connection?

Hughlander
May 11, 2005

pokeyman posted:

What’s the connection?

Most assembly was for graphics initialization, networking, or input. iOS just did it all in Objective-C. Even the 360 and PS3 titles I worked on had some Power PC to get to the title screen.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Telerik

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Hughlander posted:

Most assembly was for graphics initialization, networking, or input. iOS just did it all in Objective-C. Even the 360 and PS3 titles I worked on had some Power PC to get to the title screen.

Cool. For some reason I was thinking "does iOS somehow co-opt inline assembly? Was it too annoying to deal with multiple architectures?" and it wasn’t making sense.

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

My personal angst is towards Infragistics.
Many colleagues loathe DevExpress.

It begs the question : are there actually any good UI Component libraries out there?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
AppKit. UIKit.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Found out today that one of our in-house libraries (not all that widely-used) contains a type T that implements IEquatable<T> and

1) the Equals(T other) method isn't transitive
2) it's possible for T t1 and T t2 to satisfy t1.Equals(t2) && t1.GetHashCode() != t2.GetHashCode()

It's not clear whether anything is going to be broken if we just get rid of the implementation of IEquatable<>, so I am just adding ObsoleteAttribute to relevant methods, adding Debug.Assert(false) statements so uses get caught when code is run in debug, and making sure that the unit tests in the project I'm working on can run in debug without asserting...

(This type has been this way since 2013)

CPColin
Sep 9, 2003

Big ol' smile.
That's like when I noticed that a couple of our classes' equals() methods looked like this:
code:
return name.equals(other.name) && super.equals(other)
with super.equals() being Object.equals(), which only ever returns true for the exact same object. Nobody never noticed because none of the rest of code was ever checking instances of these classes for equality. (So why did my predecessor write these methods in the first place??)

Magissima
Apr 15, 2013

I'd like to introduce you to some of the most special of our rocks and minerals.
Soiled Meat
We also have a shitload of equals() instances that are probably never used but everyone's scared to change, even when fields are added. There are quite a few "hasSameContents()" and the like floating around as a result.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If there isn't a single and unambiguous possible definition of equals, you shouldn't be overriding equals. (And as a corollary, since identity is a reasonable definition for anything mutable, you should never override equals for a mutable type).

Define an IEqualityComparer instead that people can use when they want this specific definition.

xtal
Jan 9, 2011

by Fluffdaddy
Is there a good reason to overload equals instead of just defining a separate comparison function? Besides using an API that uses equals under the hood?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Jabor posted:

If there isn't a single and unambiguous possible definition of equals, you shouldn't be overriding equals. (And as a corollary, since identity is a reasonable definition for anything mutable, you should never override equals for a mutable type).

Define an IEqualityComparer instead that people can use when they want this specific definition.

Who is this aimed at? I'm aware of all this.

The class should not have implemented IEquatable<T>. It should have had a NearEnough(T other, double tolerance).

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
In other exciting news (I just discovered this): our unit tests were not assert-clean to start with! How enjoyable!

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.
Ugh digging through the app I've inherited and every. single. one. of the few hundred tests is a snapshot test. So if any tests are failing, I can just regenerate the snapshots and they magically all pass. And there is a handwritten copy of the model of the initial application state in the tests directory, rather than the tests using the actual model of the initial application state.

sunaurus
Feb 13, 2012

Oh great, another bookah.

RobertKerans posted:

Ugh digging through the app I've inherited and every. single. one. of the few hundred tests is a snapshot test. So if any tests are failing, I can just regenerate the snapshots and they magically all pass. And there is a handwritten copy of the model of the initial application state in the tests directory, rather than the tests using the actual model of the initial application state.

Snapshot tests are great. If you make a mistake when regenerating a failing snapshot, surely that will get caught in code review?

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.

sunaurus posted:

Snapshot tests are great. If you make a mistake when regenerating a failing snapshot, surely that will get caught in code review?

They're fantastic for smoke testing components, and I'm glad they're there for that. But the majority of them are for the Redux app. I just...ugh...that's not where I want them snapshots to be. We told the agency who were building the MVP of the app to add in tests, and this is the result. Each of those snapshots run against the root reducer, not the individual slices: that seems to have enabled them to just basically copy-paste the same snapshot test a couple hundred times and change the action going into it on each one. Then backed it with that mocked handwritten version of the initial state of the reducer rather than the actual initial state (which is a thing I want to know is correct! Why the gently caress would you make a pretend version of it)

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat
cmon people please

php:
<?
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];?>

necrotic
Aug 2, 2005
I owe my brother big time for this!
What's a leap year anyway?

Ola
Jul 19, 2004

streetlamp posted:

cmon people please

php:
<?
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];?>

It should of course be

php:
<?
var DAYS_IN_MONTHS_4_YEARS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
];?>

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat
hey it works most years? at least?

CPColin
Sep 9, 2003

Big ol' smile.
2100 is somebody else's problem

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

Ola posted:

It should of course be

php:
<?
var DAYS_IN_MONTHS_4_YEARS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
];?>

gonna need to spend a while writing out DAYS_IN_MONTHS_400_YEARS if you really want it to be correct though

Ola
Jul 19, 2004

CPColin posted:

2100 is somebody else's problem

*sigh*

php:
<?
var DAYS_IN_MONTHS_C_YEARS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
                              31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
];?>

quote:

...unless the year is divisible by 400...

Fuuuuuuuuuuuuuuck. If only there was some way you could calculate this.

streetlamp
May 7, 2007

Danny likes his party hat
He does not like his banana hat
nailed it, you got the job

Ola
Jul 19, 2004

What actually happens when you store the correct sequence is that your code eventually starts it from the wrong place.

xtal
Jan 9, 2011

by Fluffdaddy

Ola posted:

What actually happens when you store the correct sequence is that your code eventually starts it from the wrong place.

Arrays indexed by month should have a null value at the beginning so you can write `array[getCurrentMonth()]`, which everybody is going to write eventually anyway, but as a bug.

Doom Mathematic
Sep 2, 2008
Galaxy brain:

PHP code:
// feb is special case
var DAYS_IN_MONTH = [31, 30, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
(Two hours later, you ascertain that no, despite the comment, there is no special-case code for February.)

CPColin
Sep 9, 2003

Big ol' smile.
code:
var KNUCKLES = [big, little, big, little, big, little, big];
var MONTHS = KNUCKLES.repeat(2).take(12);
wait

code:
var MONTHS = KNUCKLES.repeat(TWICE).take(MONTHS_PER_YEAR);
there we go

Ola
Jul 19, 2004

CPColin posted:

code:
var KNUCKLES = [big, little, big, little, big, little, big];
var MONTHS = KNUCKLES.repeat(2).take(12);
wait

code:
var MONTHS = KNUCKLES.repeat(TWICE).take(MONTHS_PER_YEAR);
there we go

Hahaha, knuckles should be a standard sequence unit.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

This last page is one of the reasons I love this thread and by extension, dead gay forum

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Scaramouche posted:

This last page is one of the reasons I love this thread and by extension, dead gay forum

it's all fun and games until someone complains that your product is reporting infant ages incorrectly and then you find a five hundred line long function that tries to calculate how many days are between two different dates.

VikingofRock
Aug 24, 2008




Bruegels Fuckbooks posted:

it's all fun and games until someone complains that your product is reporting infant ages incorrectly and then you find a five hundred line long function that tries to calculate how many days are between two different dates.

That's when you get to write one of those fun -500/+3 pull requests by replacing this all with a call to an appropriate datetime library.

steckles
Jan 14, 2006

VikingofRock posted:

That's when you get to write one of those fun -500/+3 pull requests by replacing this all with a call to an appropriate datetime library.
Request denied. Reason: The old code is “burnt in”. I’ve heard that one used a few times to justify the continued existence of some of the deeper, stranger places in our codebase.

canis minor
May 4, 2011

I found this: https://zygoloid.github.io/cppcontest2018.html entertaining

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

VikingofRock posted:

That's when you get to write one of those fun -500/+3 pull requests by replacing this all with a call to an appropriate datetime library.

yeah but it's medical software and there was pearl clutching about potential safety issues so that generated literally hundreds of emails for something that ended up being a three line fix.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Today I discovered that there's no guarantee for constexpr to be actually computed at compile time and MSVC will just give up and compute it at runtime if it's too hard. No way to turn that into an error afaict though.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Can I also request to the C++ guys for controls and hints for execution performance? If your dumb autovectorizer fails that should be a compile error rather than compiling to slower code.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
You're allowed to have a constexpr function that returns a compile-time constant if passed compile-time-constant arguments but just gets called normally if passed variable / runtime values.
They up and added the consteval keyword to the language to do what constexpr sounds like it's *supposed* to do.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Suspicious Dish posted:

Can I also request to the C++ guys for controls and hints for execution performance? If your dumb autovectorizer fails that should be a compile error rather than compiling to slower code.

/Qvec-report:2 will tell you if things failed to autovectorize but I don't think that can be enabled just for specific loops that you're expecting to be vectorized.

Suspicious Dish posted:

Today I discovered that there's no guarantee for constexpr to be actually computed at compile time and MSVC will just give up and compute it at runtime if it's too hard. No way to turn that into an error afaict though.

constexpr just means that it can be called in places which require a constant expression.

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