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.

ArbitraryValue , in Is this a Nut?

I am static_casting the nut_t*. Pray I don’t static_cast it any further.

corroded ,

reinterpret_cast<int*>(&a_nut)

I like to live dangerously.

7heo , in POV: Working at Google

That isn’t real. It wouldn’t pass peer review. Here is the actual code:


<span style="font-weight:bold;color:#a71d5d;">function </span><span style="font-weight:bold;color:#795da3;">GetCookieValue</span><span style="color:#323232;">(x) {
</span><span style="color:#323232;">  </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#323232;">JSON.stringify(x);
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">user.cookies.agreed </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">Boolean(GetCookieValue(</span><span style="color:#0086b3;">true</span><span style="color:#323232;">));
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">if</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">!</span><span style="color:#323232;">DarkPatternPopup()) {
</span><span style="color:#323232;">  </span><span style="font-style:italic;color:#969896;">// Make sure we respect the user choice
</span><span style="color:#323232;">  user.cookies.agreed </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">Boolean(GetCookieValue(</span><span style="color:#0086b3;">false</span><span style="color:#323232;">));
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">if</span><span style="color:#323232;">(user.cookies.agreed) CollectData(user);
</span>
_cnt0 , (edited ) in Is this a Nut?
@_cnt0@sh.itjust.works avatar

I just dabbled in javascript again, and that description is spot on!

console.log(‘javascript operators are b’ + ‘a’ + + ‘a’ + ‘a’);

sjmarf OP ,

BaNaNa

hypnicjerk ,

Terracotta

fishbone ,

Pepperoni and green peppers, mushrooms, olives, chives!

Oh wait wrong song.

krippix ,

I can‘t believe you’ve done this

_cnt0 ,
@_cnt0@sh.itjust.works avatar

Well, not by accident.

arc , (edited )

The only reason people use JS is because it’s the defacto language of browsers. As a language it’s dogshit filled with all kinds of unpleasant traps.

Here is a fun one I discovered the other day:


<span style="color:#323232;">new Date('2022-10-9').toUTCString() === 'Sat, 08 Oct 2022 23:00:00 GMT'
</span><span style="color:#323232;">new Date('2022-10-09').toUTCString() === 'Sun, 09 Oct 2022 00:00:00 GMT'
</span>

So padding a day of the month with a 0 or not changes the result by 1 hour. Every browser does the same so I assume this is a legacy thing. It’s supposed to be padded but any sane language would throw an exception if it was malformed. Not JavaScript.

chatokun , in Good luck speed camera 📸

Little Bobby Tables’s car?

chahk ,

He goes by Robert D. Tables now.

BurningTurtle ,
@BurningTurtle@programming.dev avatar
gandalf_der_12te , in Is this a Nut?

In Java, it’s not called the Crackable interface.

It’s the Nuttable interface.

fishbone ,

How do I know if something is Nuttable?

Benaaasaaas ,

Actually it’s AbstractNutAndShellsFactory

steeznson ,

Provided your method specifies a strongly bound type you can ensure that you get your nut.


<span style="color:#323232;">void dischargeNut(T extends Nut) { ... }
</span>
gandalf_der_12te ,

strongly bound you say?

RonSijm , in Is this a Nut?
@RonSijm@programming.dev avatar

StackOverflow: Question closed as duplicate. Someone else already asked whether or not something is a nut.

Steve ,

1 answer: use the fucking search

Poutinetown ,

First search result brings you to this answer.

Ironfacebuster ,

“Question closed as duplicate”

The question it’s a duplicate of: “How to programmatically prove a hotdog is a sandwich?”

ADTJ ,

“It’s 2024! Why are people still trying to classify nuts? Just use some expensive cloud solution that doesn’t really solve your problem”

MonkderZweite , (edited )

How long to hard-boil an egg?

Seriously, i just googled how much energy would be needed to put 1Kg in LEO. Ofc there’s a StakOverflow to it asking the same question and none of 4 answers answer the question and one is like “This seems like a complicated way of doing it. Instead of asking the minimum energy…”.

LillyPip , in Good luck speed cameras

Little Bobby tables learns to drive.

This is smart. When my son was learning, I put a magnetic ‘student driver’ sign on my car, too. More people should do this. It’s just polite.

snugglesthefalse ,

L plates are a legal requirement here if that’s what you mean

LillyPip ,

They’re not required here. You just plop your child in your regular car with no changes whilst they’re learning. It’s insane. I bought a magnetic sign to warn people though, because that seems nuts to me.

I was making a joke tho.

The_Tired_Horizon , in Good luck speed cameras
@The_Tired_Horizon@lemmy.world avatar

Reminds me of the woman that got a fine for “driving in a bus lane” here in the UK. When she looked at the attached image on the fine it was of a woman walking in the street of a town she’d never been to. On that woman’s jumper was lettering that closely resembled her plates.

Made me think I could attach a sheet of card with the plate details of some arsehole I disliked, ride a bicycle down the bus lane and see if they start complaining about being fined. 😅

Dr_Cog ,
@Dr_Cog@mander.xyz avatar

They’ll get the picture in the fine letter so make sure you give them your best one-finger salute

The_Tired_Horizon ,
@The_Tired_Horizon@lemmy.world avatar

Well I was on google streetview giving their camera the finger, LOL!

spizzat2 , in Is this a Nut?

Ce n’est pas une cacahuète

winterayars , in Is this a Nut?

Ruby: No, it has been redefined as the number 5 so buckle your seatbelts, kiddos, cuz shit’s about to get wild!

AeonFelis , in Is this a Nut?

C# should actually be “What Java said, except it’s ICrackable”.

callumbirks ,

Would the equivalent Rust trait be Crack?

blackstampede ,

AsCrack

taaz ,

Into<dyn AsCrack>

class_d_fire ,

Into’s type parameter has an implicit Sized bound. I think AsRef<dyn Crack> would be the trait of choice :D

Hazzia ,

pervert

warlaan ,

No, actually C#'s answer should be: “What Java said - hold on, what Python said sounds good too, and C++'s stuff is pretty cool too - let’s go with all of the above.”

C#, or as I like to call it “the Borg of programming languages”.

dependencyinjection ,

I got my first software developer role last year and it was the first time I’d written C#, I was more TypeScript. Now we use both but I must say I really like C# now that I’m used to it.

LeFantome ,

I think most programmers would like C# if they spent time with it. It is getting a bit complex because the joke about it over borrowing from other languages is on the money. It is a nice language though and pretty damn fast these days all things considered.

Scoopta ,
@Scoopta@programming.dev avatar

There’s too much MS in the language and runtime for me. The fact that it gives my Linux programs DLL files and the fact that by default the SDK phones home makes me run away in horror from not only writing it but also running other projects written in it.

force ,

even nicer is F#. join us brother, you can do everything that you can do in C# but better

dependencyinjection ,

What does it offer that would make it better? Just curious and I’m not in a position to change out tech stack at work though.

force , (edited )

The biggest selling point about functional languages for me is the type system, mainly algebraic/union types (which imo Scala does the best), pattern matching (and imo Rust does this best), and the incredible type inference, but also all the functional features. But I think the best part about F# specifically comparing it to C# is the removal of a shit ton of the boilerplate. Plus data is immutable by default, always a nice touch.

For F#, the special types may not be super relevant when interacting with C# libraries, but in general you can do everything in F# that you can do in C#, including all the OOP. It’s just an added bonus that you basically get enums on steroids and pattern matching.

I find that writing in F#, even if I write basically the same code I would in C#, speeds up my design/programming a TON and makes it significantly more maintainable and easy to navigate. There’s a lot less clutter and you don’t have to worry about the layers upon layers of repetitive boilerplate.

The only downside IMO is that F# can have some terrible error messages. And of course, you have to learn F# syntax which can be a small pain if you’ve never used ML or Haskell (especially when it comes to function call syntax). But if you’re mainly interfacing with C# libraries then it’s no big deal. I started making an application only utilising C# libraries (mainly DB stuff) the same day I started using F# and it went relatively smoothly, although probably because Rust is the main language I used then.

This resource might help, although I can’t say it’s enough to completely learn the language: fsharp.org/learn/

Bishma , in Is this a Nut?
@Bishma@discuss.tchncs.de avatar

Whatever the Tiger 2-XL was “programmed” in, it’s the best.

WhiskyTangoFoxtrot ,

Thought this was a YTP at first.

Bishma ,
@Bishma@discuss.tchncs.de avatar

No, just an early 90’s toy commercial. Which is probably a video genre of it’s own.

Kolanaki ,
@Kolanaki@yiffit.net avatar

It feels like it with how often YouTube keeps recommending me channels of nothing but commercials from the 90’s.

FriendBesto , in Good luck speed cameras

This is awesome. Saved. LOL

riodoro1 , in Is this a Nut?

All those memes picturing C++ as unsafe and unstable yet the server that serves these memes is running mostly C/C++ and has an uptime of months.

arc ,

Lemmy is written in Rust. There might be bits of C at the periphery behind bindings.

riodoro1 ,

And linux is written in C.

arc ,

Predominantly C. But even the kernel is beginning to use Rust as a way of avoiding entire classes of programming error.

MonkderZweite , (edited )

They implemented some sort of OOP tho.

edit: I meant: the Linux devs implemented some sort of OOP in their C code in the kernel – is something i read forever ago.

arc ,

Rust isn’t really OOP like C#, Java or C++ - it has structs with functions that you could consider an “object” but there is no inheritance. Instead Rust uses traits which are a little bit like interfaces in some languages.

The way the kernel is using Rust at the moment is to produce safe bindings for modules to be written in Rust, i.e. you can create a module in Rust source which will be correctly loaded up, the code is safe by default and will have access to kernel services via bindings. I expect over time that more of the kernel will become Rust, but the biggest impediment right now is Rust relies on LLVM and LLVM only supports a subset of targets that a kernel could potentially support with another compiler like gcc.

vox ,
@vox@sopuli.xyz avatar

well and it’s only running this well because of decades of effort and millions of effort spent on security reviews

CosmicCleric ,
@CosmicCleric@lemmy.world avatar

Lemmy is written in Rust.

Wow, way to ruin my joke.

AMDIsOurLord ,

Also they’re always treating C++ like it’s some arcane enterprise variant that uses 1990s C++

Using modern C++ you can write much cleaner, more usable, and really safe code

riodoro1 ,

Having a thorough process and an engineer approach in software development is also pretty handy. There weren’t many bugs in the AGC. Yet it was programmed mostly in assembly and people had no trouble trusting it with their life.

CanadaPlus ,

True, but that’s partly because the Linux is beyond mature, and you can ferret out a lot of bugs with millions of users over decades.

CosmicCleric ,
@CosmicCleric@lemmy.world avatar

yet the server that serves these memes is running mostly C/C++

Time to rewrite it in Rust!

/ducksandruns

pewgar_seemsimandroid ,

if i remember lemmy is written in rust

CosmicCleric ,
@CosmicCleric@lemmy.world avatar
Scoopta ,
@Scoopta@programming.dev avatar

Lemmy is rust and it’s alternative sublinks is java…your comment has now power here

sonymegadrive , in Is this a Nut?

C++: Nuh, uh …


<span style="font-weight:bold;color:#a71d5d;">template </span><span style="color:#323232;"><</span><span style="font-weight:bold;color:#a71d5d;">typename</span><span style="color:#323232;"> T>
</span><span style="color:#323232;">concept Crackable </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">requires(T obj) {
</span><span style="color:#323232;">    { obj.crack() };
</span><span style="color:#323232;">};
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">auto </span><span style="font-weight:bold;color:#795da3;">crack</span><span style="color:#323232;">(Crackable </span><span style="font-weight:bold;color:#a71d5d;">auto& </span><span style="color:#323232;">nut) {
</span><span style="color:#323232;">    nut.crack();
</span><span style="color:#323232;">}
</span>
Aatube ,

This is dangerous. The object might not have the crack() method, and this bloats the compiled size by a lot if you use it with different types. There's also no reason I can see to use concepts here. The saner way would probably be to use inheritance and objects to mimic Java interfaces.

sonymegadrive ,

This is dangerous

Well, they say you do have to be over 18 to use Concepts

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