Click here to Skip to main content
15,393,050 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
dandy7217-Dec-20 3:11
Memberdandy7217-Dec-20 3:11 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
honey the codewitch17-Dec-20 3:15
mvahoney the codewitch17-Dec-20 3:15 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Martin ISDN18-Dec-20 5:56
MemberMartin ISDN18-Dec-20 5:56 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Mike Hankey17-Dec-20 3:36
professionalMike Hankey17-Dec-20 3:36 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
honey the codewitch17-Dec-20 3:39
mvahoney the codewitch17-Dec-20 3:39 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Member 1330167917-Dec-20 20:17
MemberMember 1330167917-Dec-20 20:17 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Mike Hankey18-Dec-20 1:16
professionalMike Hankey18-Dec-20 1:16 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Member 1064287218-Dec-20 13:32
MemberMember 1064287218-Dec-20 13:32 
Honey, that is exactly why they are confusing! The problem is English and the really sloppy way programmers use English!

Pointers do not actually "point" to a memory location. The fact that you can get to a data element in memory and that method that can be manipulated as if it were a number is a *compiler specific concept* in the C family of languages. And an incredibly stupid idea that creates tons of security vulnerabilities. NEVER, EVER use a pointer as if it were a number. ALWAYS use it as an abstract data type and you will avoid 99.9% of pointer type defects in your code.

I am mentoring a young woman who is taking her first real programming class (Python *DOES NOT* count).

---------------
Here is what I told her:

Anyone who has ever written in a "proper" language like Pascal, Modula, PLM-86, or Ada or who studied actual Computer Science will tell you that a "pointer" is an abstract data type that is nothing more than a handle to some object in your program. There are *NO* operations defined for a pointer other than connection to some object, referencing an object (either an actual object in C++, C#, Ada, etc. or a struct or intrinsic in C) or copying a pointer to another pointer of the same type. You can literally use a "pointer" as a handle to carry data around in your program from one place to another. In some languages we use the word "reference" as a synonym for a pointer.

I also gave her a physical example of how pointers can be used in linked lists.

----------------
Kernighan and Ritchie (bless their hearts) improperly called a data type by the CS name "pointer" when they should have named it an "address". They ARE NOT the same thing. In modern computers, that is absolutely the case because the "address" you get is just a virtual mapping of an actual address to some other thing that just happens to be a number (but you have to understand hardware to understand why that is). K&R (or some folks after them) also screwed up the keyword "static" which has two *completely different* meanings depending on context. The list of things screwed up in C is a long one! It is why the MISRA standard is necessary.

C was just readable assembly language for the PDP-11 computer which got moved over time to other computers. Because you are forced on very small computers to play tricks in C/assembler in order to save data and code space, C has some really egregious history of confusing pointers with addresses and the fact that you can actually see a *real* computer underneath the virtual computer. The way to solve that problem: NEVER, EVER use a pointer as if it is an address or a number even if the language allows you to do it.

Just because you *can* do a thing does not mean you *should* do that thing. (Someone on this board has that thought from Jurrasic Park as his signature)
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Maximilien17-Dec-20 2:36
MemberMaximilien17-Dec-20 2:36 
GeneralCAREFUL WITH THAT LINK Pin
Nelek17-Dec-20 5:19
protectorNelek17-Dec-20 5:19 
GeneralRe: CAREFUL WITH THAT LINK Pin
Maximilien17-Dec-20 11:07
MemberMaximilien17-Dec-20 11:07 
GeneralRe: CAREFUL WITH THAT LINK Pin
Nelek18-Dec-20 3:34
protectorNelek18-Dec-20 3:34 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
W Balboos, GHB18-Dec-20 2:22
mveW Balboos, GHB18-Dec-20 2:22 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
User 1106097917-Dec-20 3:12
MemberUser 1106097917-Dec-20 3:12 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Amarnath S17-Dec-20 3:31
professionalAmarnath S17-Dec-20 3:31 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Johnny J.17-Dec-20 3:33
professionalJohnny J.17-Dec-20 3:33 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
honey the codewitch17-Dec-20 3:34
mvahoney the codewitch17-Dec-20 3:34 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Daniel Pfeffer17-Dec-20 3:59
professionalDaniel Pfeffer17-Dec-20 3:59 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
honey the codewitch17-Dec-20 4:01
mvahoney the codewitch17-Dec-20 4:01 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
  Forogar  17-Dec-20 4:22
professional  Forogar  17-Dec-20 4:22 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Marc Clifton17-Dec-20 5:11
mvaMarc Clifton17-Dec-20 5:11 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
Southmountain17-Dec-20 6:52
MemberSouthmountain17-Dec-20 6:52 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
CPallini17-Dec-20 7:37
mveCPallini17-Dec-20 7:37 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
honey the codewitch17-Dec-20 7:42
mvahoney the codewitch17-Dec-20 7:42 
GeneralRe: I was going to write an article about how pointers aren't confusing Pin
CPallini17-Dec-20 20:07
mveCPallini17-Dec-20 20:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Do you feel you fully understand the vision and purpose of the software project you're working on?
Sure you can be told the "what", but do you have the "why"?
  Results   253 votes