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.

state_electrician , in Someone escaped the Matrix

Farming is god-awful if your livelihood depends on it. I’d rather be a carpenter or a metalworker once I’m fed up with that computer stuff.

uis ,

Wielders are paid close to programmers in my country

_sideffect , in What the heck is a god dang cloud?

Oh you want to delete a file from your folder? Ok, we’ll also delete it from OneDrive so it’s gone forever, see ya!

potustheplant ,

Firstly, no, it’s not gone forever. It remains in your onedrive recycling bin for a month. Secondly, that behavior makes sense. One drive is a mirror of your synced folders. If you just want to not have the file downloaded in your computer, just right click on the file and select “free up space”.

_sideffect ,

It’s so obvious!

potustheplant ,

It is. Another indicator you get is a status icon next to each file telling you if the file is permanently or temporarily (meaning it will get auto-deleted locally if you don’t use it) dowloaded to your pc or if it’s only on the cloud.

Oh, and you also get a prompt when you delete a file letting you know that it will be deleted from onedrive as well but it will still be in the recycling bin for a while. The only way to not get that prompt is to tick a box to not get reminded again.

Microsoft software has a lot of flaws but this isn’t one of them.

Diplomjodler3 , (edited ) in What the heck is a god dang cloud?

Luckily I’m old, so I reflexively click the save button every few minutes anyway. Great progress there, Microsoft!

Norgur , in much profits, just 5 people on team, imagine sweet sweet bonuses
@Norgur@fedia.io avatar

"but... I explicitly described this in the frickin' 'Business Case' you had me fill out a thousand times!"

sus , in std::underflow_error

your underflow error is someone’s underflow feature (hopefully with -fwrapv)

Derp , in I made this

Except when a bug pops up somewhere. Ownership/Responsibility changes in sub-Planck-second time when assigning blame.

scrubbles OP ,
@scrubbles@poptalk.scrubbles.tech avatar

In our head nothing ever was wrong, bugs only came along when you came along! You should have been able to build it in days, what’s so hard about this?

ChaoticNeutralCzech , (edited ) in Saw 37 the software Dev

w3school

victorz ,

MDN ftw, screw stackoverflow.

Redkey ,

Any time I need to learn something about JS, I go to W3Schools to wrap my head around the basics, then over to MDN for current best practice.

victorz ,

I remember visiting W3S like 10-15 years ago when first learning DOM manipulation etc at uni. But nowadays there’s nothing it can give me that MDN can’t, that I need to know.

frezik ,

MDN is better at everything than w3school, except for SEO.

victorz ,

Yeah… Then again I just use the DuckDuckGo bang !mdn and it searches MDN directly.

There’s also devdocs.io which can be indispensable when using a lot of popular utility libraries and frameworks in the same project. Just having a single page with all the relevant docs is just a real blessing.

onlinepersona , in new preference war just dropped

I used to like the action followed by direct object format, until some time ago when trying to find methods or variables related to a specific object. If the action comes first, scanning for the object without an IDE means first reading unnecessary information about the action. That convinced me to opt for $object-$action in situations where it makes sense.

For example in CSS, I often scan for the element, then the action, so $element-$action makes more sense. BEM kinda follows this. When dealing with the DOM in JS, that makes sense too button.fileDialogOpen(), button.fileDialogSend(), … makes more sense when searching.

Of course one has to use it sensibly and where necessary. If you are writing a code that focuses more on actions than objects, putting the action first makes sense.

A similar thing is definition order.


<span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">main</span><span style="color:#323232;">(args):
</span><span style="color:#323232;">  result </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">do_something(args.input)
</span><span style="color:#323232;">  processed </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">process_result(result)
</span><span style="color:#323232;">  transformed </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">transform_object(processed)
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#323232;">transformed.field
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">do_something</span><span style="color:#323232;">(some_input):
</span><span style="color:#323232;">  </span><span style="color:#0086b3;">...
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">process_result</span><span style="color:#323232;">(result):
</span><span style="color:#323232;">  </span><span style="color:#0086b3;">...
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">transform_object</span><span style="color:#323232;">(obj):
</span><span style="color:#323232;">  </span><span style="color:#0086b3;">...
</span>

