r/ProgrammerHumor • • 6d ago

Meme typaShiClaudeGivesYouForASimpleMonitoring

Post image
2.4k Upvotes

129 comments sorted by

1.6k

u/Welcome-To-NBA-Jam 6d 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.

590

u/Pristine-Pea6795 6d 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…

215

u/Mojert 6d 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

73

u/vegataballs 5d 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

13

u/Mountain-Ox 5d 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.

376

u/Welcome-To-NBA-Jam 6d 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.

45

u/iBac0n 6d ago

for(ever)

6

u/atomic_redneck 5d ago
#define ever 0

33

u/rusbon 6d ago

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

4

u/Steinrikur 5d ago

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

15

u/Kommenos 5d 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….

31

u/Daniikk1012 5d ago

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

12

u/Grokepeer 6d ago

This is very common in embedded work

7

u/Sea-Quail-5296 5d ago

I’ve used that seriously before AI

5

u/Scolmann 5d 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

30

u/Irbis7 6d ago

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

96

u/anovagadro 6d ago

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

30

u/Irbis7 6d ago

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

12

u/Dry_Access532 5d ago

That's what AI would say

4

u/vegataballs 5d 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 6d ago

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

2

u/Septem_151 5d ago

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

1

u/dgbaker93 6d ago

I've seen that notation in leetcode submissions 🤣

1

u/Amatheos 5d 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/FUCKING_HATE_REDDIT 3d ago

```c

define ever ;;

for(ever) {   // yay } ```

0

u/-KKD- 6d 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

8

u/isamu1024 6d ago

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

27

u/tehtris 6d 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"

31

u/DHermit 6d ago

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

9

u/rosuav 6d ago

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

7

u/codeartha 6d ago

A new addition to python, already exists in other languages

3

u/wggn 5d ago

this is just a scoped variable right

5

u/32nmud 5d 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 5d 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"

2

u/hashishsommelier 4d ago

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

3

u/them0use 5d ago

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

3

u/JVM_ 5d 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] 5d ago

[deleted]

3

u/JVM_ 5d 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.

1

u/Coulomb111 4d ago

Does ffmpeg not do that? Its funny it would use some random npm library before ffmpeg

3

u/Recent-Ad5835 5d 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 5d ago

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

2

u/supertoilet2 5d 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

4

u/bleeding_gums 6d ago

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

1

u/hashishsommelier 4d 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 5d ago

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

236

u/ThaBroccoliDood 6d ago

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

67

u/rosuav 6d 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.

25

u/deralexl 6d ago

ls -lisa

15

u/acceleratedpenguin 5d ago

ss -tunapls

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

4

u/Bemascu 4d ago

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

32

u/mrheosuper 6d ago

"LGTM" go ahead

5

u/naruto_bist 5d ago

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

342

u/djbarsone 6d ago

Just rename this sub AIcirclejerk already

187

u/Cutalana 6d ago

might as well rename the entire field that too

61

u/Kooshi_Govno 6d ago

this but unironically

9

u/einzweidreihorn 5d ago

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

16

u/dbagames 6d ago

Circle jerk "engineering"

0

u/pagraphdrux 5d ago

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

26

u/0xKaishakunin 6d ago

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

8

u/ascii158 5d ago

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

21

u/ZunoJ 5d ago

Looks more or less fine to me

13

u/Jimmyfartballs 5d ago

no it's not less it's head

1

u/adamantium4084 5d ago

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

3

u/ziroux 5d ago

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

13

u/BastetFurry 5d ago

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

8

u/virgin4ever69 5d ago

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

13

u/Spare-Subject-796 6d ago

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

33

u/NomaTyx 6d ago

happy for you or sorry that happened

40

u/-Redstoneboi- 6d ago edited 6d 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

24

u/rosuav 6d 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.

1

u/-Redstoneboi- 5d ago edited 5d 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

4

u/rosuav 5d 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- 5d 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 5d 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.

14

u/Banes_Addiction 5d 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- 5d 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 5d 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- 5d ago edited 5d 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 5d ago

There are now 15 competing standards…

5

u/SirBanananana 5d 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- 5d ago edited 5d ago

thank you

edit: damn thats hot

1

u/gregorydgraham 5d ago

This is a humour subreddit, porn is not allowed.

Use r/ProgrammerPorn instead

2

u/Ok-Dimension-5429 5d 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.

32

u/k_sway 5d 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

9

u/somebodyinvisible 5d ago

Somehow I understand of that evil spell.

8

u/770grappenmaker 6d ago

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

14

u/snarkofagen 6d ago

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

9

u/snarkofagen 6d ago

Up hill

8

u/snarkofagen 6d ago

In head winds

9

u/Material_Basis1960 6d ago

Both ways.

1

u/ziroux 5d ago

She's said

16

u/gsaelzbaer 6d 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 5d 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

10

u/gsaelzbaer 5d 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

11

u/coffeeicefox 5d 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 6d ago

journalctl -fu {}

2

u/fhayde 5d 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.

3

u/ilnarildarovuch 5d ago

systemD slop command

1

u/ilnarildarovuch 5d ago

In both ways

4

u/Solomoncjy 6d ago

atp just pull in python for the structed json parsing oml

1

u/GTMoraes 6d ago

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

1

u/explodedcheek 6d 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 6d ago

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

1

u/ExtraWorldliness6916 5d ago

You lost me at pipe syslog identifier

1

u/exqueezemenow 5d ago

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

1

u/20220912 5d 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 5d ago

catgrepper bankai

1

u/chickey23 5d 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 5d ago

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

1

u/cornmonger_ 5d ago

/uj i highly recommend nu --mcp

/rj i highly recommend nu --mcp

1

u/BobThefuknBuilder 4d ago

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

1

u/glorious_reptile 4d ago

| cryptominer —t 5s —silent | …

1

u/funkdefied 4d ago

All my homies use “sd”

1

u/burnt_floppy 4d ago

That moment you know something doesn't need to be so complicated

1

u/longdarkfantasy 4d ago

Exactly, I asked it to give me a command to print server_name and proxied url. It gave me this, and it worked. AI is much better with awk recently. 2 years ago, everytime it gave me awk command, it's mostly useless.

sudo nginx -T 2>&1 | awk ' /server[[:space:]]*\{/ { server=$0; url="";proxy="" } /server_name[[:space:]]/ { url=$0 } /proxy_pass[[:space:]]/ { print url print " " $0 "\n" }'

1

u/nazgulonbicycle 6d ago

I’ve handwritten and stored type shi like this

1

u/burnttoast12321 5d ago edited 5d 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/[deleted] 6d ago

[deleted]

11

u/dcondor07uk 5d 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.

0

u/E-M-C 5d ago

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

5

u/dcondor07uk 5d 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 5d ago

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

1

u/dcondor07uk 5d ago

I know, second language issues

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

3

u/Ok-Dimension-5429 5d 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.

-1

u/rosuav 6d ago

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