r/vibecoding • • 3d ago

Discussion Coding was always the hard part.

Post image

Bros, we gotta stop saying "coding was never the hard part.." Before AI, it was frickn hard bro..

We get it bro, product-market fit is hard too. You coded 20 apps and only one got 3 users.... and bro, for every app you coded, 500 other people didn't code anything.

Tell the farmer growing crops was never the hard part.

423 Upvotes

768 comments sorted by

View all comments

206

u/ClibeanCeann 3d ago edited 3d ago • Bravo Mindblown Popcorn

If this was your code, then yea. Coding clearly is the hard part for you lol.

Edit: Just for the silly billys in the comments who claim to be coding genuises, properly parsing URLs is best done like this:

const request_param_note_tags =
    new URL(req.url, 'http://example.com')
        .searchParams
        .get('note_tag')
        ?.split(',')
    ?? [];

If you want it in a one liner:

const request_param_note_tags: string[] = new URL(req.url, 'http://example.com').searchParams.get('note_tag')?.split(',') ?? [];

145

u/danrol92 3d ago • Heartwarming

Your answer reminded me of the way people answer on Stack Overflow

60

u/Alarmed-Western-655 3d ago

Accepted Answer

6

u/naut___ 3d ago

Used to answer*

11

u/kabinja 3d ago

The problem is still the same. A bunch of incapable people come to a field they do not belong in. They could be lawyers today by the same token. So the shit they used to produce before will just be the same shit after, just faster. This is why people say what they are saying. If you cannot design a system, the AI will not do it for you for the simple reasons that it does not know all the subtleties of the context you are in.

→ More replies (3)
→ More replies (4)

39

u/kraemahz 3d ago

This isn't that bad. It's solving the problem of parsing an HTTP query in a way that should've been left to a routing library, but I can at least tell what it is by looking at it.

11

u/NerdyMcNerderson 3d ago edited 3d ago

I beg to disagree. I assume this is the built in node http server and there are bugs in this code. Here's a free code review on what I can see in this snippet alone:

First off, the type definitions are lying to you. If the URL doesn't include a query param section or if it doesn't include one that includes the string note_tag then req_params_note_tags is undefined, not a string array. This will throw an error if something tries to access that variable assuming it's an array. EDIT: Forgot to mention, the fix here is to end your chain with a ?? [] so that if the long optional chain returns undefined, at least we honor the type contract we stated above but it's a moot point because you shouldn't be writing it like that anyway.

Second off the parsing isn't even correct. Note that they're using .includes('note_tag') so this will match query params such as "my_note_tag" or "your_note_tag" or "hey_note_tag_whats_up".

Third this doesn't handle string that are url encoded/decoded. If a valid note_tag query param can have a space or any special characters, those get URL encoded and will likely mess up the lookup function down the line (i.e. ?note_tag=work%20todo will keep the %20 as a string value and not convert it back to a space.

Minor edge case ?note_tag= will parse as [''] when you probably want it to be [].

OP absolutely should replace this line with something more robust. Without any extra dependencies:

const url = new URL(req.url ?? '/', 'http://localhost');
const noteTags = url.searchParams.get('note_tag')?.split(',').filter(Boolean) ?? [];

And this second line only assumes note_tag can have multiple values. If not this will suffice:

const noteTag = url.searchParams.get('note_tag'); // 'work' or null

No import required. It's the same old URL object that browsers have access to.

And lastly the fs.readFile call doesn't handle errors, 404's etc. Even if the read fails, it's going to send a 200 OK.

I mean I'm sure AI could have told you these things if you pointed it at the snippet but these are just my observations as a software engineer (assuming you kept this code and didn't immediately improve it after noticing how bad it was).

3

u/Mrgluer 3d ago

I see this review and instantly get reminded i have so much yet to learn

4

u/Wonderful-Habit-139 3d ago

You can always learn as long as you still value the importance of coding and don't disregard it due to takes like "Software engineering was never about the code".

→ More replies (2)

2

u/Green_Sugar6675 3d ago

I don't know, but looking at your response as an old guy (who's put in his time) reminds me of playing games against teenage "specialists" and just being constantly destroyed... I remember my teen years when I had all the time i wanted to memorize every D&D book... and yeah, I don't even want to read that stuff and understand the deep complexities, even though my income might depend on it.

It's really nice to just have Claude work out the details... and thus the trap is triggered.

→ More replies (1)
→ More replies (2)

8

u/Weaves87 3d ago

I mean, it ain’t pretty.

There’s a lot of cognitive load there on that particular line that unpacks all of the note tags into an array. I could see what it does as a rusty TypeScript dev, but I always cringe when I see a cascade of ?. operators for unpacking data

If I saw that in a script it would be OK, but if I kept running into that in the codebase I wouldn’t push that thru PR until it was refactored to use some sort of proper URL parsing library instead

2

u/kraemahz 3d ago

I would just say I'm guilty of worse as a senior dev back when I still wrote code. Sometimes all that stuff about clean code and readable functions doesn't matter when you just want it to work. You're right that the line is somewhere between a script that no one but you will see that it failed and what your company depends on to make money.

→ More replies (2)

2

u/ClibeanCeann 3d ago

req.url.split()[1]?.split().split().split().find().split

bro what the fuck

→ More replies (8)
→ More replies (1)

2

u/New-Locksmith-126 3d ago

thank God these people are using AI now

1

u/TenshiS 3d ago

That was like 80% of them

1

u/Wonderful-Habit-139 3d ago

Heck no. They generate even more slop instead of being slowed down by their coding skills.

2

u/howreudoin 3d ago

Also, just look at that code. It‘s total garbage. For one, it could use some line breaks and some local variables. Moreover, it uses explicit any!

Functionality-wise, that code is not hard to write. It is pretty straightforward in fact. It’s just that it takes a lot longer without AI.

I agree that "coding" isn’t easy. But if people fail to recognize how this code is not in perfect shape, it comes as no surprise that to them coding is extremely difficult.

2

u/OkLettuce338 3d ago

rofl yes

1

u/singularitittay 3d ago

This; specifically the endless pedantry to sift through while learning—was the hard part

1

u/dr1fter 3d ago

I also didn't even really mind it the way it was originally written, and I'm usually pretty nitpicky about style. There are examples of coding being "the hard part" but probably not this time.

1

u/Lazy_Ruin7888 3d ago

Parsing URLs (anything) is best not done in js because JavaScript is awful

→ More replies (1)

1

u/Manxkaffee 2d ago

Code that is actually readable and understandable for a normal human? What a sight.

I swear I have been trying to understand what the AI is writing for me because I do not want to completely lose the ability to properly code and/or change my projects by hand, but it always seems so much more convoluted than anything I ever wrote that it is hard to wrap my head around it.

→ More replies (1)
→ More replies (18)