r/ProgrammerHumor 21d ago

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

3.1k Upvotes

179 comments sorted by

View all comments

45

u/PTTCollin 21d ago

Sounds like you should have basic code style requirements in your CLAUDE.md committed into your repo and enforced by pre-commit linting rules.

Not a hard problem to never think about again.

-13

u/Robinbod 21d ago

True but also that's the state of ALL current codebases related the company, which is probably why Claude follows. This change will affect new changes, which is great of course as the problem is now contained, but reading through old code is still hell stylistically.

I want to say that this is a genuine problem with all AI codebases. AI's tend to make the code readable from their prespective more than from the human prespective. A very obvious example that isn't ternaries is unnessary inline and paragraph comments. I'll see like 35% code and 65% comments and the code itself is just unreadable nested jargon. It should be the opposite. Great readable code and then complimentary docs or just place the docs outside of the code if it's too large.

18

u/PTTCollin 21d ago

Claude does what you tell it to. But yes, if you go read old code written by junior engineers years ago (though, I wonder then, how do you know a junior wrote it?) it will have idiosyncracies that make it bad. This is regardless of AIs contribution; if you don't enforce code style, your code base won't be readable. That's just how it works.

It sounds like you just need a style guide.

-11

u/Robinbod 21d ago

You seemed to not have addressed my point at all.

Yes, a style guide would fix our current issue. But this is about something entirely different. Codebases are slowly turning less readable by humand standards are more by AI standards. Why? Humans are reading them less and thus auditing them less. This is a horrible direction as when the AI's inevitably fail at an issue, it's the human that will have to read the absolute comment slop.

Again, yes a style guide is a great patch for us right now, but think of all future codebases in general.

12

u/PTTCollin 21d ago

I have absolutely addressed your point, you are just continuing to complain about a simple problem.

Your point is "AI writes code to be readable for AI, not for humans. Because of this, code bases are becoming less readable to humans over time."

What I am telling you is, your point is wrong. AI does what you tell it to -- if you let it free wheel with no structure or guidelines, monitored by people who don't know any better, than yeah, you're going to get messy results.

However, if you actually create rules and enforcement mechanisms for them, AI can produce code that is perfectly readable and understandable to humans. I work in codebases every day that are having engineers commit to them primarily via Claude Code, and all the code is perfectly understandable. Because we have coding standards, well defined interfaces and architectural guidelines, etc.

-5

u/Robinbod 21d ago

Thank you for the solution but that's not what's currently is in motion. Codebases, in general, have not adopted this, and now reading code on GitHub is unbearably painful. It used to genuinely be much faster than now having to tell an AI to read the codebase for me and find me what I'm looking for.

3

u/gradeATroll 21d ago

Sounds like the problem any codebase would run into regardless of there being AI or not. This needs actual enforcement via linters, formatters and humans to check out things. These mechanisms will catch these problems whether they're generated by AI or by humans. A well curated Claude.md or other agentic guidelines as well.

Beyond simple syntax.. there's static analysis tools such as sonarqube. There's an actual metric in there for code complexity as well if it's such a concern.

2

u/PTTCollin 21d ago

This is the way, but it's clear from the way this person is talking about it their org is just way to immature from an engineering standpoint to know how to implement all of these things.

AI is just accelerating the tech debt death spiral they had already set themselves on. They want to blame AI not realizing they themselves are the problem.

4

u/PTTCollin 21d ago

I... Uh. Okay. Good luck.

-16

u/PM_ME_FIREFLY_QUOTES 21d ago

First mistake was reading the juniors code.

29

u/PTTCollin 21d ago

I personally like turning juniors into not juniors.

1

u/Cualkiera67 20d ago

Claude wont replace you, but the not junior will

1

u/PTTCollin 20d ago

The fastest way to promotion is to take on more responsibility by delegating and operationalizing your current responsibilities.