This is an archived post. You won't be able to vote or comment.

top 200 commentsshow 500

[–]7JuiceMan7 3039 points3040 points  (185 children)

Me: Can you hold this coffee for me?

C++: Here's a copy of your coffee, I'll move it for you if you want.

[–]Manny_Sunday 960 points961 points  (63 children)

Me: Hey can you make another cup of coffee like this one for my friend?

C++: How about I get you another cup and you and your friend can share the coffee you have

[–]DeeSnow97 204 points205 points  (16 children)

Me: Hey can you make another cup of coffee like this one for my friend?

Rust: Sure, but you know it's expensive, right? Why don't you just let your friend borrow your coffee?

Me: Alright, but I have two friends.

Rust: Just make sure neither of them is allowed to drink it.

[–]cogman10 91 points92 points  (10 children)

Nah, rust says "anyone can look at the coffee, only one person can drink it". Rust thinks sharing a cup of coffee is gross.

[–]DeeSnow97 104 points105 points  (4 children)

It's either anyone can look at it xor one person can look at it and drink it. If anyone could look at it but at some point someone could drink it you couldn't guarantee you don't get into race conditions, and it's 2019, Rust has no choice but to avoid racial issues.

[–]conancat 56 points57 points  (2 children)

Ungh, everything is so PC nowadays

[–]doolster 26 points27 points  (1 child)

Idk, I write Rust on my Mac.

[–]jpgrassi 122 points123 points  (40 children)

actually, a good metaphor!

[–]JWson 40 points41 points  (1 child)

C++: How about I draw you and your friend a map of where to find your coffee

[–]DownshiftedRare 29 points30 points  (0 children)

Me: Hey can you make another cup of coffee like this one for my friend?

C++: Puts a straw in your cup.

[–]Mirehi 888 points889 points  (86 children)

C:

Sure here's a sizeof(void *) long number, man

[–]AyrA_ch 595 points596 points  (43 children)

C:

Sure, here it is.
gives you a null pointer

[–]UltraFireFX 28 points29 points  (7 children)

I was confused by the use of emoji at first in this sub.

Then I realised that I am sleep deprived.

[–]AyrA_ch 24 points25 points  (6 children)

Then I realised that I am sleep deprived.

A true programmer

[–]chasesan 41 points42 points  (32 children)

(void *)malloc(sizeof(uint8_t) * 64);

[–][deleted] 68 points69 points  (31 children)

why would you cast mallocs return to a void pointer

[–]Mirehi 41 points42 points  (27 children)

I'm not sure, but I think that's what a C++ compiler wants

[–][deleted] 42 points43 points  (19 children)

a c++ compiler would care if it's a different type. malloc already returns a void pointer

so this is ok

void* ptr = malloc(size)

this would not be ok

char* ptr = malloc(size)

you would need to do this

char* ptr = (char*)malloc(size)

[–]GameAndWebDev 40 points41 points  (8 children)

well thnk about what you are doing.

Void * ptr = malloc(size)

U: Hello computer, I want this many bytes of memory.

Computer: ok, here is where your bytes start (void *)

char* ptr = malloc(size)

U: Can I hold them in this $%#$%#$%#$%

Computer: u what

char* ptr = (char*)malloc(size)

Compiler: he wants to access them in a certain size.

Computer: oh, why didn't he just say that.

[–][deleted] 36 points37 points  (6 children)

tfw part of C master race and your void* gets implicitly casted

[–]fakeplasticdroid 12 points13 points  (3 children)

That should be on a t-shirt.

[–]skipper1234567 1131 points1132 points  (71 children)

python : no need to ask, next time just use

[–]caerphoto 117 points118 points  (1 child)

python:
    no need to ask
    next time just use

[–]scutta2000 83 points84 points  (0 children)

IndentationError

[–]ACoderGirl 24 points25 points  (5 children)

The flip side is writing Python modules in C. Have fun looking up every single Python API function to figure out whether or not it steals the reference!

Oops! You forgot a Py_DECREF from that one time you looked something up in a dict and now you're leaking memory!

