Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is pointer programming even necessary?

Reply
Thread Tools

Is pointer programming even necessary?

 
 
Danno
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 10:15 am, Danno <(E-Mail Removed)> wrote:
> On Mar 31, 1:07 am, Kai-Uwe Bux <(E-Mail Removed)> wrote:
>
>
>
> > Danno wrote:
> > > I have decided that this year, I will refresh my C++ skills since they
> > > are old and brittle. I have moved onto other languages over the past
> > > 10-15 years or so, and all the languages I have taken to don't have
> > > the pointer logic associated with it (Java, Ruby, etc). I can't say
> > > that I missed it. So my question is simple, is pointer programming
> > > still viable or even necessary?

>
> > If you are asking about C++ (which can be inferred since you are posting
> > here), then the answer is: Yes.

>
> > The standard library offers a nice collection of useful data structures. So,
> > you don't need explicit dynamic memory management anymore to use a doubly
> > linked list.

>
> > However, run-time polymorphism in C++ heavily relies on pointers. It is
> > really on the level of pointer and reference types where the "is-a"
> > relationship holds: if D derives from B, then the set of values for D* is a
> > subset of the set of values for B*. (The canonical map from the set of
> > values of type D to the set of values of type B is a projection not an
> > inclusion, and it goes by the name of slicing.) Since references cannot be
> > reseated, pointer still prove necessary at the very least in this context.

>
> > Of course, there are other reasons to use pointers: e.g., T* can be used
> > even for incomplete types, which sometimes makes it necessary to use T*
> > instead of T in the context of template programming.

>
> > Best

>
> > Kai-Uwe Bux

>
> Thanks for your help Kai.


Kai, I know where my problem came from.

In java and ruby, object variables hold object references. I forgot
in C++ that object variables hold object values. That means that
pointers are absolutely necessary.

Thanks again. That was the source of my confusion.

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-31-2008
* Danno:
> On Mar 31, 2:01 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
>> * Danno:
>>
>>> I have decided that this year, I will refresh my C++ skills since they
>>> are old and brittle. I have moved onto other languages over the past
>>> 10-15 years or so, and all the languages I have taken to don't have
>>> the pointer logic associated with it (Java, Ruby, etc).

>> I think you mean "pointer arithmetic", because Java certainly have pointers.
>> Java reference values are pointers. They're called pointers by the Java
>> language definition (just consider what the heck you think a Java
>> NullPointerException is all about), and they act like pointers.

>
> I was trying to be careful with the term, I did't think pointer
> arithmetic was the best term.


It was, if that was what you were referring to.

You ended up being the opposite of careful.


> Pointer arithmetic is when you use
> mathematical terms to manipulate the pointer (increment, decrement,
> comparison). In C++ you can do that, but I used the general term
> 'pointer programming' so it can include pointer arithmetic as well as
> merely setting the reference.


Java does have pointers. What it lacks is pointer arithmetic, and the ability
to form pointers in other ways than via new.


> But this exercise in semantics isn't
> really my cause here.


It should be.

It would be a good idea to understand, at least to some rough approximation,
what you're attempting to ask about.


Cheers, & hth.,

- Alf
 
Reply With Quote
 
 
 
 
Erik Wikström
Guest
Posts: n/a
 
      03-31-2008
On 2008-03-31 08:38, Danno wrote:
> I have decided that this year, I will refresh my C++ skills since they
> are old and brittle. I have moved onto other languages over the past
> 10-15 years or so, and all the languages I have taken to don't have
> the pointer logic associated with it (Java, Ruby, etc). I can't say
> that I missed it. So my question is simple, is pointer programming
> still viable or even necessary?


Viable, most certainly!

Necessary? Not always, you can write quite a lot of programs these days
without having to play with pointers. On the other hand, if you do use
pointers you can much more with a lot less effort.

--
Erik Wikström
 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 10:45 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
> * Danno:
>
> > On Mar 31, 2:01 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
> >> * Danno:

>
> >>> I have decided that this year, I will refresh my C++ skills since they
> >>> are old and brittle. I have moved onto other languages over the past
> >>> 10-15 years or so, and all the languages I have taken to don't have
> >>> the pointer logic associated with it (Java, Ruby, etc).
> >> I think you mean "pointer arithmetic", because Java certainly have pointers.
> >> Java reference values are pointers. They're called pointers by the Java
> >> language definition (just consider what the heck you think a Java
> >> NullPointerException is all about), and they act like pointers.

