this post was submitted on 22 Nov 2025
651 points (98.7% liked)

Programmer Humor

27673 readers
511 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

cross-posted from: https://lemmy.ml/post/39334581

you are viewing a single comment's thread
view the rest of the comments
[–] mindbleach@sh.itjust.works 3 points 2 weeks ago (1 children)

It's object-oriented; you can assign this to a named variable.

[–] Ghoelian@piefed.social 9 points 2 weeks ago (1 children)

In that case the full thing would be const fun = () => {}

[–] SpaceCowboy@lemmy.ca -5 points 2 weeks ago (2 children)

Yeah for whatever reason, FE devs want to make everything a const. It's like a religious belief or something, it's really kinda weird.

const fun = () => { const something = "whatever" const array = []; array.push(someting)

for (const thing of array) { if (thing === 'whatever') blah(thing) } }

Semicolons? Optional. Which quotes you should use? Whatever you feel like! But you must declare things as a const wherever possible! Even if it's an array that you're going to be changing, declare it as a const because you should know that you can push things into a const array, and since it's possible to declare it as a const, you must declare it as a const.

Why is this? Nobody knows, but it's important to FE devs that you use const.

[–] Ghoelian@piefed.social 9 points 2 weeks ago (1 children)

The reason is very simple, performance. If a value doesn't need to be changed, don't declare it as mutable. This isn't just a front-end thing btw.

[–] brian@programming.dev 2 points 1 week ago (2 children)

semicolons? quotes? use a formatter and don't think about it. I think js world has basically done this already.

const is simpler. why would I declare an array as let if I'm not reassigning? someone can look at it and know they don't have to think about reassignment of the reference, just normal mutation. ts has the further readonly to describe the other type of mutation, don't abuse let to mean that.

const arrow over named function? gets rid of all the legacy behaviors and apis. no arguments, consistent this, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually need this

[–] mr_satan@lemmy.zip 1 points 1 week ago (1 children)

semicolons? quotes? use a formatter and don't think about it. I think js world has basically done this already.

It's nice when a codebase has sane formatter conventions. I can't say that my workplace does, tho…

const arrow over named function? gets rid of all the legacy behaviors and apis. no arguments, consistent this, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually need `this

How is having arguments and this an issue? If one doesn't need them, then it can be just left unused. I really don't get this argument. It makes everything visually a variable. I see no benefit to this convention and actively despise it.

[–] brian@programming.dev 1 points 1 week ago (1 children)

I've worked at several places that didn't have formatters when I started. they did by the time I left. you can incrementally adopt them and if it's automated most people at worst don't care. advocate for things you want

reassignment and hoisting are the significant ones. behavior around this does just seem more intuitive than otherwise when it comes up, so I think telling especially new devs to use const arrow fn everywhere but classes is a reasonable rule

hate to break it to you but it behaves like a variable either way. function just behaves closer to a var variable. const fns are less like variables since no assignment. intellisense/devtools all show them just fine. it really is just a minor aesthetic difference on the definition

[–] mr_satan@lemmy.zip 1 points 1 week ago

I've worked at several places that didn't have formatters when I started. they did by the time I left. you can incrementally adopt them and if it's automated most people at worst don't care. advocate for things you want

We use formatters, I just disagree with our current conventions (nitpicky, I know).

hate to break it to you but it behaves like a variable either way. function just behaves closer to a var variable. const fns are less like variables since no assignment. intellisense/devtools all show them just fine. it really is just a minor aesthetic difference on the definition

To me it's about readability and declaring everything as const goes against that.
What benefits does it have? Using this in arrow functions is still valid it's just that they will use parent scope to resolve it. You saying it doesn't have this or arguments doesn't convey any benefits (nor real drawbacks) to me. Hence the convention feels useless at best.

[–] SpaceCowboy@lemmy.ca -3 points 1 week ago (2 children)

Stylistically, you're changing the array when you add something to it. Javascript is a janky language in the best of times, but FE devs like to artificially introduce additional unnecessary complexities on top of the jank.

const is simpler. why would I declare an array as let if I’m not reassigning?

Why would you declare a const that's going to have different data every time to function is called?

Now I'm thinking it's a form of gatekeeping. Just an excuse for FE devs to throw out terms like "immutable" to make it sound like they know what they're taking about. Y'all need to constantly sound like you know what you're talking about when dealing with users, pretending weird stylistic choices have real technical reasons for them. But the BE devs know what you're saying is complete bullshit LOL.

[–] brian@programming.dev 2 points 1 week ago

knowing the programming language you're working in at a basic level is gatekeeping I'm ok with

[–] masterspace@lemmy.ca 2 points 1 week ago* (last edited 1 week ago) (1 children)

You are literally just describing the conceptual differences between functional programming and object oriented programming. It has nothing to do with front end vs backend, except for the fact that React has vastly popularized functional paradigms on the frontend.

If you come from a Java / Spring background, that will seem foreign, if you come from an express background it will feel natural.

Functional programming is extremely pleasant though. Its been described as what object oriented would look like if you actually followed all the SOLID principles. You should keep an open mind.

[–] SpaceCowboy@lemmy.ca -2 points 1 week ago (1 children)

I'm questioning why things are being done in the way they're being done and you're saying I'm being close minded? Also spewing out some more jargon like that's going to impress me?

And LOL at "it will feel natural after you get used to it." I don't think you understand the concept about something feeling natural. Like I say I just make stuff const because someone put some bullshit in the linter. Enforcing dumb rules in a linter is the opposite of keeping an open mind, it forcing preferences on people.

I think I've confirmed it's just FE religious dogma. Just keep on repeating whatever Theo says and people will think you know what you're talking about.

[–] masterspace@lemmy.ca 3 points 1 week ago (1 children)

Lol good luck on that promotion, you seem difficult to be around.

I wonder how your company handles performance reviews when you already know everything about all types of programming?

[–] SpaceCowboy@lemmy.ca -1 points 1 week ago

Yup, it's definitely just some religious dogma going on there.

You think it's a good career choice to conform and never question anything so you wind up being indistinguishable from an LLM? Ok, good luck!