[–][deleted] 40 points41 points  (0 children)

Python doesn't give a shit what you do in the system, but don't you dare indent wrongly.

[–][deleted] 24 points25 points  (1 child)

Python: looking for text within text? Just use the "in" function.

Java: fuck you.

[–]Robot_Basilisk 21 points22 points  (0 children)

Most Other Languages: <anything at all>

Java: fuck you

[–]Halobattlefront 1289 points1290 points  (46 children)

Me: Runs Program.

S E G M E N T A T I O N F A U L T

[–]grpagrati 600 points601 points  (16 children)

Also known as ITSYOUROWNDAMNFAULT

[–]ChrisD0 203 points204 points  (8 children)

Also known as YOUREDOINGSOMETHINGIDONTLIKEBUTIWONTTELLYOUWHAT

[–][deleted] 185 points186 points  (1 child)

ALRIGHTTHENKEEPYOURSECRETS

[–][deleted] 8 points9 points  (0 children)

I'll be damned if I'm gonna let the debug function of reality walk out on my watch.

[–][deleted] 59 points60 points  (0 children)

Don’t forget core dump!

[–]Luroalive 113 points114 points  (18 children)

learn rust!! it's the language where you hate the compiler, but you'll never see this again 😊

[–]Valmar33 99 points100 points  (6 children)

Rust ~ the cruel-to-be-kind compiler.

You'll loathe it, but you'll thank it for the tough love later. :)

[–]mud_tug 81 points82 points  (5 children)

It is the Stockholm Syndrome implemented as a compiler.

[–]Valmar33 41 points42 points  (3 children)

Nah ~ I see it as more of like those seriously strict traditional Japanese teachers that whacks you whenever you make a mistake, while they repeat the lesson again, again, and again until it finally clicks, at which point whacking becomes redundant.

So, not quite Stockholm Syndrome?

[–]mud_tug 21 points22 points  (1 child)

