r/ProgrammerHumor • • 1d ago

Meme typaShiClaudeGivesYouForASimpleMonitoring

Post image
1.9k Upvotes

124 comments sorted by

1.3k

u/Welcome-To-NBA-Jam 1d ago

What I love about Claude-generated code is that it finds a way to usefully use that one function in your language you never knew existed and have never seen code that ever uses it in your 20 year career, but someone out there made that function 40 years ago, and Claude decided today was the day for it to shine.

488

u/Pristine-Pea6795 1d ago

The other day i got: for(;;) and i was like what the hell is that ? Claude said it does the same as while true, ok use while true then…

154

u/Mojert 1d ago

IIRC using for(;;) produced better assembly in the first C compilers than while(true), so it became common because of this. Also, true wasn't a thing in C at the time so it would actually have been while(1), which also isn't super clear

53

u/vegataballs 1d ago

Indeed.

But also worth noting that though "at the time" sounds (to me at least) like maybe 70's and 80's, it is anything before 1999, or really, the time when people got around to adopting the C99 standard (so mid 2000's?) where the boolean type _Bool was introduced to the language. But even then you had to include the stdbool.h header if you wanted to use bool, true, or false, which were really just convenience macros expanding to _Bool, 1, and 0. It wasn't until the year of our lord 2023 that they genuinely became part of the language.... which is pretty wild if you ask me

8

u/Mountain-Ox 12h ago

That takes me back to JavaScript optimizations. You got better performance running over an array backwards than forwards. And a loop is much faster that for each. An index loop is faster than a 'for of' loop.

Then you sometimes need to allocate the variables outside the loop so they would be reused.

Usually this didn't matter but sometimes you gotta summon the arcane knowledge of the V8 engine.

323

u/Welcome-To-NBA-Jam 1d ago

CFO: Claude is getting too good. It's using fewer tokens. It's eating into our non-existent margins. What do we do?

Dario: So make it use weird code that forces people to ask it to explain what it does.

CFO: And if they make it use caveman mode?

Dario: Write assembly for all basic arithmetic.

41

u/iBac0n 1d ago

for(ever)

7

u/atomic_redneck 1d ago
#define ever 0

28

u/rusbon 1d ago

Its common for c embedded world. Depending on compiler version, not even true/false existed.

2

u/Steinrikur 19h ago

I've seen while(1) in FreeRTOS. for(;;) is pretty straightforward, though.

28

u/Daniikk1012 1d ago

That's actually a pretty common C idiom for infinite loops, not that obscure

13

u/Kommenos 1d ago

Actually this is the preferred convention in my field for notation of “this is intentionally running forever” like within a thread or a task.

Funny that….

11

u/Grokepeer 1d ago

This is very common in embedded work

6

u/Sea-Quail-5296 1d ago

I’ve used that seriously before AI

31

u/Irbis7 1d ago

I always use for(;;) or for (; condition; ) instead while, the last time I've used while was probably in Pascal.

94

u/anovagadro 1d ago

Get off of reddit Claude, we need the water. Im about to shower

29

u/Irbis7 1d ago

I'm not AI, but I apologise to all unfortunate users if Claude copied my style.

11

u/Dry_Access532 1d ago

That's what AI would say

2

u/vegataballs 1d ago

Last time I recently looked at Torvald's code he did too. Not to downplay your contribution, but that too has probably "inspired" Claude quite a bit.

4

u/thet0m0 1d ago

i only know that from my second 2nd year uni course in C

3

u/Scolmann 13h ago

Not uncommon in C, one advantage is it's obvious to any linter that you intend to iterate forever. Linters are generally smart enough to handle it now but if you say "while(1)" or "while(true)" you may get a warning that the condition is always true, and the latter requires including stdbool prior to C23

1

u/dgbaker93 1d ago

I've seen that notation in leetcode submissions 🤣

1

u/Amatheos 1d ago

I legit failed a job interview once because I didn't know that. You can also fill in for call only partially and it will still work

1

u/Septem_151 12h ago

You've never seen for(;;) used...? This is very common.

0

u/-KKD- 1d ago

I've heard from some algo dudes that in c++ for(;condition;) in some cases by some compilers is optimized better by -O3 than while(condition) and that can save them precious milliseconds they fap on

7

u/isamu1024 1d ago

We have that moment with SQL where suddenly everyone starts declaring temp table in a way we never saw before:D

21

u/tehtris 1d ago

Python joined the chat

Claude: if x := func():

Me: JUST DECLARE THE VAR FIRST. No one knows this unless they have seen this and went "wtf is this"

26

u/DHermit 1d ago

Nah, I knew this exists. It's just a relatively new addition, so people aren't used to it yet.

6

u/rosuav 1d ago

And the controversy surrounding it was so strong that some of us still have scars.

4

u/codeartha 1d ago

A new addition to python, already exists in other languages

3

u/wggn 1d ago

this is just a scoped variable right

5

u/32nmud 23h ago

Sort of, the scope is not as limited as you might expect. In this condition, x is assigned the return value of func() then evaluated for its truthiness. The variable then can be used after declaration, even outside the scope of the condition block (so you could later use x entirely outside the scope of the condition)

It's a somewhat new addition to Python, but I've found it pretty useful personally. It can also be used in some more complex cases, like in dict comprehension. For example:

``` products = {"Pen": 120, "Notebook": 80, "Pencil": 40}

affordable = { name: discounted_price for name, price in products.items() if (discounted_price := price * 0.9) < 100 }

print(affordable) ```

(stole this example from here because I'm lazy)

The := operator is called the walrus operator if you wanted to look it up and learn more

1

u/tehtris 23h ago

Essentially. I guess it's an uncommon math operator that a lot of other languages use, but the first time I saw it in code I was like "wtf is this nonsense..... Oh..... It's bullshit"

1

u/hashishsommelier 4h ago

That’s called the walrus, I like it. It’s cute if you see a walrus.

3

u/them0use 1d ago

Seriously, TIL about the -l option to xargs. What a helpful meme!

2

u/JVM_ 22h ago

I wanted a PNG converted to SVG or some such. It couldn't find a PowerShell way to do it, pngtosvg.com was blocked by the corporate firewall so it found a npm library to do it, downloaded it and called it locally to do the conversion.

Like. It know this possible but what a crazy way to accomplish the task.

1

u/[deleted] 19h ago

[deleted]

3

u/JVM_ 19h ago

It was for an icon and I wanted it scalable? I forget the exact formats.

I was more impressed by AI taking a valid pathway/solution that I wouldn't have considered.

2

u/Recent-Ad5835 21h ago

Meanwhile with GPT I've head cases where I know what the function is and ask it to use it because I cant be bothered to scour the docs to find it and its name, and it kept on getting stuck because it was using a nonexistent function from a core library

2

u/BlueForeverI 18h ago

Couple months ago it generated me a goto statement... in a C# greenfield project.... in 2026...

2

u/supertoilet2 14h ago

And then when you ask it to make a tiny change it causally ditches the astute function for either a made up function or some beat up clunker

3

u/bleeding_gums 1d ago

I got INSTEAD OF triggers in SQL. Never knew about them.

1

u/hashishsommelier 4h ago

I’m not sure what of that is in the picture. Haven’t you heard about ed? You know, ed is the standard text editor

0

u/Sea-Quail-5296 1d ago

Like how many people knew what sed was 10 yearsa ago? Three?

186

u/ThaBroccoliDood 1d ago

love putting words in the terminal
sort -rn
rm -fr
journalctl -ball

43

u/rosuav 1d ago

When your systemd service is messed up, you say "journalctl -fu servicename". I am sure the devs were fully aware of what they were doing with this, same as LPL was when he made the Folding Utility ("FU") pick.

22

u/deralexl 1d ago

ls -lisa

12

u/acceleratedpenguin 1d ago

ss -tunapls

(I think I heard about this one from Julia Evans weekly email)

2

u/Bemascu 4h ago

In Spanish there's "ss -putona", which translated would be "ss -slut". It's a good mnemonic.

27

u/mrheosuper 1d ago

"LGTM" go ahead

6

u/naruto_bist 1d ago

"Always allow" and prompt stating don't make any mistakes

291

u/djbarsone 1d ago

Just rename this sub AIcirclejerk already

158

u/Cutalana 1d ago

might as well rename the entire field that too

52

u/Kooshi_Govno 1d ago

this but unironically

6

u/einzweidreihorn 1d ago

Might aswell get a pay increase out of it. I'm an AI engineer now, software engineering is for dinosaurs.

15

u/dbagames 1d ago

Circle jerk "engineering"

0

u/pagraphdrux 11h ago

Is this not criticism of a.i. or do ya'll think this is genuinely a good way to monitor something?

18

u/0xKaishakunin 1d ago

Damn, we need a Practical Extraction and Report Language at this point

6

u/ascii158 1d ago

Awesome idea! I propose we name it after a British 70s sketch show!

11

u/Spare-Subject-796 1d ago

just did the same a couple of minutes ago for my influxDB exited when it should not have

11

u/ZunoJ 23h ago

Looks more or less fine to me

10

u/Jimmyfartballs 22h ago

no it's not less it's head

1

u/adamantium4084 21h ago

Yea, less >= more and isLessOrMore() != head You could '<command> | head | less' If you wanted..

5

u/ziroux 22h ago

Could maybe refactor into a proper script, but depends on the need and environment. Otherwise it's just usual cli stuff, no magic

30

u/NomaTyx 1d ago

happy for you or sorry that happened

11

u/BastetFurry 1d ago

So Claude is your average Linux Neckbeard that loves to pipe?

3

u/virgin4ever69 23h ago

I, too, love to pipe. Alas! Meth.

31

u/-Redstoneboi- 1d ago edited 1d ago

"damn bro i'll let you use python at this point"

all these linux cli tools are so stringy, would definitely much rather have standardized apis for them

17

u/rosuav 1d ago

That's fundamental to shell scripting. It's always very stringy. There are a few shell languages that took the leap to become applications programming languages (I spent a lot of my time in the 1990s writing REXX code, for example), and they will always be that bit different from "classic" programming languages.

0

u/-Redstoneboi- 1d ago edited 1d ago

i'm really just saying i dont like strings in general

my favorite language is rust so i can and will strongly type everything by pure instinct rather than by logic even when scripting languages are objectively more convenient for these tasks

i like micro optimizations and overvalue it a lot more than developer time so i generally dont like the very idea of multiple regex passes and string operations/allocations even if in practice it takes a few milliseconds to run (if even that) every hour

3

u/rosuav 1d ago

That's fair! It's often the wrong tradeoff to make, but I definitely understand the mindset. Personally, I tend to prefer languages with richer data types (lacking support for first-class arrays can seriously hamper a language), but there are a lot of conveniences to the simplicity of shell languages.

1

u/-Redstoneboi- 1d ago

i also have some uh, opinions regarding regex and vim's default keybinds

so many things that "work and work well but aren't perfect for my specific definition of perfect"

i feel like the new kid walking into the scene going like "damn y'all live like this?" and being basically the only one in the room to (outwardly) think this way while everybody is busy doing their actual job

i'll probably look around for "regex with macros" and other text editors like kakoune and emacs before i make another competing standard

2

u/rosuav 1d ago

Oh look, everyone has opinions about regex. Most of them have at least some merit. The minilanguage is so extremely compact and then has to get extended in so many directions. Ugh. Don't worry, you are not the only one to think that way.

TBH I wouldn't reach for a regex for most parsing, unless it's the only real option available in the context I'm working in. Whenever I can, I prefer sscanf parsing instead. The main reason is to avoid backtracking (yes, occasionally that means sscanf is a poor choice, but OTOH you never have the catastrophic performance that a regex can suffer from), but also I prefer the syntax.

15

u/Banes_Addiction 1d ago

The fun thing about the "stringy"ness is it's really quick and simple. You can just build up a pipeline in real time looking at the output of each thing, and not really worry about anything (or even really look anything up).

No API, just a very simple set of operations with easily human readable output every step of the way.

If you look at that, journalctl is the only tool that does something specific/uncommon. Everything else is the equivalent of a standard library function.

This is what I'd consider an "aeroplane skill", ie easily doable without an internet connection.

0

u/-Redstoneboi- 1d ago

from my perspective, this is just a repl but with only one type

correct me if i'm wrong but isn't that basically what bash is

it's awesome that they figured out this kind of workflow from a long long time ago, but things are absolutely not optimal the way they are now. they are simply the most backwards compatible, universal, and thus generally least headache-prone ways of doing things.

1

u/Banes_Addiction 23h ago

I mean, yeah? A terminal is a REPL loop.

The thing about a shell is that it's designed to be something different than a "real" programming languange, right? It's a way to interact with the OS, and all that stuff is front and centre. Strings and files are the natural "units".

Of course you can do all this stuff in a Python interpreter if you want, it just takes way more typing.

A shell one line is a neat little "here's a thing that needs doing, it needs a few simple steps, just get them out the way". I guess the python equivalent would be a list comprehension.

1

u/-Redstoneboi- 23h ago edited 23h ago

i guess the difference is that in python, the syntax is command, arg2, opt=val) while in bash it's command arg1 arg2 --opt val and you can pipe things.

very convenient, with the catch that you have only one type to work with. someone suggested i take a look at nushell and that's pretty much what i envisioned. just a language with real types, a repl, and convenient default parse/tostring implementations for every type.

user readability doesn't clobber the exact values of the data. you don't have to lose information or re-parse whatever the last program outputted, if it's compliant. the number "10,552 bytes" can show as "10kb" since both are just the same mumber displayed differently.

6

u/JangoDarkSaber 1d ago

There are now 15 competing standards…

5

u/SirBanananana 1d ago

all these linux cli tools are so stringy, would definitely much rather have standardized apis for them

Then you'll love nushell

2

u/-Redstoneboi- 1d ago edited 1d ago

thank you

edit: damn thats hot

1

u/gregorydgraham 12h ago

This is a humour subreddit, porn is not allowed.

Use r/ProgrammerPorn instead

2

u/Ok-Dimension-5429 22h ago

I mean you can go use PowerShell if you want. Commands return objects. It's a pain in the ass though. Strings work fine.

26

u/k_sway 1d ago

Lately I’ve been telling it “your code needs to be easily read and understood by a human reviewer so always lean towards readability even if it means your solutions aren’t as elegant”

I’ve been getting good results with that so far

6

u/somebodyinvisible 1d ago

Somehow I understand of that evil spell.

9

u/770grappenmaker 1d ago

Get the top 3 most common syslog identifiers, count errors for each?

9

u/snarkofagen 1d ago

Beats having to write shit like that by hand like we had to do in the olden days.

6

u/snarkofagen 1d ago

Up hill

7

u/snarkofagen 1d ago

In head winds

6

u/Material_Basis1960 1d ago

Both ways.

1

u/ziroux 22h ago

She's said

13

u/gsaelzbaer 1d ago

That’s not even a crazy command with basic UNIX/Linux knowledge.
I’d be more worried about you, if you vibe code stuff in a domain that requires this command, and don’t understand it.

5

u/Cobracrystal 1d ago

tbf i think you can compress it? surely you can just get both results at the same time and censor data in the output instead of running two journalctl commands

9

u/gsaelzbaer 1d ago

Not saying it’s not overly verbose 😄 LLMs usually don’t come up with the most compact solution. But that command‘s intent is not _that_ hard to parse

10

u/coffeeicefox 1d ago

Okay mate, everyone knows your a big bad coder, chill out.

Of course every command is simple, and if you take the time to read it you can make sense of it, It's the construction of the whole script in a nano second using tools you've not used for that project or in a while and it's moved onto the next task producing a similar output before you can even process what happened in the first one that causes the shock to your current mental model of what you're working on.

e.g, The agent is running a basic SQL command and parsing into another data structure to run sed with a mad regex on it rather than writing a decent SQL query which you would have done previously.

1

u/rosuav 1d ago

journalctl -fu {}

2

u/ilnarildarovuch 1d ago

systemD slop command

1

u/ilnarildarovuch 1d ago

In both ways

5

u/Solomoncjy 1d ago

atp just pull in python for the structed json parsing oml

1

u/GTMoraes 1d ago

guy that made the tool: I didn't even know it could do that

1

u/explodedcheek 1d ago

This is what I thought regex final boss would look like...but it's just code for monitoring logs lol.

1

u/Express-Acanthaceae9 1d ago

Claude finds interesting ways to reduce filling context with output from these kind of commands

1

u/ExtraWorldliness6916 1d ago

You lost me at pipe syslog identifier

1

u/exqueezemenow 23h ago

I was in this same position with the same expression this week.

1

u/20220912 23h ago

I'm an SRE, and this is, like, a typical Tuesday morning, not anything exotic. It's not even 'code', it's just a series of log dumps and filtering. No conditionals or looping anywhere.

1

u/dminus 23h ago

catgrepper bankai

1

u/chickey23 22h ago

I told you we should have put a no robots at the start of the crontab. Now they are stealing all of our pipes!

1

u/r0b074p0c4lyp53 21h ago

It's just reading the log, plus a bunch of formatting

1

u/fhayde 18h ago

Claude code one liners always remind me of this Romanian Perl developer I worked with in the late 90s. At least Claude doesn’t curse me and respond with RTFM if I ask any questions.

1

u/cornmonger_ 10h ago

/uj i highly recommend nu --mcp

/rj i highly recommend nu --mcp

1

u/BobThefuknBuilder 5h ago

Didn't understand instruction, gave head 5 times no logs appeared.

1

u/glorious_reptile 4h ago

| cryptominer —t 5s —silent | …

1

u/nazgulonbicycle 1d ago

I’ve handwritten and stored type shi like this

1

u/burnttoast12321 1d ago edited 1d ago

It's using bash to it's peak. Love to see it. This is why AI has an advantage.

Not even kidding. The most productive I've ever felt was when using bash in Unix. Don't even get me started on how great it feels to write Regex without looking up the syntax! Wish I still could. Been a good 10 years since I've touched it.

People probably think I am kidding but AI using bash to configure systems to deploy to AI is a huge deal.

There have even been a few new Linux distros that have come out from this in the past few weeks.

We know AI is decent at coding. If it can configure systems or even bigger networks we are in for some big changes...

I wish DraftKings had a bet to say that system integration AI is the winner. Once integrated it has full control. (Not saying we can't it shut) but at this point it has system controls, coding abilities and can just keep improving.

More hardware tech may be required but this is all happening pretty fast.

0

u/iamfab0 1d ago

Is this really best practice or can they sell more tokens by generating inflated code?

10

u/dcondor07uk 1d ago

This is most likely just a quick one-liner for Claude to run when troubleshooting a system. It identifies which services are generating the most errors, normalizes variable values (like replacing hex values with <hex> and long IDs with <id>) so similar errors can be grouped together, then displays the five most common error patterns.

So regarding your point about “selling more tokens,” I’d actually argue the opposite. This is an extremely compact and efficient way to accomplish the task. Rather than having Claude break the process into multiple steps, inspect logs individually, or write a more elaborate Bash script following some arbitrary coding conventions, it can do most of the work in a single command.

All those extra steps would take more time and, more importantly, more tokens. If anything, this is an example of minimizing token usage, not inflating it.

1

u/E-M-C 1d ago

I hate that I can recognize ChatGPT's style in this comment

2

u/dcondor07uk 23h ago

You are absolutely right to push back on that. It was an oversight on my part and I apologise for the inconvenience.😂

1

u/E-M-C 23h ago

I wasn't calling you a bot, just saying that, even if accurate, you comment was written by ChatGPT :p

1

u/dcondor07uk 23h ago

I know, second language issues

I used gpt to make it clear and meant as a satire😂

3

u/Ok-Dimension-5429 22h ago

Claude is going to read the results of this command. It's better to have a complicated command which gives a short output than a simple command which gives a long output, if you want to reduce tokens.

0

u/rosuav 1d ago

Precisely. It's best practice for them to sell more tokens by generating inflated code.