I find this much easier to follow than if main were defined last, because main is obviously the most important method and everything else is used by it. A flattened dependency tree is how these definitions make sense to me or how I would read them as newbie to a codebase.

Anti Commercial-AI license

gandalf_der_12te OP ,

I agree with you especially on the definition order of functions. I, too, define main() first.

sajran , in Not really sure whether S-expressions or Python indentation-based scoping get more hate...

So I’m going to say what I always say when people complain about semantic whitespace: Your code should be properly indented anyway. If it’s not, it’s a bad code.

I’m not saying semantic whitespace is superior to brackets or parentheses. It’s clearly not. But it’s not terrible either.

As someone who codes in Python pretty much everyday for years, I NEVER see indentation errors. I didn’t see them back when I started either. Code without indentation is impossible to read for me anyway so it makes zero difference whether the whitespace has semantic meaning or not. It will be there either way.

technom ,

Python decided to use a single convention (semantic whitespace) instead of two separate ones for machine decodeable scoping and manual/visual scoping. That’s part of Python’s design principle. The program should behave exactly like what people expect it to (without strenuous reasoning exercises).

But some people treat it as the original sin. Not surprised though. I’ve seen developers and engineers nurture weird irrational hatred towards all sorts of conventions. It’s like a phobia.

Similar views about yaml. It may not be the most elegant - it had to be the superset of JSON, after all. But Yaml is a semi-configuration language while JSON is a pure serialization language. Try writing a kubernetes manifest or a compose file in pure JSON without whitespace alignment or comments (which pure JSON doesn’t support anyway). Let’s see how pleasant you find it.

Crisps ,

This leads to weird bugs when you change indentation and miss a line or reorder lines. The logic changes. Not too bad when you’re on your own, as Python seems to be intended for. Add multiple developers and git merges and it is a recipe for disaster. With end tags at least you just end up with poorly formatted working code.

sajran ,

It’s probably more prone to mistakes like that, true. But in practice I really never witnessed this actually being a problem. Especially with tests and review.

eluvatar ,

The number of times I move code around and can just press a hotkey to fix indentation though. Not possible with Python.

sajran ,

Yeah, that’s definitely a good point. But it’s a minor thing. Adjusting indentation takes 2 keystrokes in vim, I barely notice it.

coloredgrayscale ,

Most IDEs support automatic code formatting, and doing so on save. Or have it as a github hook.

sajran ,

Of course, but when indentation has a syntactic meaning the formatter often won’t be able to fix it.

zqwzzle , in Unit Tests

Por que no los dos?

wreckedcarzz ,
@wreckedcarzz@lemmy.world avatar

Hooray! 🌮

nickwitha_k , in Not a Number

0*(NaN)… So does that mean the price IS a number?

rikudou ,

Isn’t any math operation involving NaNs also a NaN? At least that’s my gut feeling.

NegativeInf ,

Based on my frequent exploding and vanishing gradients, that would be a yes.

match ,
@match@pawb.social avatar

Thanks, relevant username!

nickwitha_k ,

Good point.

TheOakTree ,

If 0/0 is NaN, then does that mean 0NaN = 00/0 = 0?

tiredofsametab ,

In JS, it's just NaN if my browser's console is to be believed. I suspected it would probably be {object} for no clear reason

nickwitha_k ,

for no clear reason

JS That’s the reason. The language has an awful type system.

victorz ,

I think its type system is “okay”, I mean inherently dynamic typing is pretty error-prone. But its type coercion algorithms are bonkers. Also that whole “NaN ≠ NaN” business…

nickwitha_k ,

Also that whole “NaN ≠ NaN” business…