>
> > I was trying to be careful with the term, I did't think pointer
> > arithmetic was the best term.

>
> It was, if that was what you were referring to.
>
> You ended up being the opposite of careful.
>
> > Pointer arithmetic is when you use
> > mathematical terms to manipulate the pointer (increment, decrement,
> > comparison). In C++ you can do that, but I used the general term
> > 'pointer programming' so it can include pointer arithmetic as well as
> > merely setting the reference.

>
> Java does have pointers. What it lacks is pointer arithmetic, and the ability
> to form pointers in other ways than via new.



What???? You just implied that java has pointer arithmetic. haha

"I think you mean "pointer arithmetic", because Java certainly have
pointers.
Java reference values are pointers. They're called pointers by the
Java
language definition (just consider what the heck you think a Java
NullPointerException is all about), and they act like pointers."




>
> > But this exercise in semantics isn't
> > really my cause here.

>
> It should be.
>
> It would be a good idea to understand, at least to some rough approximation,
> what you're attempting to ask about.
>



So I dusted off my Bjarne's C++ book and also referenced a few sites.
Found out, you have no idea what you are talking about.
I will just rely on the knowledgeable posters in this group.

Thanks
 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 11:26 am, Erik Wikstrm <(E-Mail Removed)> wrote:
> On 2008-03-31 08:38, Danno wrote:
>
> > I have decided that this year, I will refresh my C++ skills since they
> > are old and brittle. I have moved onto other languages over the past
> > 10-15 years or so, and all the languages I have taken to don't have
> > the pointer logic associated with it (Java, Ruby, etc). I can't say
> > that I missed it. So my question is simple, is pointer programming
> > still viable or even necessary?

>
> Viable, most certainly!
>
> Necessary? Not always, you can write quite a lot of programs these days
> without having to play with pointers. On the other hand, if you do use
> pointers you can much more with a lot less effort.


Thanks Erik.
>
> --
> Erik Wikstrm


 
Reply With Quote
 
lbonafide@yahoo.com
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 12:56 pm, Danno <(E-Mail Removed)> wrote:
> On Mar 31, 10:45 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:


> > It would be a good idea to understand, at least to some rough approximation,
> > what you're attempting to ask about.

>
> So I dusted off my Bjarne's C++ book and also referenced a few sites.
> Found out, you have no idea what you are talking about.
> I will just rely on the knowledgeable posters in this group.


Exactly what was it that Alf (who is indeed one of them most
knowledgeable and courteous posters on c.l.c++) wrote was disproved by
your few minutes of web surfing?

Where are all of these brash newbies coming from lately?

 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 12:06 pm, (E-Mail Removed) wrote:
> On Mar 31, 12:56 pm, Danno <(E-Mail Removed)> wrote:
>
> > On Mar 31, 10:45 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
> > > It would be a good idea to understand, at least to some rough approximation,
> > > what you're attempting to ask about.

>
> > So I dusted off my Bjarne's C++ book and also referenced a few sites.
> > Found out, you have no idea what you are talking about.
> > I will just rely on the knowledgeable posters in this group.

>
> Exactly what was it that Alf (who is indeed one of them most
> knowledgeable and courteous posters on c.l.c++) wrote was disproved by
> your few minutes of web surfing?
>


Well, looking up 'Bjarne's C++ book' isn't necessarily web surfing,
although I did do some web research on pointer arithmetic as well.

Also, 'It's incredible that you have programmed for 10-15 years and
don't know this.' isn't what I would call courteous or welcoming.

I have found Kai's, Erik's, and Juha's responses very courteous and
what I needed and in return I was courteous.


> Where are all of these brash newbies coming from lately?


I am sure, if some of the denizens of c.l.c++ were more apt to help
than to insult out of the OP, they may not be so "brash". I know this
is USENET, and you guys have your share of jerks and spam, but there
is no reason to assume that of everyone.




 
Reply With Quote
 
lbonafide@yahoo.com
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 1:19*pm, Danno <(E-Mail Removed)> wrote:

