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
Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Look at all these people here posting about how great unions are, completely fearless about being fired for organizing.

Adbot
ADBOT LOVES YOU

Carbon dioxide
Oct 9, 2012

Volmarias posted:

Look at all these people here posting about how great unions are, completely fearless about being fired for organizing.

Don't worry we're all European.

Ola
Jul 19, 2004

Volmarias posted:

Look at all these people here posting about how great unions are, completely fearless about being fired for organizing.

Oh no, are you part of a discriminated union?

feedmegin
Jul 30, 2008

Brain Candy posted:

Nah, tying your your serialization to an architecture and a particular compiler is usually a bad plan OP.

I mean, there are literally two architectures anyone gives a poo poo about now, and the compiler will usually follow the architecture (and/or relevant ABI) when it comes to structure layout. Also, depending on what you're doing you may not care about cross-architecture or cross-compiler compatibility anyway.

more falafel please
Feb 26, 2005

forums poster

There are ways to ensure that your representation (for a network or file format, for instance, which you may not have control over the specification of) will be accurate for all architectures/compilers you care about, with compile-time verification.

This argument usually comes down to "you should never need to care about the exact memory layout of your data" which is just patently false. There are lots of times when I need to do exactly that.

I also don't need my programs to run on all possible architectures or build on all possible compilers. I need them to build on two architectures, with two compilers, for four operating systems. Those are very concrete numbers, and it's extremely possible to make your code explicitly refuse to compile if you're trying to build it for something else without describing how.

No one is saying your front end webdev should use C-style unions, but not all of us are front end web devs.

Presto
Nov 22, 2002

Keep calm and Harry on.

Foxfire_ posted:

Using the same space to hold two different things in C/C++ is generally better accomplished with a char array and memcpys.
C++ has variants now, which are like unions that know what type they're holding.

feedmegin
Jul 30, 2008

more falafel please posted:

I also don't need my programs to run on all possible architectures or build on all possible compilers. I need them to build on two architectures, with two compilers, for four operating systems. Those are very concrete numbers, and it's extremely possible to make your code explicitly refuse to compile if you're trying to build it for something else without describing how.

Noone is saying nobody at all should care about this stuff, but there are some of us who need to build on one architecture, with one compiler, for one operating system, which are also very concrete numbers, and in that case this sort of thing can work just fine.

Edit: wait, I think you're loudly agreeing with me anyway :shobon:

Tei
Feb 19, 2011

Converting from littelendian to bigendian seems to be quick.

Once is set that a file format is written in one style, your code just convert it to the style you can read on the fly.

https://stackoverflow.com/questions/13001183/how-to-read-little-endian-integers-from-file-in-c

Is not a big issue, I think.

Maybe is more a issue if you have to deal with random fragments of binary data of unknowm origin. That would only happen if you are ... I don't know,... reverse engineering videgames data files. But at that point you are already a hacker that can figure things by yourself.

feedmegin
Jul 30, 2008

Tei posted:

Converting from littelendian to bigendian seems to be quick.

This is what I'm saying when I say there are only two architectures people care about any more - well, more accurately, three. X86-64 and ARM (Thumb if you're in microcontroller land, AArch64 if not). All of these are little endian. Little endian won. You will most likely never need to work with big endian hardware in 2021. The only reason we still have to care about it is that Sun were big endian and defined a bunch of internet protocols and apis in the 90s, hence all that htons/ntohs nonsense in libc.

That's not all there is to worry about though, between alignment rules and e.g. what is sizeof(long int).

more falafel please
Feb 26, 2005

forums poster

feedmegin posted:

This is what I'm saying when I say there are only two architectures people care about any more - well, more accurately, three. X86-64 and ARM (Thumb if you're in microcontroller land, AArch64 if not). All of these are little endian. Little endian won. You will most likely never need to work with big endian hardware in 2021. The only reason we still have to care about it is that Sun were big endian and defined a bunch of internet protocols and apis in the 90s, hence all that htons/ntohs nonsense in libc.

That's not all there is to worry about though, between alignment rules and e.g. what is sizeof(long int).