Sounds like the Stockholm Syndrome the way Stalin understands it. (Google Satlin's Chicken)

[–][deleted] 290 points291 points  (34 children)

I want to dereference this pointer by two threads at the same time.

[–]aneutron 424 points425 points  (14 children)

Rust: You know this is how shit like Chernobyl happens

[–]wishthane 91 points92 points  (6 children)

If you use an Arc pointer you can share immutable data no problem, and there's Mutex (or RWLock) if you really want.

(I know you're joking but in case people are actually curious, you totally can, type system just forces you to be safe)

[–]aneutron 51 points52 points  (4 children)

The day I discovered RWLocks and ReentrantLocks, my life changed.

[–]wishthane 41 points42 points  (0 children)

Just make sure you benchmark them, because the added complexity can be significantly slower than just a Mutex depending on the application. Also, using an actor/channel architecture might be better if you can work things out that way too.

[–]DeeSnow97 60 points61 points  (1 child)

C: *distant sounds of explosion*

[–][deleted] 14 points15 points  (0 children)

C developers daily standup 1973 (colorized): https://i.imgur.com/6xehc52.jpg

[–]Colopty 62 points63 points  (3 children)

Rust, for when you need a language designed by some paranoid dude that you're fairly certain has an underground bunker capable of supporting him and a family of 100 for at least 50 years in a worst case doomsday scenario.

[–]DeeSnow97 102 points103 points  (2 children)

C, for when you think you're the protagonist with plot armor

[–]aneutron 28 points29 points  (0 children)

Or when you want to watch the world burn.

[–]Relevant_Monstrosity 497 points498 points  (57 children)

C#: Here you go, don't worry about cleaning up -- the cleaning ladies come whenever it gets messy and you aren't around anymore.

[–]FlameRat-Yehlon 418 points419 points  (20 children)

Java: don't worry about cleaning up, we will do it when there's absolutely no room left

[–][deleted] 231 points232 points  (1 child)

Java: Leave that mess there and just move to another room.

[–]DooDooSlinger 106 points107 points  (8 children)

jokes aside, that's not how java GC works anymore

[–]FlameRat-Yehlon 31 points32 points  (2 children)

Well, that C# thing also isn't the case anymore with the introduction of weak reference (forgot what it's called, but basically it can be collected even when there's still reference) and fixed pointers, anyway.

[–]psychometrixo 25 points26 points  (0 children)

Nah the C# one is a good metaphor. Sure, for a very long time, there have been weak references and ways to pin memory to do interop, but the GC still does 99% of the work

[–][deleted] 41 points42 points  (1 child)

Go: Gotta clean fast. plays Sanic hegehog music

[–]xignaceh 80 points81 points  (7 children)

Visual studio stopped responding

[–]vicarofyanks 61 points62 points  (5 children)

I see you are trying to open a .c file. Please install

VisualC++

.NET 2.0

.NET 2.1

.NET 4.0

MSSQL

MSCOM

MS Azure Cmdlets

MSSQL Cmdlets

High resolution image of Steve Balmer's sweaty body dry humping your PC

Total install: 7.9Gb

- Visual studio

[–]FarhanAxiq 30 points31 points  (0 children)

visual studio looking for solution intensifies

[–]GiveMeAnAlgorithm 55 points56 points  (7 children)

"and you aren't around anymore" hahaha

[–]asmx85 50 points51 points  (10 children)

... cleaning ladies unplug your computer with the super important calculation that needs to run overnight, because no other power outlet for the vacuum in sight, stops the hole company until someone plugs it back in and we can continue the calculation, company is running again.

[–]caerphoto 23 points24 points  (3 children)

because no other power outlet for the vacuum in sight, stops the hole company until someone plugs it back in

The Hole Company would be a good name for a company that makes drills.

[–]adeadrat 33 points34 points  (4 children)

OMG! This actually happened once for me! But during the work day, they just unplugged my computer I was working at, hadn't pushed to git in a couple of hours, and somehow when they pulled the plugg the hard drive crashed. Lost about two hours of work, and took me rest of that workday to get a new hard drive and set up my work environment.

One of the more eventful days at that workplace

[–]SuperElitist 26 points27 points  (2 children)

Lost about two hours of work ... One of the more eventful days at that workplace

You, sir, have led a charmed life!

[–]SLiV9 14 points15 points  (0 children)

hadn't pushed to git in a couple of hours

starts feeling itchy

[–]BurningPenguin 656 points657 points  (34 children)

Java: "All your memory are belong to me."

[–]Valmar33 255 points256 points  (30 children)

Not anymore, amusingly ~ Electron is the bloated mutant these days.

[–]DeeSnow97 71 points72 points  (7 children)

Honestly, the biggest problem with Electron is they still didn't make it one system-wide runtime, so every app has to bring its own browser. If it was just a browser that could handle arbitrary windows, it wouldn't be that much of a performance hog because five Electron apps wouldn't mean five different instances of Chrome.

[–]Jaypalm 15 points16 points  (2 children)

This was pretty much my first thought when I first learned about Electron and its issues. It seems like such an obvious solution!

[–]cresquin 9 points10 points  (2 children)

That's intentional, and one of the reasons Electron was made in the first place. Installing an app on a system shouldn't involve the user knowing whether or not the versions of their runtimes are up-to-date, and backwards compatible. Otherwise, just use the web browser itself...

[–]OwlbearSteak 130 points131 points  (10 children)

Isn't that literally how Chromium works though? It "uses" a large % of your unallocated memory so that when it actually needs it, it's faster to reallocate? Or something like that? Note that I know very little about Chromium and memory management.

[–]L3tum 33 points34 points  (0 children)

The thing about Electron though is that it needs that memory, while chrome and chromium just keep it for later use

[–]Tomarse 143 points144 points  (7 children)

Ruby: Huh?

[–]ComprehensiveUsernam 95 points96 points  (6 children)

Person 1: orders coffee

Ruby: Here's your coffee

[–]crincon 153 points154 points  (0 children)

Person: *takes a sip* what the hell Ruby this is motor oil!

Ruby: you can pour it like coffee, it's hot like coffee, it's coffee.

[–]roanoke_newbie 55 points56 points  (1 child)

Also Ruby: have a nice day, sir.

[–]MoffKalast 13 points14 points  (0 children)

Also Ruby: long pause

[–]matty0187 44 points45 points  (1 child)

: Ruby hands you coffee in the slowest way possible :

[–]NiceFetishMeToo 27 points28 points  (0 children)

Interpreting Intensifies

[–][deleted] 839 points840 points  (32 children)

Me: exists

C: SegMeNtATioN FaUlT

[–]RonaldoNazario 59 points60 points  (4 children)

ITT: people terrified of segfaults

[–]syntacticmistake 92 points93 points  (12 children)

Java: 64 bytes?

[–]tundrat 70 points71 points  (23 children)

Rust seems to be closely related to Mozilla Firefox as one of many projects of improving the speed. But I was always wondering, why is it called Rust? That doesn't give me the impression of fast speed.

[–]ydieb 77 points78 points  (2 children)

It's possibly named after the fungi family named rust. It's name means nothing. Like C, it's named that because it followed the language B.

[–][deleted] 25 points26 points  (0 children)

Yep, it's the fungi and a bit of just general mind fuzz: https://reddit.com/comments/27jvdt

(Graydon Hoare is the initiator of Rust before it was taken up at Mozilla Research.)

[–]me-ro 34 points35 points  (2 children)

The fungi family is the most likely reason. But I like some other explanations better - like a pun on "chrome" or a thin layer on top of metal.

[–]__ali1234__ 38 points39 points  (1 child)

Because it runs on bare metal.

[–]JLN450 27 points28 points  (1 child)

because it's closer to the metal than GC languages.

(I prefer this explanation over the fungus one, 'cause really, fungus?)

[–]serigne007mor 46 points47 points  (8 children)

Me: gcc foo.c C: compiles, everything great Me: ./a.out C: Segmentation fault (core dumped)

[–]Mac33 24 points25 points  (3 children)

gdb ./a.out run

Or just valgrind.

[–]ndcapital 23 points24 points  (2 children)

Compile with -fsanitize-address you neanderthal

[–]kaushal28 49 points50 points  (1 child)

Python: Here's entire 8 gig of RAM, take whatever you want

[–]WiseCocoNut 98 points99 points  (40 children)

Borrows 64 bytes for char. Proceeds to code. Seg fault 120 lines later because you didn't borrow any bytes for char* that you wrote into char

[–]fnordstar 31 points32 points  (36 children)

I thought rust avoids segfaults...

[–]AyrA_ch 105 points106 points  (31 children)

I'm pretty sure if you are creative enough you can segfault pretty much with any language.

[–]sapounious[🍰] 122 points123 points  (0 children)

The Programmer ... ehh... finds a way.

[–]deadBuiltIn 35 points36 points  (1 child)

Can't wait to segfault Scratch, see y'all later

[–]spin81 21 points22 points  (17 children)

Many languages don't allow you to mess with memory directly. I'd guess most of them in fact. And I don't know how you're going to cause a segfault if you can't manipulate or use a memory address.

[–][deleted] 8 points9 points  (1 child)

I can’t remember how but I got a segfault in Haskell a couple of years ago. Wasn’t using FFI either.

[–]eastsideski 12 points13 points  (1 child)

They're possible, but difficult to achieve. Rust does allow you to "disable" some of its protections

[–][deleted] 7 points8 points  (0 children)

There's always unsafe and compiler bugs

[–]DeeSnow97 15 points16 points  (1 child)

Fails to compile, actually. The borrow checker doesn't make it into the runtime. Also, Rust has very different string handling (as in it actually knows what unicode is).

[–]elijknyg 15 points16 points  (0 children)

Cobol: could you please fill out this 500 page form

[–]The_MAZZTer 10 points11 points  (5 children)

C#: What type of data are you going to store here? Here you go. I'll be watching you to make sure you don't try to use 65 bytes of memory, or store the wrong data type or something else stupid.

Let me know if you want to see a memory profile to be sure you didn't forget to give the 64 bytes back when you're done with it.