r/ProgrammerHumor • • 17h ago

Meme iThoughtIGotRidOfYou

Post image
589 Upvotes

42 comments sorted by

126

u/FurieMan 16h ago

"We have no pointers!"

Looks inside: Only pointers.

15

u/HumunculiTzu 13h ago

I've had bugs because the original developer who wrote the code didn't understand that and it was causing duplicates in the 1 path where it was passing by reference

4

u/BusEquivalent9605 7h ago

When everyone’s a pointer, no one is.

Except primitive types of course - `int, double, boolean, char,…` which are stored on the stack

59

u/IamSunka 17h ago

We can give you references, though. 

13

u/Cesalv 16h ago

with or without value?

1

u/Ok-Scheme-913 1h ago

Well, java actually only has primitive "value" types and pointers.

C++ has both pointers and references.

It's very mindfuck, but they are not the same thing, java just renamed them because people were afraid of pointers, but it lives on under the hood (NullPointerException)

25

u/Makonede 14h ago

10

u/Jbolt3737 9h ago

Literally an XKCD for everything

15

u/stupled 14h ago

I was expecting Rust

8

u/aeropl3b 13h ago

They were trying to think outside the Box

15

u/bwmat 15h ago

NullPointerException

2

u/AsaKeyholderUK 16h ago

CAmelCase variable names do not hide in key dreams. Mine is still isLoadingUserProfile from a project I finished in 2023.

1

u/Personal-Code-2496 4h ago

unsafe doesn't mean that it isn't safe. Just means that you have full control over the memory and as such need to think about how the memory you allocated gets freed later. You can do retarded memory shit in every language.

1

u/SoggyCaterpillar5773 2h ago

You should try Golang.

2

u/Ok-Scheme-913 1h ago

"fun" fact: golang is not memory safe.

You can cause memory corruption by data races. Slices are fat pointers but are not written atomically. So if you change a slice from two different threads, you can observe false states like a pointer to the first slice's data but the length of a second. After which your code can read past the memory slice, a la c/c++

0

u/Puzzleheaded-Weird66 16h ago

why no references? also why does C# have the ref keyword but requires the variable to pass be also ref (introduces some annoying syntax errors), its quite annoying since in my head I thought it was like rust's &mut

5

u/AcornAnomaly 14h ago

I see it as a behavior warning/guard.

A variable passed using ref can be changed in ways that might not be expected if the person is expecting a normal function call, including having the underlying reference replaced entirely out from under them.

1

u/Puzzleheaded-Weird66 13h ago

my main issue is now everything has to be ref

3

u/Xialian 13h ago edited 13h ago

Reference types are always passed by reference by default - passing them with the ref keyword is 99% of the time unnecessary (and likely doesn't do what you want).

Passing a value type (aka, primitives/non-"classes") with ref is basically like passing T& instead of T, so it can be useful there, but generally you don't really need that keyword much

0

u/drawkbox 4h ago

Everything worked out and was "safer" until Log4Shell and Java4Shell where Java was wide open for a decade.

1

u/Ok-Scheme-913 1h ago

That's like nothing compared to the number of C vulnerabilities.

-9

u/El_RoviSoft 16h ago

Imho, languages with references tends to be even more unintuitive than C++ as a first language. So I highly recommend to pick C++/Rust/Zig as a first language (and pls not C, it won’t teach you anything good for projects development).

5

u/Scolmann 16h ago

Mutability may be unintuitive but there's much more unintuitive things about system languages in general that I think languages like Python, Java, or JavaScript end up being much better for beginners

C++ in particular I would never recommend to a beginner

2

u/El_RoviSoft 16h ago

At the time I found good teacher in IT school who taught C++ in a very good way. But it was 10 years ago or so.

So Ig Zig is the most right choice rn because Rust in particular teaches a lot of unusable-in-other-languages practices and architectural designs so I don’t really know which language is the beat for start now…

1

u/Ok-Scheme-913 1h ago

But like.. not even Stroustrup knows the whole c++ language, it's just so goddamn complex. Like tell me how coroutines actually work.

1

u/El_RoviSoft 1h ago

Yeah, coroutines is just a mess, recently tried to use them and it was horrible experience and several hours of reading AI explanations…

3

u/Dragaliona 10h ago

Honestly, after trying Python and C, Java is the one that sparked the flame of programming passion on me, so I’m really fond of it. I really like it and it’s the one I chose whenever I want to program something. though I guess the teacher also does a lot for the enjoyment ([at]BroCodez on YouTube).

Imho, Java is one of the best to start mainly because of its verbosity. I think it helps the programmer keep a better understanding of the program and it makes programs easier to read and decipher without needing a bajillion comments.

On the other hand, even the course I followed wasn’t that good and it bored me to death, I think C is also an excellent choice to start, because it forces the programmer to stay closer to the machine and that experience with lower level programming makes programming in higher level languages easier and more efficient, since the programmer learns stuff it would have otherwise been abstracted away with higher level languages. Also going from Python or C++ or Java to C is much harder than the opposite, precisely because one loses the libraries/abstractions of those higher languages that one has learnt to rely on.

PS: Sorry for the rambling. It’s 4:50 for me right now and my brain ain’t braining well no more :/

1

u/El_RoviSoft 8h ago

Kinda agree with Java but references are still kinda unexplained, if you are not familiar with memory models as a concept, it can potentially blow up your legs in the future. People need at least know how shared_ptrs work (or its alternatives).

1

u/realrealvantheman 15h ago edited 15h ago

How dare you disrespect the best language ever!! Edit: /s

2

u/GreatScottGatsby 15h ago

Without the sarcasm, C is pretty great.

1

u/El_RoviSoft 15h ago

I don’t think it’s a good first language, that’s it. As a C++ dev I regularly interact with it and wrote some programs, the main issue with C that it is quite struggling and unrewarding language in some way, especially when you wanna build some big projects. There is a reason why some projects are written in C++ initially and then C interop is added.

1

u/realrealvantheman 15h ago

I mean it really depends on what your making. C is just so incredibly flexible while being one of the single most portable languages ever made and usually being pretty fast. I can see how something like c++ can be easier for larger projects tho. I do think c++ is a bit overcomplex for what it is and it isnt a first good lang due to that.

1

u/El_RoviSoft 15h ago

it’s just not as rewarding for learning, that’s my only issue in current context

I personally didn’t have feel of power and variety when I used it and this is main aspect of learning new things

sadly we don’t have middle ground nowadays which will teach something complicated with just enough power (In my school days it was Pascal + Delphi)

1

u/realrealvantheman 15h ago

Lol i cant say anything on that i dont know much c++. my first bit in programming was an lsi11/03 processor manual. i only learned c like 2 years later and have used that almost only since

1

u/someNameThisIs 15h ago

I don't see what's wrong with not teaching C as a first language, though C++ and Rust would also be good.

Zig wouldn't be, it's too immature and not enough resources for people coming in with no preexisting knowledge.

1

u/El_RoviSoft 15h ago

Imho, the inly purpose of the first language is to teach you pointers and memory model as well as build small application. If you have a good friend who knows programming/informatics well, Zig is way better choice than C or C++ but not sure about Rust tho except it’s language specific practices.

1

u/someNameThisIs 15h ago

C would be fine teaching pointers and memory models. It's how I first learnt them being self taught, as my first language was Python.

1

u/El_RoviSoft 15h ago

I just tried to find middle ground between C and some high level languages, so that’s why I told C++/Rust/Zig

1

u/Bomaruto 15h ago

Mutability where it doesn't belong is the issue, not languages with references in itself and C++ doesn't solve this.

1

u/El_RoviSoft 8h ago

Mutability by default is good but C++ has a solution at least (with const function/arg/ref specifier).

1

u/rosuav 7h ago

C++ has a solution for everything except complexity. Sometimes I have no clue what problem is being solved, but hey, there's more layers of complexity there!