What's the point of pointers?

What's the point of pointers?

so you don't have to copy huge chunks of information and instead just use a pointer

so you can tell where your mouse is on the screen

Reference semantics

Next time please ask

sometimes i pull on it so hard, i rip the skin

So you can reference something and do stuff with it without caring what it is.

For example, in a game where I want to move to the nearest enemy automatically, all I have to do is set a pointer to the nearest enemy, and my auto-move mechanics will deal with the rest

Well, my daddy taught me a few things too, like uhh.. how to not rip the skin by using someone else his mouth : ^ )

The point is to point

Will you show me?

Hey user, where do you live? I want to mail you something.

>Here let me just rebuild an exact replica of my house by yours so you can find it

Uhh, can't I just have the address?

>No. Pointers are useless

To prevent copying data back and forth when you need to change something.

I'd be right happy to!

Yeah, just allocate everything on the stack....

YOU FUCKING FAGGOT

A pointer is an address.
You can use it to point to an arbitrary address in virtual memory.

Imagine if I ordered something from amazon and I built an exact copy of my house next to their warehouse so they could deliver it there.
Then I destroyed the copy after delivery.

Wouldn't it be easier to just give them my address?

Who is this fluid druid?

Dunno what you mean by pointers but sweet mother of ass...

>using the smiley with a carat nose

Why doesn't the compiler take care of this shit? I don't have to worry about pointers/references in Python - I can just use variables Why!

>python compiler
kek

If NULL is the value of a pointless pointer, then dereferencing it is a matter of pointing at non-pointy programmers and laugh at them, at point-blank.

who cares, post more asses

just give >her
your parents address

...

user, do you want Amazon to know your address? No. Obviously, this option is much better.

Question:

do compilers of languages without pointers typically optimize code by assigning pointers to things when it detects it would be an advantage?

*BRAAAAAAAAAAAPFPPPPFfffttt*

Actually, basically most variables in python are pointers since everything is by reference in python. Basically they are just autopointers that do a lot of the memory heavy lifting for you.

...

One really good example of pointers is in the network stack. Basically the ethernet device has access to RAM through the motherboard so it is able to write packets directly from RAM.

After that, the OS can "move" the data by just passing the pointer around the networking stack, and finally to the application. This allows the consuming application to access the data with no copying and very few CPU cycles.

Obviously, this is very a simplified, but you get the idea.

god that's disgusting

>2016
>Not building lists with double pointers

To point.

>What's the point of pointers?

Found the Python "programmer."

Any modern data structure:
Linked lists
Trees
etc

lol

wew... those are very hairy legs

asian spotted

>What's the point of pointers?
This should illustrate the point.

So you don't blow the stack like a cunt

faggot

Rude!

Duck hunting.

it like this:
Imagine you and a friend are standing on the side of the highway.
you want them to see what it says on the billboard across the street, so you point to it
because taking a picture, printing it out, scanning it into you computer, running OCR to crate a PDF, converting the PDF to a DOC, copying the text from the DOC, pasting it into an email and clicking send is TOO MUCH FUCKING WORK!!
THIS IS WHAT HAPPENS WHEN YOU PASS BY VALUE YOU STUPID OOP SCRIPTING PIECE OF SHIT!!!

With pointers:

>have some data
>need to manipulate it with a function
>pass the address of the data (pointer) into function
>function manipulates data directly
>done

Without pointers:

>have some data
>need to manipulate function
>make a copy of all the data
>pass the copy of the data into the function
>manipulate copy of data in function
>data is returned by function
>then copy the manipulated data back into where the data originally was
>finally done

With a pointer, the act of passing the data into a function is O(1). Without pointers, it's O(n). Thus, a function call will have no change in overhead based on the size of the data.

/thread

Many languages which do not possess pointers do these abstractions automatically, and don't have much of an overhead. However if you know what you are doing pointers are sweet.

And that's what makes those "many languages" have more bloat, overhead, and become slower than languages that utilize pointers. Even if most modern hardware can handle the overhead, and the speed-loss is minimal, it's still an inefficiency that can be done without. But I'm not trying to get into a debate between Java and C, just stating that there are benefits to each, and downsides to each from different perspectives.

Get out.

>>>/dpt/

STOP REPLYING, THERE ALREADY IS A GENERAL *DEDICATED* TO THESE QUESTIONS

How mad are you?

fucking with memory desu

>not always using a shared pointer

You use your penis to point at things.

>THIS IS WHAT HAPPENS WHEN YOU PASS BY VALUE YOU STUPID OOP SCRIPTING PIECE OF SHIT!!!
Actually, pointers/references are used extensively in OOP, as otherwise it's difficult to modify objects. For example, if you pass a BankAccount object to a function that's supposed to withdraw money from it, one of the things that function will do is call the SetValue() method. But, if you pass the bank account by value, you won't be modifying the value of the original object.

Where pointers are unnecessary is in unstructured spaghetti code, where everything is out in the open in global scope and you modify things directly rather than by passing values to functions.

>tfw fell for the 64 bit penis meme

>mfw im grading coursework and see a pointer to a struct smaller than 8 bytes

What's wrong with having a pointer to a small struct?

>he doesn't go on Sup Forums

This user just means assign variables locally, ergo in a function. Always.

I'm pretty sure the designers for whatever language you are referring to can manage pointers as well as you. Maybe even better than you.

Pointers create a general case, just like lambda functions create a general case.

Besides allowing data aliasing (pass by reference), which is both powerful and incredibly dangerous, the other point of pointers is dynamic allocation. Generally, there are three kinds of memory allocation: static memory contains program code and global variables, the stack contains functions' local variables, and the heap contains everything else.

Static memory and the stack have fixed allocation; the exact location of everything has to be known at all times. This is why, in C, arrays passed to functions have to either be pointers or they have to have fixed width (so they have known size). The heap allows you to allocate any amount of memory, and you don't have to know ahead of time how much you need. In C, you get heap memory with the malloc function; in object-oriented languages, you get heap memory with the new keyword.

Since the heap is a pretty random mish-mash of one-shot allocations, you need to keep track of what you've allocated, which is (mostly) what pointers are. Likewise, in an object-oriented language, the handle that refers to an object is a pointer, which was clearer in C++ where you actually use pointer syntax. (And also in C++, stack allocation of objects was possible in some circumstances.)

that is a profound pic. somehow in all my time on Sup Forums I have never seen it. It really demonstrates who Hitler was: focused, determined, vigorous, and surely simple minded. but it also displays who he was surrounding himself with: military men; educated men; dull men; men who craved power and men who were sure they knew what was best.

thank for sharing this user, on this moment of viewing I am euphoric.

>somehow in all my time on Sup Forums I have never seen it.

that's just so unbelievable since /pol is so consistently filled with the most brilliant and far-reaching minds civilization will ever know

it's very easy for outsiders to proclaim mental illness upon another when they can't experience the glory and splendor that the greatest and most brilliant minds are capable of achieving.

is a pointer just used like a variable but it could be anything not just a set type?

what's the point of anything?

Ass

Agreed. When do you plan on killing yourself?

when I was about 13 i got in an argument with my childhood friend (who i've long since fallen out of contact with). he told me i've never had a gf and kissed a girl. i lied and said i had. that was 10 years ago and i still haven't. thanks for reminding me.

>Whats the point of indirect addressing modes

To confuse people and make things more efficient.

Sup Forums still can't have audio webms? This will have to do then.

I'd point my dick right to that booty

the pointer ends up being bigger than the data?

>>Whats the point of indexed indirect addressing modes
Fixed.