Right, I still do have to care about endian sometimes (moreso in the last console generation, but it's still sometimes relevant for network transmission), but I generally speaking don't use "long int", I use "int32_t" or equivalent, depending on how big of an integer I want. These are defined in platform headers (and if they're not for some reason, they're trivial to define yourself).

My point is that lots of "undefined behavior" is undefined by the language standards, not by the actual discrete tools/architectures/platforms you're using. The argument that you can't use these tools safely is the problem -- you just need to know precisely what is going to happen, which, in these situations, you already need to know.

Foxfire_
Nov 8, 2010

more falafel please posted:

My point is that lots of "undefined behavior" is undefined by the language standards, not by the actual discrete tools/architectures/platforms you're using. The argument that you can't use these tools safely is the problem -- you just need to know precisely what is going to happen, which, in these situations, you already need to know.
C/C++ undefined behavior has a specific meaning: "You may not legally do this, but nothing is obligated to give you an error if you do anyway."

The reasoning is generally not because of uncertainty about what actually happens on the platform, it's for what can be assumed about the program. A compiler will have a library of optimizing transformation techniques that provably don't change the output under all inputs, but the proofs use assumptions that a legal program may never do some stuff. If you violate those assumptions, the transformed program might produce different output, sometimes.

For example, signed integer overflow is undefined behavior in C. Any actual compiler knows what chip it's emitting assembly for and what actually happens on overflow. You still can't overflow a signed value in a C program and expect things to work because the optimizing transformations are designed with the assumption that "(X + 1) > X" is always true if X is signed. If you do overflow anyway, you might or might not get what you expect depending on if any transformation that got applied to that piece of code in particular relied on that assumption for its correctness.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Type layout is not undefined, it's just implementation-defined.

You can absolutely use C structs for precise binary layouts. Doing so does sometimes mean it'll take extra work to bring up a new port, but it's not necessarily less work than writing a byte-stream deserializer would've been. You can even make bit-fields work portably, although that can be a huge pain in the rear end and sometimes requires you to declare your bit-fields in a different order on different platforms.

Brain Candy
May 18, 2006

feedmegin posted:

I mean, there are literally two architectures anyone gives a poo poo about now, and the compiler will usually follow the architecture (and/or relevant ABI) when it comes to structure layout. Also, depending on what you're doing you may not care about cross-architecture or cross-compiler compatibility anyway.

I'm trying to retroactively convince whoever did this to me with twelve bit words to not.

csammis
Aug 26, 2003

Mental Institution
“Hey csammis, we need you to take over this feature. The guy who wrote it is gone and the guy who tried to fix it can’t get it finished.”

It’s all C++-without-classes functions with no fewer than 21 parameters, some of which are references to pointers to objects with still more parameters.

I think I know why the feature’s been orphaned

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.

csammis posted:

“Hey csammis, we need you to take over this feature. The guy who wrote it is gone and the guy who tried to fix it can’t get it finished.”

It’s all C++-without-classes functions with no fewer than 21 parameters, some of which are references to pointers to objects with still more parameters.

I think I know why the feature’s been orphaned

is there code review at your company?

csammis
Aug 26, 2003

Mental Institution
The person who approved the feature is also no longer with the company :v:

Volmarias
Dec 31, 2002

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

csammis posted:

“Hey csammis, we need you to take over this feature. The guy who wrote it is gone and the guy who tried to fix it can’t get it finished.”

It’s all C++-without-classes functions with no fewer than 21 parameters, some of which are references to pointers to objects with still more parameters.

I think I know why the feature’s been orphaned

:wtc:

On the plus side, it sounds like you have a great chance to refactor things. On the negative side, this sounds like a horrific house of cards except that the cards are actually spiders and there's almost certain to be pointer arithmetic in there that makes Assumptions about the nature of structs it is given.

I hope you had a very delicate conversation with your boss about how this is going to require an outsized amount of time, either in fixing it, or completely rewriting it.

Tei
Feb 19, 2011

csammis posted:

“Hey csammis, we need you to take over this feature. The guy who wrote it is gone and the guy who tried to fix it can’t get it finished.”

It’s all C++-without-classes functions with no fewer than 21 parameters, some of which are references to pointers to objects with still more parameters.

I think I know why the feature’s been orphaned

It sounds that code is pure poo poo. It started has something really bad, and then it was downhill from there.

It would be fun to document how is actually used. Maybe you can mark the methods that are really in use.

If more than two methods are in use, then is not this module, the whole codebase is dumb poo poo.

Ola
Jul 19, 2004

When I use the wrong API key, the vendor I'm integrating with returns:

code:
OK 200

<html>
  <head>
    Error 500
  </head>
  <body>
    Internal Server Error
  </body>
</html>

Ola fucked around with this message at 11:48 on Jun 22, 2021

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?
Didn’t even close his tags properly

Ola
Jul 19, 2004

DoctorTristan posted:

Didn’t even close his tags properly

I knew I should have copy/pasted the actual thing.

SirViver
Oct 22, 2008
I'd say that's a perfectly fine QuirksMode response. The HTML spec is just a suggestion anyway, right?

csammis
Aug 26, 2003

Mental Institution

Volmarias posted:

I hope you had a very delicate conversation with your boss about how this is going to require an outsized amount of time, either in fixing it, or completely rewriting it.

In fact the opposite! It’s so loving bad that my boss convinced the product manager that it is absolutely critical that we refactor or rewrite this before adding the new pieces they want because multiple engineers have taken a stab at it and failed. It’s the textbook definition of unmaintainable and it’s a pretty important feature for the product. I was asked to be the fixer and given five months.

Tei posted:

It would be fun to document how is actually used. Maybe you can mark the methods that are really in use.

This is how I started yesterday - I was hoping I could just begin by cutting entire chunks. No such luck.

quote:

the whole codebase is dumb poo poo.

In all of the rest of my company’s engineers’ defense, the vast vast vast majority of our codebase does not look like this. The feature in question is thankfully not foundational. If it were, :sever:

Macichne Leainig
Jul 26, 2012

by VG
Morning status update from my offshore team:

"Hey Protocol7. We had some issues updating rows in this table, so we removed the primary key and now everything's working."

:wtfdude:

Yeah I'm sure that was the only option.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Protocol7 posted:

Morning status update from my offshore team:

"Hey Protocol7. We had some issues updating rows in this table, so we removed the primary key and now everything's working."

:wtfdude:

Please tell me there's a backup. :negative:

Macichne Leainig
Jul 26, 2012

by VG

Absurd Alhazred posted:

Please tell me there's a backup. :negative:

There is only one significant reason I have backups enabled and you're reading about it! :v:

Macichne Leainig
Jul 26, 2012

by VG
- wow I'm bad at forums this morning

Volmarias
Dec 31, 2002

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

Protocol7 posted:

Morning status update from my offshore team:

"Hey Protocol7. We had some issues updating rows in this table, so we removed the primary key and now everything's working."

:wtfdude:

Yeah I'm sure that was the only option.

:rip:

ChickenWing
Jul 22, 2010

:v:

Protocol7 posted:

"Hey Protocol7. We had some issues updating rows in this table, so we removed the primary key and now everything's working."

:catstare:

In what universe is this a logical choice


Like, I've worked with some iffy devs, but how in the goddamn gently caress

SirViver
Oct 22, 2008
"We had issues when deleting some rows, but the problem has now been resolved. We executed following statement:

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all""

zokie
Feb 13, 2006

Out of many, Sweden
Why are they allowed to touch the schema?

Macichne Leainig
Jul 26, 2012

by VG

zokie posted:

Why are they allowed to touch the schema?

Oh they are certainly not anymore, don't worry. We're starting to hire more on-shore guys and we're brainstorming how to properly un-gently caress things like this (and that includes restricting their access to things they have shown they can't be trusted with). But until we have enough on-shore developers that we can fully cut off the offshore team, things like this are gonna pop up now and then.

