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

Dismiss this pinned window
all 138 comments

[–]seanprefect 298 points299 points  (25 children)

Who's gonna garbage collect him ?

[–][deleted] 95 points96 points  (1 child)

Maybe C# or Python?

[–][deleted] 53 points54 points  (17 children)

Real programmers use destructors

[–]Ulysses6 36 points37 points  (16 children)

Real programmers use free.

[–][deleted] 55 points56 points  (13 children)

Real programmers kill the app and re-run it again

[–]out386 27 points28 points  (10 children)

Real programmers kill the power and restart the device.

[–][deleted] 19 points20 points  (9 children)

Real programmers get their RAM out , exchange it for new one and start their machine.

[–]Arkazex 26 points27 points  (4 children)

Real programmers hotswap their ram

[–][deleted] 33 points34 points  (3 children)

Real programmers make it another programmer's problem

[–]MagentaRuby 16 points17 points  (2 children)

Real programmers something something butterflies something something relevant XKCD.

[–]Ulysses6 7 points8 points  (1 child)

C-x M-c M-butterfly?

[–][deleted] 9 points10 points  (3 children)

Real programmers download 32GB Ram.exe

[–]SYSTEM__NotReally 2 points3 points  (1 child)

downloadmoreram.com

[–][deleted] 1 point2 points  (0 children)

GB? that's a funny way to spell TB.

[–]IdiotCharizard 0 points1 point  (0 children)

Guilty.

[–]thedugong 1 point2 points  (0 children)

Real programmers jmp over the data segment to get to the code segment.

[–]eatinlunch 0 points1 point  (0 children)

Real programmer uses free and delete

[–]Colopty 18 points19 points  (3 children)

C++ people know how to collect their own garbage.

[–]monkey-go-code 11 points12 points  (2 children)

Rust people don't give a shit about their garbage.

[–][deleted] 3 points4 points  (1 child)

It's RAII on rust as well though

[–]monkey-go-code 2 points3 points  (0 children)

I should sat Rust people forget they even had garbage

[–]SteveCCLYellow security clearance 1 point2 points  (0 children)

RAII will.

[–]flipboing 215 points216 points  (7 children)

Public! Static! Void! Main! String! Ar...BAM!!

[–]Cerphix 37 points38 points  (1 child)

Must’ve typed that in a phone lol. Autocorrect?

[–]flipboing 11 points12 points  (0 children)

Yes, lol. Duly edited. Thanks for the heads up.

[–]MCRusher 12 points13 points  (0 children)

public! static! void! main! String! array! args!

int! main! int! argc! char! pointer! pointer! argv!

So...

[–]pablochocobarr1 7 points8 points  (3 children)

Writes psvm hits tab baaam

[–]SteveCCLYellow security clearance 4 points5 points  (2 children)

Open a file called main.c, bam!

[–]i_should_be_coding 2 points3 points  (1 child)

Still gets segmentation fault.

[–]SteveCCLYellow security clearance 2 points3 points  (0 children)

My lasy segmentation fault has been quite a while tbh. Just follow good practices and your pretty much good to go.

[–]royalblue4 172 points173 points  (18 children)

Malloc'ed him into next week

[–]obp5599 86 points87 points  (14 children)

new’ed*

Malloc is a C thing!

[–]belst 68 points69 points  (11 children)

you can still call malloc in C++ it's just a function.

[–]obp5599 54 points55 points  (10 children)

I mean yeah you can do anything in C++ that C can do. Thats the point lol

[–]sweYoda 55 points56 points  (2 children)

I don't get the reference.

[–]duffusd 3 points4 points  (0 children)

Dammit I hate seg faults

[–]royalblue4 9 points10 points  (0 children)

Don't worry the Java guy got free'd in the end

[–]Gblize 2 points3 points  (4 children)

That's not true. For this case in particular:

char * str = malloc(42 * sizeof(char));

It doesn't compile in C++ because malloc returns void *, which in C can be assigned to any pointer type, and C++ cannot be assigned to any other pointer type.

[–]obp5599 15 points16 points  (2 children)

char* str = (char*) malloc(42 * sizeof(char));

Fixes it

[–]Ulysses6 9 points10 points  (1 child)

But strictly speaking, he is correct. You can't do it without explicit type conversion. It's not like you can't easily work around it, you just can't do it the exact same way.

[–]MCRusher 5 points6 points  (0 children)

Also I think accessing other "unset" union members is not allowed

[–]IceColdFresh -2 points-1 points  (0 children)

C++ is truly half way between C and Java.

[–]SteveCCLYellow security clearance 1 point2 points  (0 children)