>
> Also, 'It's incredible that you have programmed for 10-15 years and
> don't know this.' isn't what I would call courteous or welcoming.
>
> I have found Kai's, Erik's, and Juha's responses very courteous and
> what I needed and in return I was courteous.
>
> > Where are all of these brash newbies coming from lately?

>
> I am sure, if some of the denizens of c.l.c++ were more apt to help
> than to insult out of the OP, they may not be so "brash". I know this
> is USENET, and you guys have your share of jerks and spam, but there
> is no reason to assume that of everyone.


I think you're taking this way too personally, and I don't consider
Alf's comment to be an insult, just his opinion. And AFAICT, nobody
accused your post of being spam or you being a jerk. I do think it's
evident that you haven't read much of this group before posting or
your opinion of Alf would be different perhaps.
 
Reply With Quote
 
Danno
Guest
Posts: n/a
 
      03-31-2008
On Mar 31, 1:30 pm, (E-Mail Removed) wrote:
> On Mar 31, 1:19 pm, Danno <(E-Mail Removed)> wrote:
>
>
>
> > Also, 'It's incredible that you have programmed for 10-15 years and
> > don't know this.' isn't what I would call courteous or welcoming.

>
> > I have found Kai's, Erik's, and Juha's responses very courteous and
> > what I needed and in return I was courteous.

>
> > > Where are all of these brash newbies coming from lately?

>
> > I am sure, if some of the denizens of c.l.c++ were more apt to help
> > than to insult out of the OP, they may not be so "brash". I know this
> > is USENET, and you guys have your share of jerks and spam, but there
> > is no reason to assume that of everyone.

>
> I think you're taking this way too personally, and I don't consider
> Alf's comment to be an insult, just his opinion.


You say that as if opinions and insults are exclusive.

> And AFAICT, nobody
> accused your post of being spam or you being a jerk.


Never said that anyone did... I said that members here probably have
their share of jerks and spam.

> I do think it's
> evident that you haven't read much of this group before posting or
> your opinion of Alf would be different perhaps.


That's hopefully obvious from my original post . I did look for
other posts that may have an answer before posting.

I hope that Alf and some other users takes some of my advice and offer
up some civility and maybe some humility. There will always be a lot
of noobs and people who have a new projects where a little or a lot of
C++ is involved and/or will need a refresher. They may not be brash
but only reacting to how they are treated and/or welcomed in this
forum.

I also hope that if you and Alf ever find yourself in a forum of
another programming language (good to continually learn new
languages ) that you get treated respectfully and professionally
like I how I was treated by you, Kai, Juha, and Erik on this thread.



 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      03-31-2008
* Danno:
> On Mar 31, 10:45 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
>> * Danno:
>>
>>> On Mar 31, 2:01 am, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
>>>> * Danno:
>>>>> I have decided that this year, I will refresh my C++ skills since they
>>>>> are old and brittle. I have moved onto other languages over the past
>>>>> 10-15 years or so, and all the languages I have taken to don't have
>>>>> the pointer logic associated with it (Java, Ruby, etc).
>>>> I think you mean "pointer arithmetic", because Java certainly have pointers.
>>>> Java reference values are pointers. They're called pointers by the Java
>>>> language definition (just consider what the heck you think a Java
>>>> NullPointerException is all about), and they act like pointers.
>>> I was trying to be careful with the term, I did't think pointer
>>> arithmetic was the best term.

>> It was, if that was what you were referring to.
>>
>> You ended up being the opposite of careful.
>>
>>> Pointer arithmetic is when you use
>>> mathematical terms to manipulate the pointer (increment, decrement,
>>> comparison). In C++ you can do that, but I used the general term
>>> 'pointer programming' so it can include pointer arithmetic as well as
>>> merely setting the reference.

>> Java does have pointers. What it lacks is pointer arithmetic, and the ability
>> to form pointers in other ways than via new.

>
>
> What???? You just implied that java has pointer arithmetic. haha


Nope.


Cheers, & hth.,

- Alf
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 0 11-14-2009 11:21 PM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:30 AM
Why my working ps/2 mouse freezes and even don't even get recon.after reboot ? demi General Computer Support 0 08-03-2007 05:28 AM
Even older fart, even newer newbie Stan Goodman Java 11 07-04-2003 07:32 AM



Advertisments