I even spoke to the web designer guy on our team who's often present at our meetings like this, and he's like "yeah, even I know that's a no-no."

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...
A day in the life of a professional software engineer

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Protocol7 posted:

Oh they are certainly not anymore, don't worry. We're starting to hire more on-shore guys and we're brainstorming how to properly un-gently caress things like this (and that includes restricting their access to things they have shown they can't be trusted with). But until we have enough on-shore developers that we can fully cut off the offshore team, things like this are gonna pop up now and then.

I even spoke to the web designer guy on our team who's often present at our meetings like this, and he's like "yeah, even I know that's a no-no."

This particular type of problem is easily solved by revoking everyone's access to environments and having all changes go out through continuous delivery, with required PR approvals prior to merging to a branch that gets rolled out.

If people have access to an environment, they will do dumb poo poo to that environment both by accident and on purpose.

Volguus
Mar 3, 2009

New Yorp New Yorp posted:

This particular type of problem is easily solved by revoking everyone's access to environments and having all changes go out through continuous delivery, with required PR approvals prior to merging to a branch that gets rolled out.

If people have access to an environment, they will do dumb poo poo to that environment both by accident and on purpose.

Sure, but then they complain about all the red tape for every single little change. "I only wanted to add one more row to the X table". And after a bunch of years without incidents: "Hey, nothing will happen, just let me do my thing". Now, the red tape is at least justified. The incident was needed.

I would blow Dane Cook
Dec 26, 2008
Someone just asked me to help with their Command Prompt batch file. They had two lines in a text file, each about 14,000 characters long that their batch file wasn't reading properly. I said there might be an escape character in there and wished him good luck.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



csammis posted:

no longer with the company

I'm assuming this is a euphemism for "was assassinated simultaneously by all of their co-workers Julius Caesar style"

SirViver posted:

I'd say that's a perfectly fine QuirksMode response. The HTML spec is just a suggestion anyway, right?

Having done web dev for over a decade, I can confidently say that the HTML spec is, charitably, a pernicious rumor.

Volmarias
Dec 31, 2002

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

Volguus posted:

Sure, but then they complain about all the red tape for every single little change. "I only wanted to add one more row to the X table". And after a bunch of years without incidents: "Hey, nothing will happen, just let me do my thing". Now, the red tape is at least justified. The incident was needed.

I think it's possible to give table permissions for add/update/delete without giving permissions for Alter Table and the like.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Munkeymon posted:

Having done web dev for over a decade, I can confidently say that the HTML spec is, charitably, a pernicious rumor.

I found the HTML spec (a) shockingly thorough (description of a giant gross mess).

Adbot
ADBOT LOVES YOU

xtal
Jan 9, 2011

by Fluffdaddy
The HTML 5 spec is a thorough description of horrors. Before HTML 5 to call it a spec was stretching the truth a bit.

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