how important is having knowledge about pointers?

Go To


i am very weak in pointers , blame it on not having access to some good books .. while designing a compiler in c , how important is it to have a good knowledge about pointers?.. any good books??

2009-06-16 09:33
by Hick
Is this a serious question or just a troll - Erich Kitzmueller 2009-06-16 09:40
very serious ...!! do i sound funny .. or do they who are replying ..! - Hick 2009-06-16 09:45
Your question looks like a troll. You might as well ask "how important is having knowledge about HTML when designing a website". It's simply unbelievable for me that you want to design a compiler without that knowledge - Erich Kitzmueller 2009-06-16 09:47
@mekasperasky May I suggest that if you stop using !! and ?? and .... in everything you write, people may stop thinking your a troll. ? and ! are enoug - Nathan W 2009-06-16 09:48
Trust me, the people who are replying sound much, much more serious - Suvesh Pratapa 2009-06-16 09:53
I think you need to give up on compiler and concentrate on learning the basics. Developing a compiler isn't trivial task, you have to master the language first. Don't take it personally, just get real - you are not in the position to develop a compiler - qrdl 2009-06-16 10:56
Perhaps you should consider developing your C compiler in Visual Basic instead - mquander 2009-06-16 18:28


It's really, really important that you fully understand pointers when working in C (or C++) especially. So many things come down to manipulating pointers and memory, and there are a lot of "tricks" used related to pointers that may come up during compiler development in C.
"Good books" aren't really going to help you, it's just a concept that you need to get your head around.
Google for pointer tutorials on the net, and work through them until it clicks. For example:

2009-06-16 09:36
by Joris Timmermans
Another tutorial I found is at: - Greg Hewgill 2009-06-16 09:51
I would agree. Almost everything is a pointer or manipulation thereof. Always thought "Pointers for C/C++ Coding" would be a good book title - ChrisBD 2009-06-16 11:08
@ChrisBD: there is an except book by Ken Reek called "Pointers on C" :- - Evan Teran 2009-06-16 17:35
Kenneth Reek's "Pointers on C" is quite good, albeit a little on the expensive side (most seem to be!) - oevna 2009-06-16 19:31


On a scale from 1-10, about 12. It's a vital part of the language, and an even more vital part of a compiler.

2009-06-16 09:34
by jalf


It is of critical importance.

2009-06-16 09:34
by Eric
how??.. where will find it in use in compiler development??! - Hick 2009-06-16 09:35
See my answer below - Alex Brown 2009-06-16 09:41
srsly, if you dunno about pointers, how would you even understand the simplest linked list implementation - Johannes Schaub - litb 2009-06-16 09:42
You will most certainly run into it when you get to memory management in the compiler - Joris Timmermans 2009-06-16 09:43
pretty much everywhere see Marco's answer. If you don't understand pointers you really shouldn't be looking a writing a compiler - Nathan W 2009-06-16 09:44


That is pretty basic. If you don't know that, you are far from writing a compiler in C, since that is all about dynamic structures (trees), and the operations on them.

Parsing usually yields a tree that is sometimes transformed to another tree after semantic analysis, then modified (e.g. optimization), and then written out to a more linear format (IL or something that is one step above label-assembler)

2009-06-16 09:35
by Marco van de Voort
how are trees involved in compiler design?? would u mind explaining - Hick 2009-06-16 09:38
The parser constructs a tree as an abstraction of the cod - Nils Weinander 2009-06-16 09:39


A compiler writer needs to know about pointers, since she or he will be designing a machine to turn a high-level language such as c or pascal or perl into assembly code or machine code.

You cannot write assembly code without understanding pointers, it's just out of the question, unless you never want to have objects or globals or pass by reference or interact with the operating system to open read from files or write to a display buffer.

All of which are handy things for a user of your compiler to have.

2009-06-16 09:40
by Alex Brown


It is very important. I started out developing (C, C++ and now Objective-C) without any knowledge and certainly not the patiantce to read about pointers. Working with them made me aware of the basics, but that was it.

It didn't cause any real problems at first, while my programs were simple, but in the long run, when my programs became more complex and my work more important (i.e.: other people depending on them), my lack of knowledge about pointers caught up on me and I had to rewrite and re-understand most of my code .. that was the bitter reality and the consequence of me not caring about something that is so important in low(er) level programming..

Also have a good understanding of garbage collection or retain counts (malloc, dealloc, new, etc. etc.) Freeing and creating objects at the right time is very, very important as well and closely related to pointers.

2009-06-16 09:37
by Jake


Even if pointers arent very much used by the programmer in modern managed-code languages they are still used in their compliers and can help you as a programmer to produce better, faster, more stable programs.

As an example I wouldn't know how to explain why you should use StringBuilder instead of string when concatenating a lot of strings without saying the word pointer:).

2009-06-16 09:37
by AlexDrenea


In C? Strings are represented as pointers (to null-terminated sequences). Several standard library functions take pointers to other functions (qsort). There's no need to write your own linked list or binary tree implementation, but every one out there will use pointers, and expect you to understand them.

Additionally, if you want to put something somewhere other than the stack, you'll need to use pointers. Generally you'll open files and get back a "file pointer" which is a struct that you interact with as a pointer.

And then, if you intend to compile a language that has pointers itself, ...

Overall this is something you can't just get by without.

2009-06-16 09:38
by Max Lybbert


You really have to get to grips with pointers in order to successfully program in C. Without them you won't be able to properly handle memory management, implementing most advanced data structures and pretty much any other resource management. You'll also have problems dealing with arrays (as they can and will degrade to pointers in certain circumstances) so I'm afraid you'll have to learn how to use them propery.

2009-06-16 09:39
by Timo Geusch


In C you are always dealing with pointers in one way or another. It's nearly impossible to not use them and performance wise very important. So basically to develop FAST, SECURE and readable code you should make yourself familiar with this topic. There are so many good books out there... let me see... I really like "C Unleashed", but there are many good tutorials out there.

2009-06-16 09:39
by merkuro


If you start writing in C/C++ it's first thing you should get to know , otherwise writing in C will be a horror . Learn how to pass pointers and data via pointers to functions , how to debug program using pointers and study the math of pointers . If you get to know this well you won't get lots of problems later

2009-06-16 11:44
by red777