Be a pointer my friend !

Programming, for all ages and all languages.
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Be a pointer my friend !

Post 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
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Be a pointer my friend !

Post by Troy Martin »

Very poetic! And funny!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Be a pointer my friend !

Post by Love4Boobies »

Not really poetic :) It's trying to shout out "MANAGED CODE FTW"!
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Be a pointer my friend !

Post 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
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Be a pointer my friend !

Post 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 :)
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Be a pointer my friend !

Post 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
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
thre3dee
Member
Member
Posts: 34
Joined: Mon Nov 03, 2008 7:42 pm

Re: Be a pointer my friend !

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Be a pointer my friend !

Post 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. ;-)
Every good solution is obvious once you've found it.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re: Be a pointer my friend !

Post 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:
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Be a pointer my friend !

Post 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
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Be a pointer my friend !

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Be a pointer my friend !

Post 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
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Be a pointer my friend !

Post 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 :) .
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Be a pointer my friend !

Post 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.
Every good solution is obvious once you've found it.
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: Be a pointer my friend !

Post 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
Post Reply