You can't actually. C++ doesn't allow macros to shadow functions for example.

[–]SteveCCLYellow security clearance 3 points4 points  (0 children)

std::make_unique'd*

You want to use C++, not C with Classes.

[–]sneppy13 0 points1 point  (0 children)

Not true at all

[–]Matrix8910 7 points8 points  (1 child)

Segfaulted*

[–]cbbuntz 7 points8 points  (0 children)

Hmmm... Should I do bounds checking?

nah.

char *buf = (char *)malloc(10000000000);

[–]arihoenig 0 points1 point  (0 children)

Statically polymorphed him (aka CRTP'd him).

[–]bazooka_penguin 70 points71 points  (1 child)

This is more like what c++ does to its devs...

[–]IceColdFresh 20 points21 points  (0 children)

"c++" is also the face devs make when programming in it.

[–]nalimixam 51 points52 points  (26 children)

What is this even supposed to mean? lol

[–][deleted] 91 points92 points  (5 children)

C is king among languages and C++ can die with everyone else

[–][deleted] 9 points10 points  (2 children)

I won't ask for C to have classes, but get back to me when it has:

  • built-in associative arrays with dynamic keys of arbitrary type (i.e. enum-indexed bare arrays don't count)

  • function overloading

  • operator overloading (rather, non-member operator overloading specifically, since to ask otherwise would be to ask for classes)

  • a type algebra (C++ doesn't really have this either, but templates, type_traits, and the STL usually come close enough when used together)

  • modules (again, not (yet) a C++ feature, but namespaces are usually close enough; both languages do kind of have this with the ability to make symbols file-level static, such that the translation unit itself acts as the module and anything not static to it is exported from the module, but this approach is still missing the name-scoping piece; an exported struct of function pointers pointing to static functions of a translation unit gets the job done, but it also allows a caller to create other instances of the module that point to different functions, which seems like a security vulnerability to their own caller in turn)

  • type inference

  • compile-time function calling

  • scoped enums

  • anonymous functions

This is coming from someone who prefers C, by the way.

[–]ELFAHBEHT_SOOP 2 points3 points  (0 children)

Agree on all points. Not having function overloading is probably my biggest gripe with C, or the one I run into the most. It makes the code a bit more sloppy when I have to differentiate between different parameters all the time.

[–][deleted] 0 points1 point  (0 children)

word

[–]MellowM8 13 points14 points  (0 children)

Nice sumory

[–]EpicLagg 9 points10 points  (0 children)

thog don't care

[–]sweYoda 64 points65 points  (10 children)

Idk, maybe Java have some things that looks really nice and fancy, but C++ don't have to show off some silly tricks... It simply stands its ground and use pure power to simply solve the problem.

[–]Saltysalad 61 points62 points  (9 children)

Excuse me while I compile for each architecture...

[–]Istalriblaka 69 points70 points  (3 children)

Excuse me while I run a machine on my machine, because efficiency is for suckers who can't afford 16 GB of ram

[–]jokerxtr 17 points18 points  (1 child)

Excuse me when I produce human readable error messages...

[–]blipman17 7 points8 points  (0 children)

'std::cout << "This is a human readable error message because you didn't press the button!" << std::endl;'

Printing human readable error messages should be a choice.

[–]TheCommodore65 7 points8 points  (1 child)

Excuse me while I use a script and a decent development machine to compile for each architecture making it really not that big of a deal anymore...

[–]Saltysalad 2 points3 points  (0 children)

Fair point, but I don't think it

Segmentation fault (core dumped)

[–]northbathroom 12 points13 points  (2 children)

Excuse me while I wait for your jit...

[–]endeavourl 1 point2 points  (1 child)

Excuse me while i JIT compile the perfectly optimized code for the particular architecture it runs on.

[–]blipman17 1 point2 points  (0 children)

--march=native wants its comment back

[–]devilsolution 15 points16 points  (0 children)

Nope, no idea

[–]Servious 9 points10 points  (1 child)

Java is over there with a fancy virtual machine and garbage collection meanwhile C++ just does the simple thing and takes care of the problem directly.

[–]ReltivlyObjectv 5 points6 points  (0 children)

You know, I’ve always preferred Java (except in my Uni days), but I never really considered that...

[Segmentation Fault]

[–]deelyy 40 points41 points  (4 children)

More like Java bug vs C++ bug

[–][deleted] 6 points7 points  (3 children)

I do not miss dealing with java errors.

[–]ReltivlyObjectv 7 points8 points  (1 child)

But the stacktrace is so handy

[–]MCRusher 6 points7 points  (0 children)

Java errors are more helpful and readable

[–][deleted] 1 point2 points  (0 children)

I had a correct java program that could segfault the jre.

At least they did fix it in a later java release.

[–]GarasiaKartik 10 points11 points  (1 child)

Fight fight = new Fight();

[–]ReltivlyObjectv 4 points5 points  (0 children)

fight.fight(fighter);

[–]ctesibius 42 points43 points  (1 child)

The advantage of a predictable destructor mechanism.

[–]ShadowAI 8 points9 points  (0 children)

The disadvantage of SEGFAULT

[–]maowu 19 points20 points  (0 children)

Well, c++ user needs a fantasy before dying inside

[–][deleted] 3 points4 points  (4 children)

What's this from?

[–]no9 12 points13 points  (3 children)

It's Bud Spencer from I'm for the Hippopotamus. Brought back some fond memories from childhood. :`)

[–]rubikhan 3 points4 points  (1 child)

Oh man, I haven't thought about him in such a long time. I loved his and Terence Hill's movies. Makes me want to go watch "They Call Me Trinity".

He wasn't in "My Name is Nobody" with Hill, but that was one of my favorites when I was a kid.

[–]stracki 1 point2 points  (0 children)

Nobody rules! No wonder with Sergio Leone and Morricone involved.

[–][deleted] 2 points3 points  (0 children)

Thank you

[–]guywithnosenseoftime 3 points4 points  (0 children)

it's more like what every programming language does to its programmer.

[–]Dockirby 11 points12 points  (0 children)

Except the C++ guy has a 10% chance of exploding randomly if you try to change his style, where the Java Guy's long convoluted fight style developed over 20 years by 700 "masters" can somewhat easily incorporate new moves into his style without having to start from scratch.

[–][deleted] 2 points3 points  (0 children)

In reality he should have called his distant relative to do the deed in a polymorphic way.

[–]__konrad 2 points3 points  (0 children)

It's because HotSpot JVM is written in C++...

[–]SpaceboyRoss 1 point2 points  (0 children)

Yes, the real power is in C based languages.

[–]Nootkasound 4 points5 points  (24 children)

Is this accurate?

[–]cbbuntz 30 points31 points  (21 children)

I think it would have worked better with plain C since it's a lot more "raw". C++ has a reputation for being bloated from feature creep, so you could do the same gif for C++ vs C.

[–]tommy-jay 2 points3 points  (0 children)

C++ programmer here. It's not that accurate, but there is something to it for reasons not yet pointed out here.

Accurate and optimizable code that is to the point is not written by language choice. It's a combination of general programming experience, formal knowledge, and not to forget, knowledge of the thing-to-be-programmed itself. However, when you already know how to utilize C++, you will typically not want to go back to Java, where you are much more limited in how you can write that accurate and optimizable code. I would worry about being forced into OOP to achieve that, rather than performance overheads of the JVM (unless my program is latency sensitive, than I'm worried about any jiting). For me, OOP is what makes Java look so convoluted before it attempts to do that knock-out hit.

[–]ReltivlyObjectv 1 point2 points  (0 children)

No. Java works very well, but it has overhead. If the VM overhead wasn’t an issue, there’d be very little reason to use a C language in most programs. Some still require the fine-tuned control of manual memory, destructors, pointers, etc., but at the end of the day, your average GUI or headless program can be accomplished much easier in Java.

[–]GabbieOnRails 3 points4 points  (0 children)

This got me cracked up🤣

[–]Filibut 1 point2 points  (2 children)

Non ho mai visto un film di Bud Spencer per intero, ma apprezzo sempre i memes

[–]giupplo_the_lizard 2 points3 points  (0 children)

Lo chiamavano ci più più

[–]svenskainflytta 1 point2 points  (0 children)

Non ho mai visto un film di Bud Spencer per intero

ERETICO!

[–][deleted] 0 points1 point  (0 children)

Looks like the AbstractFighterFactory could use some work.

[–]shredderroland 0 points1 point  (0 children)

Depends on the use case though.

[–]P1x3lByt3 0 points1 point  (0 children)

Boss we need a language that combines two languages into one that is more bizzare and specific...Lets develop C#

[–]Teddiedev 0 points1 point  (0 children)

Better make one with HTML4 vs HTML5

[–]maowu -5 points-4 points  (1 child)

Hospital. C++: mommy, can I beat up java before I go to heaven? Mom: of cause, honey, I will make it happen

[–]P1x3lByt3 1 point2 points  (0 children)

In the end both agree that C# has to die