There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

eran_morad , in Guess what my favourite language is:

Gotta be R.

notsure , in Programmer tries to explain binary search to the police
@notsure@fedia.io avatar

everyone is a little bit gay!

belated_frog_pants , in huggingface.co

I dont get it

sin_free_for_00_days ,

AI leading us cavemen into the future.

kamen , in Unused variables

Imagine lint running on format and your linter removing unused variables: you start typing, hit format by muscle memory before using the variable. Rinse and repeat.

TechNerdWizard42 , in Some of my iterations are delightfully recursive

Ah yes the X86 instruction set for mapping.

Everything is a conditional branch loop. Always has been.

Username ,

There also isn’t a loop instruction though.

TechNerdWizard42 ,

It’s a conditional branch… You make that into a loop. Branch if zero, branch if not zero, etc.

dylanTheDeveloper , in Unused variables
@dylanTheDeveloper@lemmy.world avatar

I’m not a CS major but why exactly does having a variable or parameter that’s not used in C, C# and C++ throw a warning

Prunebutt ,

It’s probably gonna be optimized out by the compiler. However, linters will mark it for you, since it suggests that you actually wanted to do something with that variable and forgot about it after declaration.

… Or it can be removed to reduce visual noise once it’s not necessary anymore after refactoring.

Shareni ,

Because it’s code that literally doesn’t do anything. Some languages won’t even let you compile without special instructions.

gens ,

Lets say you use a variable named abcd in your function. And a variable named abcb in a for loop inside the same function. But because reasons you mistakenly use abcd inside that loop and modify the wrong variable, so that your code sometimes doesnt work properly.

It’s to prevent mistakes like that.

A similar thing is to use const when the variable is not modified.

morrowind , in Unused variables
@morrowind@lemmy.ml avatar

Word proccessors have had this figured out for ages, I wonder why it’s so hard to implement this QoL change for code

RagingRobot ,

How do you mean? You can’t type a word without using it in a word processor. Once the word is typed out it’s been used. Variables need to be declared then used so 2 separate steps.

ricdeh ,
@ricdeh@lemmy.world avatar

What do you mean? Variables do not necessarily need to be used, you can allocate memory for some value and initialise it but then simply don’t do anything with it.

DacoTaco ,
@DacoTaco@lemmy.world avatar

You can but compilers will optimise that away unless you tell it not to.

Shareni ,

Meanwhile go: you will remove it or I won’t compile, unless you know the secret handshake

RagingRobot ,

Yes you can but the little red squiggles show in your editor to warn you that it’s unused code. That’s what the whole post is about lol

morrowind ,
@morrowind@lemmy.ml avatar

There’s no direct equivalent but word like won’t bother me about spelling or grammar until I’m done typing that part

ExperimentalGuy , in The "Java Life" Song

This is so bad I can’t look away

LinearArray , in The "Java Life" Song
@LinearArray@programming.dev avatar

This goes hard

cruxialwd , in Unused variables
@cruxialwd@programming.dev avatar

Programming with Java be like :v

labsin , in Unused variables

I start writing the implementation and get the “variable not defined” error and then let the ide add the declaration. It’s less keys to press and misspell.

dojan , in Unused variables
@dojan@lemmy.world avatar

I recently started poking with Vue, For the most part when it comes to webapps I’ve mostly worked with React, Blazor, and a touch of Svelte. The linter is so aggressive. I start defining a method and it instantly goes “IT DOESN’T RETURN ANYTHING!!”

Okay, thanks! I literally just defined the return type!

CanadaPlus , in Some of my iterations are delightfully recursive

Unironically this. I know it’s the same assuming there’s no bugs (lol), but it’s just faster to type and easier to read, at least to me.

ByGourou ,

I always found map more confusing than loop for some reason. Especially nested.

CanadaPlus ,

To each their own.

dudinax , in Unused variables

Me: <starts a heredoc>

jetbrains: This heredoc goes on FOREVER!

Me: I’m going to close it…

jetbrains: <dies>

tiredofsametab , in My wife was unimpressed by Vim

As someone who's been a software developer for over a decade and in IT even longer, I still don't use vi/vim for anything other than when crontabs have it set as the editor.

SpaceNoodle ,

alias vi=nano

tiredofsametab ,

You can set your default editor (maybe in .bashrc or .bash_profile? I forget), but I'm far too lazy.

PureTryOut ,
@PureTryOut@lemmy.kde.social avatar

export EDITOR=nano.

But (neo)vim is amazing so there is no need to do that.

SpaceNoodle ,

I transfer all my files over to a Windows machine and edit them in Notepad

ryannathans ,

Based nano user

From my .zshrc (typing this on mobile so cope if it’s wrong)


<span style="color:#323232;">case "$OSTYPE" in
</span><span style="color:#323232;">  linux*)
</span><span style="color:#323232;">    export EDITOR=nano
</span><span style="color:#323232;">  ;;
</span><span style="color:#323232;">  freebsd*)
</span><span style="color:#323232;">    export EDITOR=ee
</span><span style="color:#323232;">  ;;
</span>
lil ,
@lil@lemy.lol avatar

I guess shell languages can’t do this:


<span style="color:#323232;">export EDITOR=case "$OSTYPE" in
</span><span style="color:#323232;">  linux*)
</span><span style="color:#323232;">    nano
</span><span style="color:#323232;">  ;;
</span><span style="color:#323232;">  freebsd*)
</span><span style="color:#323232;">    ee
</span><span style="color:#323232;">  ;;
</span>
ryannathans ,

That would be too smart. Smells like kotlin’s when

SpaceNoodle ,

Put backticks around the entire case statement, and you can.

Hexarei ,
@Hexarei@programming.dev avatar

Honestly if you don’t use vim motions in your ide of choice, you’re missing out big time. Being able to do things like “Delete everything inside these parentheses”. di( or “wrap this line and the two lines below r in a pair of {}” ys2j{ , or “swap this parameter with the next one” cxia]a. with a single shortcut is game changing.

Even just being able to repeat an action a number of times is ridiculously useful. I use relative line numbers, so I can see how many lines away a target is and just go “I need to move down 17 lines” and hit 17j.

Absolutely insane how much quicker it is too do stuff with vim motions than ctrl-shift-arrows and the like

tiredofsametab ,

That's really neat, but I don't think I do that often enough to really make the performance hit of learning a whole new thing and memorizing keyboard shortcuts and commands worth it. I don't find myself refactoring code a ton, especially after moving to a more TDD-like model.

Hexarei ,
@Hexarei@programming.dev avatar

It’s less about refactoring and more about navigation of your code while editing. Ever wanted to delete a single word? daw deletes the word your cursor is currently in. How about "copy everything up to (but not including) the nearest “D” on the current line? yfD.

The whole point is that editing code in the middle of writing it, not just refactoring it, is immensely faster.

oce ,
@oce@jlai.lu avatar

Absolutely insane how much quicker it is too do stuff with vim motions than ctrl-shift-arrows and the like

Those tasks are a very small part of work time, so most people don’t feel the need to optimize it.

Hexarei ,
@Hexarei@programming.dev avatar

As a software dev, they’re significant parts of what I do

oce ,
@oce@jlai.lu avatar

Are you one of those rare developers who spend most of their day actually coding?

Hexarei ,
@Hexarei@programming.dev avatar

Yes, absolutely. And I refuse to let my day be anything else! :-)

trxxruraxvr ,

Only if you use a qwerty keyboard, otherwise it’s just annoying as shit

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • [email protected]
  • lifeLocal
  • goranko
  • All magazines