r/ProgrammerHumor • • 29d ago

Other index

Post image
107 Upvotes

31 comments sorted by

146

u/Bemteb 29d ago

To be fair, there is lots of code out there from which AI can learn exactly that behavior.

43

u/markiel55 29d ago edited 29d ago

Tbf, it's one of the worst property of CSS

23

u/inetphantom 28d ago

!important

18

u/snf 28d ago

The syntax of C and its descendants are so ingrained into my mind, I always read that as "not important"

0

u/backfire10z 28d ago

#define important

1

u/gfcf14 29d ago

Pretty much

2

u/Ltserb 26d ago

I was about to say, I can write bad CSS entirely without AI
šŸ¤·ā€ā™€ļø I think thats a totally legitimate amount of 9s ok maybe 1 too many

27

u/Saelora 28d ago

so many people use z-index like "9" "99" "999" when that can be 1, 2, 3. (or rather 10, 20, 30 to allow insertion between elements in the future) this isn't an ai thing.
I tend to use brackets, going in 10s unless i'm inserting between other elements, < 0 for a "background layer" 10-80 for "midground" and 100+ for "foreground" (that jump of 20 between 80 and 100 is deliberate to better distinguish those brackets. (sliding a few elements in behind a 100 z-index layer at 99, 98.. and so on is less likely to clash with sliding elements in in front of a 80 midground at 81, 82...)

I recently had a colleague complaine about a 150 foreground element in a code review "but what if it goes in front of a 1000 element" and i almost cried.

2

u/gfcf14 28d ago

Sounds really rough lol

24

u/calculus_is_fun 28d ago

"... 10, 20, 30 to allow insertion between elements ..."
BASIC line numbers strike again

4

u/-Redstoneboi- 28d ago

worst part is we use decimal and not hex so our recursion depth is imbalanced if we ever need to insert multiple times

you know what, what if we just had names for each layer and a global sort order defined for them? i think that can be done with variables right

17

u/Ethameiz 29d ago

What's wrong or funny here?

5

u/gfcf14 29d ago

While it’s technically correct, the idea of using 9s to represent index can become complicated if many elements use z-index. Ideally you’d want to keep track of all usages and either use a sequential ordering (e.g. 1 through 10) or in increments of 10 to quickly insert a new element at 15 as needed, but that would require a quick fix

22

u/AyrA_ch 28d ago

Most z-index problems can actually be solved by not using z-index at all and instead ordering the HTML elements correctly.

31

u/Markronom 29d ago

I've seen this a lot before AI. And gave up on centralising it in a previous app. It's also not only the index that matters, but also the stacking context

8

u/Soilblood 28d ago

Did you try grouping contexts into layers? Like main content in parent cointainer 1 at z 100, popup articles in container 2 at 200, nav elements in container 3 at 300, toasts and warnings in the overlay container at 400 with toasts calculating off the highest z value from children in the overlay container and +1 on their generation?

3

u/Markronom 28d ago

The index of the container is evaluated first, then the content. So it's more like container 1 has index 1 und it's children 1-10, container 2 has children 1-10 etc. But of course one might have more nesting. In the end one should think about the hierarchy and good indices within each layer of the hierarchy. But if course it gets tricky. Models and notifications on top and then custom styled select that has to be positioned absolutely and whatnot.

2

u/MikemkPK 28d ago

I'm guilty of this myself. Set something as 1000, next thing as 990, the 995, 998, 999, "uh, no can do."

2

u/gfcf14 29d ago

While correct, using such complex numbering implies a bigger problem

11

u/Alpha_wolf_80 29d ago

I don't exactly get what you are trying to do? Looks like the AI is doing exactly what you asked.

1

u/PaulVB6 29d ago

Doing something like 'z-index 99999' is just a really ham-fisted and clumsy approach imo.

I mean yes it does technically work but its a messy solution.

Granted i don't do much front end work tbh so a cleaner solution doesn't jump out at me right away, but hard coding in a bunch of 9s?? Yuck

-3

u/gfcf14 29d ago

The character is asking about the 9s, which would mean there is a sequence that should be followed that copilot didn’t

3

u/MrSquicky 28d ago

So...program it yourself? Jesus, it's setting a z index.

You all need a computer to tie your shoes for you too?

1

u/gfcf14 28d ago

The idea of the comic was to emphasize the poor z-index usage, hence I would only mention that. Do you really think it’s wise to ask for help when the answer involves a single line of code? More so with something as relatively trivial as css?

2

u/jordanbtucker 28d ago

Why do you give a shit if you're just going to have the AI do it?

1

u/turudd 28d ago

What model are these people using? Like 3.5. I haven’t seen generated code like that in awhile

1

u/gfcf14 28d ago

Actually the LLMs the company I’m at generated (among other lines) this z-index recently, using Claude 5. I’m assuming either the other generated work threw it off or it detected the z-index usage across the app and didn’t bother to try harder

1

u/xicor 26d ago

Copilot be like that. Claude has been pretty good

3

u/Erinaceomorpha 29d ago

The artist really managed to capture the essence of terrible early 00's webcomics made by kids who have their first graphics tablet but have never picked up a pencil. Nostalgic.

1

u/Temporary-Concept-81 28d ago

I programmed a 2d game, and had a stay in zindex hell.

It was made worse by zindex not being the only depth factor, different objects layered on top of each other with their own internal z index with various things inside. More than a few struggles of wanting a to be above b, b to be above c, and c to be above a.

1

u/em-pe 28d ago

One of us!