See that’s one of the parts that is actually almost in line with other languages. In Go, for example, nil ≠ nil because nil is, by definition, undefined. You can’t say whether one thing that you know nothing about is at all like something else that you know nothing about. It really should raise an exception at the attempt to compare NaN though.

victorz ,

If nil ≠ nil, how do you compare a variable to the literal?

nickwitha_k ,

You’d first check for nil values, then compare like normal. Extra step, yes, but it keeps you from hitting NPEs through that route.

victorz ,

You’d first check for nil values

What does this mean, if not the same as

then compare like normal

?

nickwitha_k ,

IIRC, a nil value can be checked against a literal successfully but not against another nil value. Say you want to check for equality of two vars that could be nil. You just need an extra if statement to ensure that you are not trying to compare nil and nil or nil and a non-nil value (that’ll give you a type error or NPE):


<span style="color:#323232;">var a *string
</span><span style="color:#323232;">var b *string
</span><span style="color:#323232;">
</span><span style="color:#323232;">...
</span><span style="color:#323232;">if a != nil && b != nil {
</span><span style="color:#323232;">  if a == b {
</span><span style="color:#323232;">    fmt.Println("Party!")
</span><span style="color:#323232;">  } else {
</span><span style="color:#323232;">    fmt.Println("Also Party!")
</span><span style="color:#323232;">}
</span>
victorz , (edited )

What I mean is that in JS you can’t do NaN != NaN, not even variable != NaN. So you’re not saying it’s the same in Go, since you can do a != nil?

nickwitha_k , (edited )

Kinda. nil is a weird value in Go, not quite the same as null or None in JS and Python, respectively. A nil value may or may not be typed and it may or may not be comparable to similar or different types. There is logical consistency to where these scenarios can be hit but it is pretty convoluted and much safer, with fewer footguns to check for nil values before comparison.

I’m other words, in Go (nil == nil) || (nil != nil), depending on the underlaying types. One can always check if a variable has a nil value but may not be able to compare variables if one or more have a nil value. Therefore, it is best to first check for nil values to protect against errors that failure to execute comparisons might cause (anything from incorrect outcome to panic).

ETA: Here’s some examples


<span style="color:#323232;">// this is always possible for a variable that may have a nil value. 
</span><span style="color:#323232;">a != nil || a == nil
</span><span style="color:#323232;">
</span><span style="color:#323232;">a = nil
</span><span style="color:#323232;">b = nil
</span><span style="color:#323232;">// This may or may not be valid, depending on the underlying types.
</span><span style="color:#323232;">a != b || a == b
</span><span style="color:#323232;">
</span><span style="color:#323232;">// Better practice for safety is to check for nil first
</span><span style="color:#323232;">if a != nil && b != nil {
</span><span style="color:#323232;">    if a == b {
</span><span style="color:#323232;">        fmt.Println("equal")
</span><span style="color:#323232;">    } else {
</span><span style="color:#323232;">        fmt.Println("not equal")
</span><span style="color:#323232;">    }
</span><span style="color:#323232;">} else {
</span><span style="color:#323232;">    fmt.Println("a and/or b is nil and may not be comparable")
</span><span style="color:#323232;">}
</span>
victorz ,

Thoroughly confusing lol. I think I need to check the spec in order to grasp this. I feel like this has more to do with the typing system rather than nil itself, maybe. I’ll see.

But yeah, this is nothing like null or undefined in JS, but more similar to NaN.

Thank you for trying to explain!

nickwitha_k ,

Yeah… It’s weird but I find it useful that it is, in a weird way. Treating it as an uncertainty means that one MUST explicitly check all pointers for nil as part of normal practice. This avoids NPEs.

RecluseRamble ,

I suppressed most of my former js knowledge but I guess it’s a string now.

mindbleach ,

Javascript carcinization.

FiskFisk33 ,

0*NaN = NaN

tyler , in What it's like to be a developer in 2024
anamethatisnt ,

Your result returns version 9.0 that went EOL 2021, same as Googles fourth result in OP.
nvm, second result is correct.

FierySpectre ,

Interesting how the second “correct result” is years older

AProfessional ,

Seems creation time not modified. Makes sense “current” is older.

tyler ,

yeah not ideal, but if the actual functionality of that operator hasn’t changed then I wouldn’t expect the version to matter. Same with searching most ruby stuff and getting old results. it hasn’t changed in decades, it ain’t changing now. But I did scroll down and literally every result was from the postgres docs so that’s a marked improvement from the google results.

victorz ,
82cb5abccd918e03 ,

Yandex:

https://lemmygrad.ml/pictrs/image/7950c84c-3ee1-49ec-9971-5070a106fe30.png

First result with a more up to date version. No AI, only quotes from the source. Still shows a bunch of SEO.

Omgarm , in What it's like to be a developer in 2024

On duckduckgo it was only the the 4th result! Pretty decent.

snaggen ,
@snaggen@programming.dev avatar

Had to test with Kagi also, leads with official documentation, after that tutorials and unofficial things. Nothing obviously irrelevant. The only thing with the Kagi results, was that there were a few very simmilar official documentation links (for different postgresql versions) at top. But, still good search results. Not sure why anyone is still using google, when there are quite a few better alternatives availale

Kidplayer_666 ,

The power of defaults, comfort, not wanting to pay, and probably worse non English results

Emmie , in AI Suggestions

Ai wIlL eNsLAve huMaNs aNd rUlE tHe wOrLD

AI:

dariusj18 ,

If anything this is a great example of why that could happen. Simple leaps of logic without context.

Emmie , (edited )

I am just making fun of all those AI doomsayers on Reddit. It’s nowhere close enough to be even called such. It’s just a mindless algorithm, a tool. Math operation. Are calculators smart? Well yes from a certain point of view.

stepan , in I still don't get buffers

Same thing but reversed with multiple cursors :/

whats_all_this_then OP ,

That’s actually the biggest thing I miss about VSCode

chihiro ,

github.com/mg979/vim-visual-multi

I also missed multiple courses, but I started using vim-visual-multi in my nvim config and it’s been great. There’s a few others I tried that I couldn’t get to work quite right (usually some weird conflict with nvim-cmp) but I’ve had the best success with vim-visual-multi.

whats_all_this_then OP ,

I’m gonma bookmark and try this next time I find the courage to mess around my nvim config. That last none_ls breaking change has made me very hesitant to mess around with things that aren’t just colorschemes ngl.

stepan ,

I also tried github.com/smoka7/multicursors.nvim and the experience was horrible. Then I tried github.com/…/multiple-cursors.nvim and I absolutely love it. It has conflict with cmp, but the README has great tutorial on disabling cmp only when using multiple cursors, and dealing with other plugins to maks them work or disable them in the multicursor mode.

JoYo ,
@JoYo@lemmy.ml avatar

helix has a pretty good mc system in the select mode.

Jumuta ,

search in selection is such a cool workflow

JoYo ,
@JoYo@lemmy.ml avatar

yah ive been swapping to hx wherever i need to do refactoring, it’s too good to miss out.

space-r ename symbol for easymode.

whats_all_this_then OP ,

This feels like something I also do in neovim unless I’m misunderstanding you completely. Is it highlighting text and having yoir search apply just to the highlighted text?

If so, yes it’s great whenever you use it

Jumuta ,

yeah, and helix spawns a cursor at every match

whats_all_this_then OP ,

I’ve been meaning to check helix out for a while now but haven’t found the time :(

pfannkuchen_gesicht ,

huh?

Sotuanduso ,

Same here, but Atom. Maybe I should start using Atom again.

thanatotus ,

FYI atom project is dead. There is a community form available but it was to buggy for me.

Sotuanduso ,

I know it’s dead. I still have it, and it still does all I want from an IDE.

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