Page 1 of 2

Be a pointer my friend !

Posted: Tue Dec 09, 2008 9:01 am
by i586coder
Hi guys,

while i was reading a book around UNIX history & C, i liked the advice that says:
Empty your memory. with a free(); like a pointer.

If you cast a pointer to a integer,it becomes the integer.
If you cast a pointer to a struct,it becomes the struct.

The pointer can crash,...,and can overflow.

Be a pointer my friend !!!
Dennis Ritchie
what do you think guy's about that advice :?:

for me,..., pretty good,especially that written by the inventor of C.

in conclusion: look how maker commented :!: ...


CheerS,
a.T.d

Re: Be a pointer my friend !

Posted: Tue Dec 09, 2008 9:50 am
by Troy Martin
Very poetic! And funny!

Re: Be a pointer my friend !

Posted: Tue Dec 09, 2008 10:18 am
by Love4Boobies
Not really poetic :) It's trying to shout out "MANAGED CODE FTW"!

Re: Be a pointer my friend !

Posted: Tue Dec 09, 2008 10:58 am
by DeletedAccount
Hi,
I however use them liberally . If you have the proper tools then using pointers should not be such a big problem .

Regards
Shrek

Re: Be a pointer my friend !

Posted: Wed Dec 10, 2008 8:51 am
by neon
I like everything but this part: The pointer can crash,...,and can overflow. Why would you want to be a pointer if this can happen?

Other then that, its kind of cool :)

Re: Be a pointer my friend !

Posted: Wed Dec 10, 2008 10:47 am
by i586coder
Hi,

well,...,now the question is, why Dennis Ritchie said that ?

Troy Martin wrote:Very poetic! And funny!
maybe for fun :P

or
Love4Boobies wrote:Not really poetic :) It's trying to shout out "MANAGED CODE FTW"!
maybe to tell us the advantage of pointers & the same time the risk of using it :wink:

CheerS,
a.T.d

Re: Be a pointer my friend !

Posted: Wed Dec 10, 2008 9:27 pm
by thre3dee
I'm a fan of pointers and not much of a managed fan.

I'm also a fan of the "Object" base class mechanism used in so many shared object frameworks. But I'd much rather an object that *I* release than having some manager release it for me at some obscure "later time".

Its like the [object autorelease] mechanism in Mac OS X Cocoa framework. I wondered where it got released and then found out basically its on the next loop so the current context is guaranteed to have the reference valid. It was then I came to like the autorelease because I knew *when* it was being released.

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 1:50 am
by Solar
thre3dee wrote:I'm a fan of pointers and not much of a managed fan.
+1.

The issue being, most "managed fans" are fans of managed code because they never really got their minds wrapped around pointers - and I consider that a dangerous thing, because if you didn't understand pointers, your managed code will show (and suck...).
I'm also a fan of the "Object" base class mechanism used in so many shared object frameworks. But I'd much rather an object that *I* release than having some manager release it for me at some obscure "later time".
Or, in the case of Java, probably never. ;-) I really "like" how that language introduces a special keyword for their version of destructors (finalize), but there is no guarantee whatsoever that it actually gets called, even when the VM itself shuts down. :twisted:

Managed Code and GC is great for Rapid Application Development and an "easy way" into programming, but it comes at the cost of understanding and control.

That being said, I used both, and will continue to do so, as both have their advantages. Personally, though, I like the "ugly butts" among the programming languages, and that's why I prefer C++ and Perl over Java and Python. ;-)

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 10:29 am
by Colonel Kernel
Solar wrote:The issue being, most "managed fans" are fans of managed code because they never really got their minds wrapped around pointers
I think there are several thousand developers at Microsoft using C# to build highly reliable and scalable systems that would disagree with you.

I've just set a bear trap for you... Please don't step in it! ;)
Solar wrote:Or, in the case of Java, probably never. ;-) I really "like" how that language introduces a special keyword for their version of destructors (finalize), but there is no guarantee whatsoever that it actually gets called, even when the VM itself shuts down. :twisted:
That's why C# has "using" blocks and the IDisposable pattern. Deterministic destruction is essential, and it was a mistake for the Java designers to assume they could replace it with finalizers. Finalizers are very much seen as a mechanism of last resort, at least in the .NET world.
Solar wrote:Managed Code and GC is great for Rapid Application Development and an "easy way" into programming, but it comes at the cost of understanding and control.
Again I point to the legions of very smart people implementing web services in C# that scale to millions of users and have nearly 100% uptime... Most people probably take this for granted because all they see is the tip of the proverbial iceberg in their web browser. :P

Don't step in the bear trap! :mrgreen:

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 10:59 am
by DeletedAccount
Hi,
I however love pointers :P .Use them as much as you since they lead to terse code . But I disagree with the control part , It is possible to get almost the same level of control in C# as in C++ or C . But for that the learning curve is much steaper than that of C or C++ . Please do check out C# and the CLR.

The thing I hate most about .Net is that FCL is so large that i do not need to do anything most of the time than call the appropriate methods . It makes me look like a dumpo :mrgreen:

Regards
Shrek

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 11:21 am
by Love4Boobies
It's not avoiding pointers because you don't understand them or aren't good at handling them. The bigger the project, the bigger the chances that you make mistakes. CPUs get faster and faster and we can use this to our advantage by making languages safer, although code produced by them might be somewhat slower. Probably the same discussion took place between some people a while ago when C came on stage and there were a lot of assembly fans claiming that C programmers don't understand how the CPU works. It's a way of making sure you won't get into some classes of bugs.

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 11:30 am
by DeletedAccount
Hi,
There is not that much signifcant reduction in performance , I am pretty much impressed with XNA . We should only optimize only those which gets executed for a significant amount of time . Using FCL is quite easy , but understanding C# and CLR actually is more difficult than learning C or C++ although everything looks so easy on the surface . But I however prefer C++ over C# since i have a lot of emotional attachment towards it .

Regards
Shrek

Re: Be a pointer my friend !

Posted: Thu Dec 11, 2008 11:44 am
by Love4Boobies
Shrek wrote:Hi,
But I however prefer C++ over C# since i have a lot of emotional attachment towards it .
That's never a good thing. I can remeber being very keen on DOS and its ways. Looking back, that's just stupid. People don't like changes but sometimes they are good :) .

Re: Be a pointer my friend !

Posted: Fri Dec 12, 2008 2:05 am
by Solar
Shrek wrote: But I disagree with the control part , It is possible to get almost the same level of control in C# as in C++ or C . But for that the learning curve is much steaper than that of C or C++ . Please do check out C# and the CLR.
I worked with both Java and C# professionally in the past. Please do not think my comments come from lack of experience with managed / GC'ed code.

In the end, it's about personal belief. My experience tells me that people who never worked (earnestly) in the unmanaged realm tend to have a much fuzzier understanding of what is actually going on, and - to dance around the bear trap - they quite often don't really care in their quest to get the next web service going.

That's quite acceptable in many fields of work, and utterly unacceptable in others. Let's say I enjoy working in the latter kind of job.

Re: Be a pointer my friend !

Posted: Fri Dec 12, 2008 6:04 am
by DeletedAccount
Hi,
It is not that much fun to program in C# than in C/C++ for some reason or other . Seriously if you put a resume with skill sets : C / C++ , do you really think you will get a job :?: . C# provides a living for the time being :D .


Regards
Shrek