947
Variable Declaration (programming.dev)
top 32 comments
sorted by: hot top controversial new old
[-] perviouslyiner@lemmy.world 123 points 8 months ago* (last edited 8 months ago)

"oh, the line you are typing is incomplete and therefore the whole file is invalid which means there is nothing to suggest for autocomplete"

[-] 4am@lemm.ee 14 points 8 months ago
[-] EinfachUnersetzlich@lemm.ee 1 points 8 months ago

Reminds me of VB6.

[-] smeg@feddit.uk 79 points 8 months ago

Compiler: you're skating on thin ice there you fucking maverick

[-] GBU_28@lemm.ee 17 points 8 months ago

Hot doggin and grab assin. Not in my house.

Fuckit, red squiggly.

[-] joyjoy@lemm.ee 44 points 8 months ago

Meanwhile rust when you try to use a variable before saving.

[-] scutiger@lemmy.world 40 points 8 months ago
[-] Tetsuo@jlai.lu 9 points 8 months ago

Oh no you have to say it out loud EVERY time ?

[-] synae@lemmy.sdf.org 24 points 8 months ago

I didn't just say it, I declared it!

[-] treechicken@lemmy.world 24 points 8 months ago

...and then there's Go who just won't let you compile at all

[-] dvlsg@lemmy.world 37 points 8 months ago

Just enable format-on-save. That way gofmt can helpfully delete that variable you just added that you were for sure never going to use. You're welcome!

[-] shield_gengar@sh.itjust.works 6 points 8 months ago

My thing is imports. Like, why, why do you delete it right after I typed it in and saved?

[-] marcos@lemmy.world 13 points 8 months ago

Go will not calm down! Go will NEVER calm down!

How DARE! YOU! suggest Go to calm down!?

[-] joyjoy@lemm.ee 4 points 8 months ago

This files seems to be generated. DO NOT EDIT.

[-] pipe01@programming.dev 3 points 8 months ago
[-] Anticorp@lemmy.world 18 points 8 months ago

It's a no win situation, because it'll throw a fit if you try to use it before you declare it too.

[-] humorlessrepost@lemmy.world 16 points 8 months ago* (last edited 8 months ago)

I don’t understand?

Notepad likes my html, and filezilla doesn’t complain when I upload it to production. It even passes validation for 4.01 transitional

[-] Venator@lemmy.nz 16 points 8 months ago* (last edited 8 months ago)

Sometimes I think it could be easier to just use the variable before its declared and then let the IDE auto fix create it, but I never remember to try it 😂

[-] baseless_discourse@mander.xyz 16 points 8 months ago* (last edited 8 months ago)

writing code normally

ocaml-lsp: syntax error

ocaml-lsp: syntax error

ocaml-lsp: syntax error

ocaml-lsp: syntax error

ocaml-lsp: okay, probably okay

ocaml-lsp: syntax error

ocaml-lsp: syntax error

ocaml-lsp: wait, the entire function is wrong

me: WHAT, where

ocaml-lsp: like the entire thing, 20 lines of it,

a -> (b -> c -> d) -> [200 other types] ->g

doesn't match

a -> (b -> c/2 -> d) -> [200 other types] ->g

, c doesn't match c/2.

[-] myxi@feddit.nl 9 points 8 months ago* (last edited 8 months ago)

I turn off LSPs during my train of thoughts. I don't want all red and yellow underline bullshit to disrupt my thoughts. Like, calm the fuck down. I WILL write the correct code eventually; just give me some fucking time.

Well, I use Neovim, so turning off the LSPs or restarting them is sufficiently simple.

When I work on a new project, or on a new feature, I temporarily turn off the LSP, and rely on the compiler to figure out where the code errors. Plain white text gives me the freedom to write whatever the fuck I want without any disruption. Of course, I eventually turn on the LSP again to fix the little issues.

[-] baseless_discourse@mander.xyz 3 points 8 months ago* (last edited 8 months ago)

Many languages allow type hole like _ to indicate to the compiler/lsp that this is an expression you will fill in later.

So that lsp don't put a squiggle on the entire program, only the type hole

[-] myxi@feddit.nl 2 points 8 months ago* (last edited 8 months ago)

I also leave out little syntax errors and only only focus on the rough idea during my train of thoughts. And the variables, aren't really supposed to be implied as private or unused -- I do eventually meaningfully use them. If I have to prefix all my variables with a underscore to avoid the LSP, I might instead just disable the LSP. When I eventually turn the LSP back on, it tells me the actually unused variables and imports that I can now get rid of.

Because of the LSP, I used to write maybe three hundred lines of code per hour, but now I probably average at least five hundred or more.

[-] RonSijm@programming.dev 8 points 8 months ago

On the other hand, when my IDE doesn't tell me:

Build Server: "BUILD FAILED! SonarQube says that Roslyn says that you're not using one of your variables!"

Yea okay calm down, and why are you snitching now, Roslyn? Should have told me directly 🙃

[-] jimmy90@lemmy.world 5 points 8 months ago

#![allow(warnings)]

:)

[-] aliyss@programming.dev 4 points 8 months ago

Just type faster than the LSP needs to check. I don't see an issue.

[-] fidodo@lemmy.world 3 points 8 months ago

What is this? I've never seen it before! Where are you using it?

[-] CrypticCoffee@lemmy.ml 2 points 8 months ago
[-] Luvon@beehaw.org 10 points 8 months ago

It’s more language dependent than ide. Go for instance makes unused variables a compiler error (I believe) which means ides mark it as red immediately.

Ts/js can have eslint rules against unused variables but they will still usually compile or just run directly anyway.

Java doesnt error but can be set to warn you on them.

Abap doesn’t care and won’t tell you.

Your mileage will vary.

[-] qaz@lemmy.world 2 points 8 months ago

I've seen it with multiple IDE's

[-] clearleaf@lemmy.world 1 points 8 months ago

In godot engine you can put an underscore at the beginning of a variable to tell the linter to calm the hell down about it. But I don't see why it's such a crisis in the first place.

[-] cookie_sabotage@sh.itjust.works 4 points 8 months ago

The underscore is actually used to indicate the variable will not be used.

[-] nickwitha_k@lemmy.sdf.org 2 points 8 months ago

I agree, if talking about the warning. If talking about the unused var, Go won me over there. Unused vars are absolutely a class of software bug that can have implications in security, resource usage, and maintainability.

this post was submitted on 27 Mar 2024
947 points (98.2% liked)

Programmer Humor

19623 readers
1 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 1 year ago
MODERATORS