this post was submitted on 22 Nov 2025
1 points (100.0% liked)

Programmer Humor

31990 readers
334 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 3 years ago
MODERATORS
 

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

top 14 comments
sorted by: hot top controversial new old
[–] mindbleach@sh.itjust.works 0 points 7 months ago (1 children)

()=>{}

Javascript straddling the middle as usual.

[–] masterspace@lemmy.ca 0 points 7 months ago* (last edited 7 months ago) (1 children)

The equivalent in JavaScript / TypeScript would actually be function () {}, this is the syntax for named functions.

C# is the same as bash though.

[–] mindbleach@sh.itjust.works 0 points 7 months ago (1 children)

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

[–] Ghoelian@piefed.social 0 points 7 months ago (1 children)

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

[–] SpaceCowboy@lemmy.ca 0 points 7 months 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 0 points 7 months 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.

[–] SpaceCowboy@lemmy.ca 0 points 7 months ago (1 children)

Pushing something onto an array isn't changing the array? It's not changing the reference to the array, but from a style standpoint it doesn't make sense.

And if you're declaring a const within the scope of a function, it's still allocating memory when it enters the scope and disposing it when it leaves the scope, same as a variable. There's no performance benefit to do this.

Something like const CONSTANT_VALUE = "This never changes" has a performance benefit and is actually how other languages use constants. The value will always be the same, the compiler understands this and can optimize accordingly. If you're declaring an iterator or the result of calling a webservice to be const it'll be a different value every time it runs that code, so it's not something a compiler can optimize. In style terms, it's a value that's different every time you get to that line of code, so why would you want to call it constant?

You're comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work. But of course many religious beliefs originate from a misunderstanding of the world. Whatever man, I just make it a const to make the linter happy, because it's dumb FE bullshit LOL.

[–] masterspace@lemmy.ca 1 points 7 months ago (1 children)

Lol.

Pushing something onto an array isn't changing the array? It's not changing the reference to the array, but from a style standpoint it doesn't make sense.

So you're arguing for writing things as they seem, not the way that computers treat them?

You're comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work.

Maybe rethink this.

[–] SpaceCowboy@lemmy.ca 0 points 7 months ago (1 children)

A constant inside a function is not constant to the computer. It's only constant within the scope of the function. So it's not constant to the computer since every time the function is called the "constant" will have a different value.

Do you even know what a real constant is?

You maybe need to rethink some things.

[–] masterspace@lemmy.ca 1 points 7 months ago

That variable is only created when the function is run, and it holds a constant value for the entirety of its lifetime.

It is literally constant from the perspective of the computer executing it. You're the one adding an extra layer of expectation here.

[–] brian@programming.dev 0 points 7 months ago (1 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

[–] SpaceCowboy@lemmy.ca -1 points 7 months 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.

[–] masterspace@lemmy.ca 1 points 7 months ago* (last edited 7 months ago)

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.

[–] brian@programming.dev 1 points 7 months ago

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