Reply to post: Re: Unfair C++ bashing

Revealed: The 25 most dangerous software bug types – mem corruption, so hot right now

Baldrickk

Re: Unfair C++ bashing

Well... not always stupid to use raw pointers in C# - I once had an over 600% performance improvement.

No wait. I meant 600x (60,000%)

Achieved by moving from standard .net functions to raw pointer bashing - albeit in the small, single function that did all the heavy lifting in that application, with all the "unsafe" code being segmented away from the rest of the application.

getPixel() and setPixel() are horribly inefficient for manipulating entire images, as each call sets up mutexes and similar operations, only to strip them down and make new ones in the next call. Far more efficient to set up a single mutex and do all you need in one go. This was a long time ago now, and there may be better ways of doing it now.

As with all things, there is a time and a place. I agree that the managed nature of C# makes the usual raw pointer shenanigans almost impossible to do (I had to jump through a number of hoops to make it work).

Likewise, I love python these days, and it's my go-to for a lot of personal projects. Sometimes though, people write modules in C, to then incorporate into their python programs, for performance reasons.

Use the correct tool for the job.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon