Herfried K. Wagner said:
Unsafe pointers are no "professional" feature.
Come on Herfried, they are "THE" professional feature. They are certainly
something a beginner would struggle with.
Today they are just a feature which is used in very special domains
(low-level development, which is typically done using C) and in interop
scenarios in order to access legacy libraries and code (such as COM
components and other unmanaged APIs). In user-mode development (.NET has
been designed for that) unsafe pointers are really unimportant.
That's really not true. For something as simple as bitmap manipulation you
need to use pointers. This isn't exactly an obscure a feature. The framework
even has a method (Bitmap.LockBits) that returns you a pointer. I get the
impression that a lot of VBers think that unsafe code is like a bomb, ready
to go off at any moment, highly unstable and difficult to handle. Really,
unsafe code is just a way of saying to the compiler "I have double checked
and tripled checked this code so you don't need to run all the normal checks
because I've done them".
Same goes with 'When' clauses in 'Try...Catch' blocks, same goes with
event support as provided by VB, same goes with language-integrated XML
features,
Not really, these are not advanced features.
Sorry, the actual feature set doesn't have a significant influence on
wether or not a language is suitable for beginners and/or professionals.
Actually I have seen C# developers struggling with p/invoke function
declarations involving unsafe pointers although the exact same result
could have been achieved by safe code.
I've seen very capable developers in VB too. I might not be the best
developer in the world but I have been coding full time for the last 10
years. When I moved over to C# I realised it was more aimed at people like
me.
Once simple Windows applications have been written in C using pointers and
the Win32 API. On the other hand, other people used VB for this purpose
and didn't need pointers at all to achieve almost equal results. Which
way would you consider more professional?
Depends on the situation. Using the wrong language is something I would
considered unprofessional.
VB is a secure and high-level programming language for development of
applications for the user mode.
In which cases are you still using unsafe pointers? Just give some
examples, but do not list any interaction with legacy technologies (native
libraries, COM, ...).
I have used them for bitmap and video manipulation.
BTW, I am aware that pointers are sometimes used for direct access to
bitmap data, but this is a really special case
It's not really that special a case. You could use this to make a bitmap
looked grayed out in a webpage. I actually use it for every bitmap I open
from a file. In dot net for some reason the bitmap you open is always tied
to the file you opened it from. Nothing I could find could unlock this
association, even using Bitmap.Clone had problems. My solution was to open
the bitmap, create a second bitmap of equal size and use pointers to copy
the data from one bitmap to another. This way you got a bitmap which was
completely independant of the file. In Paint.Net (a free paint program which
was assisted by some MS programmers) they went one step further and defined
their own buffers for every bitmap (using GlobalAlloc i think) and then
associated that buffer with the bitmap object.
in which I'd consider writing a class library using C++/CLI or maybe C#.
If you're using C# then there is no reason to step out to C++, you can just
write the code inline. It works really well. I get the impression you're a
good programmer so I imagine you'd quite enjoy using pointers.
Michael