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.

Zabuxx , in Sometimes I want to call malloc, just as a treat

It’s funny because it’s true…

frezik , in Sometimes I want to call malloc, just as a treat

Years ago, older C programmers told me you don’t know C unless you use dynamic memory management. I ended up rarely writing any C, but when I do, it’s usually on microcontrollers where dynamic memory management isn’t even supported out of the box.

Jokes on you, greybeards!

sping ,

Though as a non-embedded dev who has interviewed embedded candidates I like to ask them to talk about the issues around C vs C++ for embedded and the first point 8 out of 10 of them make is C++ is bad because dynamic allocation is bad. And while they could expand to almost sort of make their point make sense, they generally can’t and stumble when I point out it’s just as optional in each.

Scrath ,

Can you give some examples of what you consider to be the issues?

My professor said that C++ embedded compilers used to be very buggy but have matured quite a lot as of ~10 years ago while C was stable a lot longer.

Another thing I could think of is the language complexity causing higher resource usage, e.g. by including large libraries though I’m not sure about that since most of the unused stuff should theoretically get optimized out.

I guess if you don’t know roughly how the internals of some C++ data types work it could cause you to accidentally use dynamic memory allocation when using strings or vectors.

On the other side, C++ style casts provide more safety as compared to C style casts and allows for usage of references instead of raw pointers to make the code generally safer.

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

Yeah, I get where they’re coming from–in typical use cases, C is often used with static allocation (correlated with minimal/embedded devices) while C++ is often used with dynamic allocation (correlated with enterprise/GUI applications).

Of course you can use either for either purpose, but that pattern seems more common. That being said, I’d be concerned with applicants who don’t understand that.

itsnotits ,

Joke’s* on you

AnarchoSnowPlow , in Sometimes I want to call malloc, just as a treat

DON’T YOU DO IT!

DON’T YOU FUCKING DO IT!

KEIL ALREADY REQUIRES A BLOOD SACRIFICE YOU’RE KILLING US ALL YOU FOOL!

KingJalopy , in Sometimes I want to call malloc, just as a treat

For real though I have wanted for years to know, the person that took this picture; what the hell did they say to get everybody to look like that?

Cqrd ,

It’s not quite as interesting as you might hope:

On November 12th, 2012, YouTuber LifeAccordingToJimmy posted a video titled “Don’t Stop the Music,” a skit based on the awkward moments caused when the music stops at a party and a story one is telling is overheard by others. In the sketch, the music stops as the main character says something particularly strange, causing the partygoers to stare at him. The video gained over 4.2 million views (shown below).

youtu.be/DHQEJoqKiBg?t=1m8s

Source

KingJalopy ,

Oh shit you’re right. That was really lame.

Edit. Okay, I click the link before you edited it and I just watched the whole video and that was actually kind of funny but still not as cool as I hoped.

ChickenLadyLovesLife ,

“Where are the blue cups?”

Ephera , in Sometimes I want to call malloc, just as a treat

Nevermind using such frivolous things as a file system.

bus_factor ,

Using a file system is much less bad than dynamically allocating memory, at least as long as you keep a predefined set of files.

troyunrau ,
@troyunrau@lemmy.ca avatar

I hate to alarm you but… What is a file system except dynamically allocated memory. ;)

Redkey ,

It’s a persistent dynamic memory allocation that’s accessed by multiple processes! :)

bort , (edited )
noli ,

FreeRTOS tasks are basically processes, IIRC other rtoses have similar mechanics too

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

If you want to get really freaky, try accessing the same flash or RAM from multiple instances of FreeRTOS running on a hypervisor.

noli ,

Is that just like the shared memory model of parallel computing or are there any added complications? Have you done this before? Please do share your experiences if so cause now I’m interested :p

owenfromcanada ,
@owenfromcanada@lemmy.world avatar

It’s similar, but the general idea of a hypervisor is to separate resources and avoid this exact situation (it’s nuanced and there are some exceptions, but that’s the general use case).

The added complication would be that when you compile a binary for one virtual machine, the compiler may optimize things, blissfully unaware that there are other players possibly affecting memory. In a typical multithreaded environment, the compiler has a better picture of how shared resources are being used across threads, but that has to be declared manually for a hypervisor. So if you configure your hypervisor to share resources, you have to be even more vigilant in configuring the individual compilers to play nice.

I don’t have a ton of experience with embedded hypervisors, though. And it’s worth noting that there are lots of “hypervisors” out there, and some work very differently from others.

frezik ,

Lots of microcontrollers have multiple cores now.

sunbeam60 ,

And indeed, with memory mapped files the distinction almost disappears completely.

kevincox ,
@kevincox@lemmy.ml avatar

a predefined set of files

…with predefined sizes located in predefined regions of storage.

bus_factor ,

Yeah, that’s what I was implying, just didn’t want to write a whole novel about it.

Agent641 , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

Its illegal to reboot a server without first saying quietly “Hold on to your butts!”

intro , in Happened to me multiple times

From youtube-dl to yt-dlp

marcos , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

It’s true. The odds increase several times.

jerrythegenius , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus
@jerrythegenius@lemmy.world avatar

He must’ve learnt C. Now if only he’d learnt Rust, he would’ve been safe and had a blazingly fast🚀 escape

const_void , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

Increases your risk of becoming a fat arse too

Steamymoomilk , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

(*geting eaten by dinosaur)*At least i dont half to code javascript anymore!!!

jaybone , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

I just chain smoke on my 286

HotsauceHurricane , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

Linux is a slippery slope to Dilophosaurs consumption. Fun fact: the slippery slope has a cameo in the movie!

Malgas ,

Excuse me, but clearly it’s UNIX that leads to Dilophosaur consumption. We know this.

AVincentInSpace ,

40% of BSD installs lead to shark attacks.

WeirdAlex03 , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus
@WeirdAlex03@lemmy.zip avatar

There’s always a relevant xkcd:
https://xkcd.com/292/

(actually quite a few in this case…)

FunkyMonk , in Fact: becoming a programmer significantly increases your risk of being blinded and eaten by a Dilophosaurus

And being eaten by a motherfucking velociraptor in a mfin electric substation, coders are weak to dino sadly.

AmidFuror ,

Oh, Mr. Arnold.

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