Linked by Jussi Pakkanen on Tue 17th Apr 2007 18:20 UTC
Editorial Let me begin by telling you a little story. Some time ago I needed to run a script at work once a day. We had tons of machines ranging from big Unix servers to Linux desktops. Due to various reasons the script could only be run on a desktop machine. However using cron was disabled on desktops. All other machines allowed cron.
Thread beginning with comment 231746
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE: Even further with C/C++
by Zenja on Tue 17th Apr 2007 23:19 UTC in reply to "Even further with C/C++"
Zenja
Member since:
2005-07-06

Why are so many people scared of pointers and memory management? For all the projects I've ever worked with, memory issues and pointer arithmetic were never issues, ie. code once, works everytime. If you understand what's happening in the backend, there really is no issue. But then again, I cut my teeth with assembler back in the early 80's, so you had to know what you actually wanted at that level. Migrating to C and using pointers was a no brainer. Understanding memory layout of C++ VTables takes some time, but you just have to figure out how you'd design polymorphism using plain old C and resizable structures on your own, and **smack hand on forehead** this is how C++ handles VTables.

Having said all that, STL containers are still unpredictable, but you really have to step away from the nitty-gritty to use them.

These days, memory management issues boil down to optimising data to fit in level 1 and level 2 caches, and memory alignments.

If you still have trouble with pointers / memory management, it's time to learn assembler and design your own memory management library. Then everything will just click.

Reply Parent Bookmark Score: 4

RE[2]: Even further with C/C++
by Doc Pain on Tue 17th Apr 2007 23:33 in reply to "RE: Even further with C/C++"
Doc Pain Member since:
2006-10-08

"Why are so many people scared of pointers and memory management?"

It's because their use needs education far far ahead of clicking around in a GUI. All this low level stuff needs more time to get knowledge about than most of the preconfigured and predesigned stuff. It's not that pointers are bad by priniple, they're just not everyone's first choice. If you write a simple solution for a simple problem, pointers are fast and easy, while they can cause problem in a very big project, especially if you've lost the overview. Furthermore, I think this basic C stuff is considered outdated by today's developers, only geeks and el33tists do use them for useless things.

"But then again, I cut my teeth with assembler back in the early 80's, so you had to know what you actually wanted at that level."

Assember is more basal than pointers, and, of course, it depends very strongly on the hardware you're using. I remember Macro-MOPS on the R300... :-)

"Migrating to C and using pointers was a no brainer."

On the other hand, character string operations need more "writing" (typing in source code) than, let's say, Java.

"If you still have trouble with pointers / memory management, it's time to learn assembler and design your own memory management library."

As an educational project, I developed a smalloc() / sfree() ("safe malloc") with CATCH and THROW macros in C many years ago. Surely, not very usable, but all the little things we program are at least a bit of education, experience, and, maybe, fun. So I would not say pointers or asm are useless "because nobody uses them anymore".

Reply Parent Bookmark Score: 3