Pointer are unnifficient

Started by
29 comments, last by Andrew Nguyen 22 years, 3 months ago
Correct me if I''m wrong, but your problem with pointers seems to be that they make code confusing. Agreed, A->Z->F->WhatTheHellIsThisHereForAnyways->SomeRandomClass is what a lot of it ends up looking like, but is that the pointers fault? No! That''s the fault of the programmer who seems to enjoy writing insanly complicated code in hopes that no one else steals it. It''s kind of like that one dumb saying that everyone keeps using. "Guns don''t kill people, People kill people." Um... yeah... make up your own analogy there. I''ve used up my brain power alotment for the day. ^_^

-----------------------------

Vash the Stampede

"Love & Peace!"
// Tojiart
Advertisement
A life without pointers would be sooo empty !!
-------------Ban KalvinB !
Honestly you shouldn''t be telling people what they should/shouldn''t code like. Every programmer has a style that they develop from both personal, and professional experiance. Habbits that are introduced from work or that are picked up by reading others code. However this usualy develops over time due to nessassity or being told by someone with much more experiance than yourself that "Coding like this is bad". As the coder develops his style, he also improves his coding habbits and develops into a better programmer. This is all a time issue. Just like learning pointers takes time. Developing a coding style that is both efficent and understandable to others takes time. This a place of learning, you can obviously expect the code presented here to be consistantly in some sage of development.

My advice to you Andrew, is to stop going around telling people what you think is right/wrong in coding but instead implement it yourself. Possibly present your solution to the community in a way which will not start a flame war. Opening your comments with "Pointers suck" does not accomplish your goal of being taken seriously.

In the end it''s not your decision what other programmers decide to do/not do. So don''t take this thing so damn personaly. Present your case, give good reasons why you think it is better, and let the rest of the people who read it decide for themselves.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
I have a question. I''ve always used pointers to keep from chewing up vast amounts of memory bandwidth passing data from function to function, etc. How is this inefficient?


----
Herb M. (mdfmKoRn)
www.sky-meyg.com
s3202@attbi.com
Fine then, I''ll use goto''s and use a basic style of coding...
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
Please tell me that English is your second language.
[xian]
Interesting opinion, and I emphasize the word opinion.

I remember struggling through pointers when I first learned to program in C. After actually using pointers and completing programs of my own, pointers made sense. Not only did they make sense, but they were incredibly convenient and useful in a number of cases.

If you like to use them, use them. They are there for people to use if they so wish.
you''re here on gamedev, most people here like coding games or at least demos of some game or grafic-engines. now games or grafic-engines or what ever engines has one important thing: REALTIME.. you can''t code that fast code with high level api''s (you mentoyed perl.. haha.. nice for server-scripts but come one.. THAT CODE does look like crap.. everything global and only one type.. tell me that is bether than goto in c)

now if you want fast code you use low-level. lowest is assembler.. assembler is only pointers and gotos

hm you say pointers are unniffizient (==inefficient).. why do high-level-languages not use them but low-level do? because high-level-languages are for simplicity, not for fast code. means its EASY TO LEARN AND SIMPLE TO GET RESULTS and yep, like that it is fast.. like visual basic.. you get your hello world in a few minutes..

but come on, no game is coded in visual basic (quake not, unreal not, outcast not etc..) no operating system is coded in a highlevel-language.. why? cause you CANT..

and my tip: learn how computers work.. you can do this with c/c++ and some little inline-assembler.. once you understand the language your computer really speaks you know why to use lowlevel.. its so much simpler than any highlevel..

you simply don''t understand and like that you got bored because you could not use the code of the other person and you got angry cause you could not rip his code. (i guess sounds like me half a year ago..).. take your time and you will see, its all soo easy, but never give up. you just dont see the tree because of the forest in front of it..

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Pointers are used because its 4 bytes.

Let's say you have a string that is 8000 characters.

If you don't use pointers, then when you call a function, it has to pass the entire string on the stack (temporary memory between functions) and copying the 8000 characters can be slow if you are calling alot of functions.

Yes pointers are useless if you have 1 gigantic function with GOTO's in it. But since that is very sloppy and hard to read, you have to use functions. The more data being passed around in functions the slower it goes.

Thats why pointers were made, they are small, and they will give you the same results as the 8000 character string... Because you POINT to the string instead of work with it directly.

Thats why BASIC is not a good language because it doesn't allow pointers because "its confusing." The side effect, it's slower.

In C, instead of 8000 character strings passed between functions, just a pointer of 4 bytes that POINT to the string (in memory) is passed around on the stack.

A pointer to a pointer is confusing yes... But they make perfect sense. Think of it as train tracks. Each pointer is a switching station. They can point to new tracks, the same track... All around.

Pointers have 2 parts, "Where they are" and "Where they point"

Pointer changes "Where they point"

Pointer-Pointer changes "Where they are" and "Where they point"

You don't ever really have Pointer-Pointer-Pointer... Because there is only 2 properties to a pointer... So the most you ever really have is 2 ... Pointer-Pointer.

Edited by - Joeyblow2 on January 2, 2002 4:28:47 PM
If you don''t want to use pointers by yourself,
go on and program in JAVA you also get nearly platform independent progs.

But don''t believe JAVA doesn''t use pointers, it does,
but you wont see it directly.

I''m programming in JAVA, C/C++, and in Assembly and like all of these languages and I''ll tell you one thing, you wont come out without pointers.

Do you like arrays?
Yes?
hmmm, they''re implemented through pointer.

Do you like dynamically allocated memory ?
Then I''ll think you want to find it once it is allocated, or not?

Do you like accessing RAM or I/O or ...
Then you''ll need a minimum of one register which contains the adress of that particular region.

Do you like calling functions.
If so you need the adress of that function.

And that are only a few examples ...

And somtimes even pointers to pointer bring some advantage !!!

Hint: In C++ you can use a reference if you only want to point to one adress ( references are something like unmutable pointers ), this is sometimes easier to use because of a simpler syntax, but could also be cionfusing somtimes.

So I hope you''ll change your attitude to pointers now.

This topic is closed to new replies.

Advertisement