using classes vs. modules

H

Harald M. Genauck

Michael C said:
If it's aimed at beginners and professionals they why didn't they add
pointers to VB? The beginners don't need to use the pointers so it
doesn't cause them any trouble but the experts can still use them.
Same goes with the yield return keyword, writing your own linq
extensions is a slightly advanced topic which they thought was not
necessary for beginners.

Maybe I didn't write my own linq extensions. But at all I never did
miss the yield keyword.
Pretty much, the pro does not need the comfort of all the extra
words, it's just unecessary and slows them down.

Some pros believe in to be ascetic, others do enjoy comfort. I think
this is somewhat of personal taste. And, to have a choice is better
than to have no choice.
I noticed both you or Herfried snipped my point about pointers and
unsafe code. If VB is aimed at pros then why is it missing "the"
biggest pro feature of all time?

Even pros do rarely need pointers and unsafe code in most desktop or
web oder other server or service applications. But, if a scenario does
need uncommon features you have to choose the appropriate tool to solve
your task. That's not new with .NET, neither with VB nor C#.


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
H

Harald M. Genauck

Michael C said:
Actually there are many reasons, you are probably just not aware of
them.

So then ... C# is not appropriate for pros, because you cannot write
inline assembler (AFAIK), as there are some scenarios for that and C#
is uncomplete at this point.
As I said to Herfriend, even graying out a bitmap in a webpage can
use pointers. If you do any reasonable amount of work with bitmaps
then their use will come up and obviously bitmap use is common these
days. In VB can you can copy the data from the bitmap to an array and
back (line by line usually) but this is just as unsafe as unsafe
code.

So many libraries out there for graying out bitmaps. Maybe, these are
using pointers internally. Maybe, these libraries are written in an
appropriate language for that task. Sure, that I won't write a library
of that kind by myself. Sure, that I won't need pointers in this case
to write professional applications.


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
H

Harald M. Genauck

Michael C said:
Perhaps you think pointers are more scary/dangerous than they really
are.

It seems that most malware scenarios depend on incorrect pointer
arithmetics resulting in buffer overflows. No pointers, and 90% of
cracking has no chance.
To me they are no big deal, if I need to go through some data at high
speed then use a pointer. You can't get much more of a perfect
example than modifying an entire bitmap.

Likewise one should avoid calling module's methods without qualifiers
and people cannot write good code without beeing flooded by compiler
warnings and errors (as you stated as your opionion), a developer even
should be prohibited to use pointers.

BTW: Does C# show compiler errors or warnings on incorrect pointer
arithmetics?
What happens if you don't have the bitmap until runtime?

If I don't have a bitmap at runtime my code cannot handle it at
runtime.


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
H

Harald M. Genauck

Jason Keats said:
Michael must think that there are no professional Java programmers
either.

The simple fact is that the pointer data type is not required - in VB
or Java (or many other languages).

Here's what Sun says about pointers:

"Most studies agree that pointers are one of the primary features
that enable programmers to inject bugs into their code. Given that
structures are gone, and arrays and strings are objects, the need for
pointers to these constructs goes away. Thus, Java has no pointer
data types. Any task that would require arrays, structures, and
pointers in C can be more easily and reliably performed by declaring
objects and arrays of objects. Instead of complex pointer
manipulation on array pointers, you access arrays by their arithmetic
indices. The Java run-time system checks all array indexing to ensure
indices are within the bounds of the array.

You no longer have dangling pointers and trashing of memory because
of incorrect pointers, because there are no pointers in Java."

Conclusion:

What a desaster of design: A _managed_ (!) language that basically
allows unsafe pointers and unmanaged code.

Besides that, calling a module's method without a qualifier or using
the My namespace seems to be peanuts.

;-)


Viele Grüße

Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de (Chefredakteur)
"ABOUT Visual Basic" - http://www.aboutvb.de (Herausgeber)
 
H

Herfried K. Wagner [MVP]

Michael C said:
I'm suprised you don't use C# yourself. :)

Be assured that I use C# myself, but this doesn't make it one of my favorite
programming languages.
 
M

Michael C

Rory Becker said:
All Hail Michael C..

...King of "Not Invented here" ...Master of mistrust
...Lord of the pointer Hammer

He who is probably going to rewrite the .Net framwork itself over lunch :D

Interesting reply Rory. Are you 12 years old? :)

Michael
 
M

Michael C

Harald M. Genauck said:
It seems that most malware scenarios depend on incorrect pointer
arithmetics resulting in buffer overflows. No pointers, and 90% of
cracking has no chance.

Like sql injection? High level techniques have just as many problems as
pointers but are harder to fix because you don't have all the source code
available. Pointers are like any other technique, you have to be careful
with what you do.
Likewise one should avoid calling module's methods without qualifiers and
people cannot write good code without beeing flooded by compiler warnings
and errors (as you stated as your opionion),

No, that is your twisted version of my opinion.
a developer even should be prohibited to use pointers.

I don't think so. The framework does it pretty well imo with the need to
specify the code as unsafe.
BTW: Does C# show compiler errors or warnings on incorrect pointer
arithmetics?

It will show compile errors on some mistakes but the whole point of pointers
is that many of the normal compiler checks are not done. That is what you
want it to do!
If I don't have a bitmap at runtime my code cannot handle it at runtime.

Great, very interesting. My question however was "What happens if you don't
have the bitmap *until* runtime".

Michael
 
M

Michael C

Harald M. Genauck said:
So then ... C# is not appropriate for pros, because you cannot write
inline assembler (AFAIK), as there are some scenarios for that and C# is
uncomplete at this point.

There is no asm support in C# but I'm not sure how that is relevant.
So many libraries out there for graying out bitmaps. Maybe, these are
using pointers internally. Maybe, these libraries are written in an
appropriate language for that task. Sure, that I won't write a library of
that kind by myself. Sure, that I won't need pointers in this case to
write professional applications.

But then you need to purchase one of these libraries when I can write a
simple page of code to do the same thing and not spend $300. Possibly I can
do it better because I can tailor it more to my situation.

Michael
 
M

Michael C

Rory Becker said:
The ability to concentrate my mind on things that actually matter to my
client.

Things other than the details of exactly how grey the bitmap should
become.

If I spend my time redoing already

This is just an example rory. I was once asked to perform a custom
modification to a bitmap for a business app.
I always trust a carefully chosen 3rd party to do specialist tasks, which
then frees me up to do the actual work I was contracted to do.

So you don't trust your own ability?
Again... The .Net Framework's *primary* use is LOB apps which have very
few reasons to use pointers.

That is your opinion. MS themselves wrote (or assisted I believe) a paint
app with very heavy use of pointers.
Therefore while they will have their uses, pointers are just not that
important in the .Net Framework, hence in any language that uses it.

I guess if you shell out all the hard work to third parties then they aren't
necessary. But that is how beginners program imo, which probably makes VB
perfect for you. :)

Michael
 
M

Michael C

Michael D. Ober said:
OS development is the primary user of pointers.

Where on earth did you get that idea?
Obviously there are others. The issue is that in almost all cases,
pointers can be avoided by better design.

The only way to avoid pointers is to use someone elses code, which is using
pointers.
Actually, I don't generally trust 3rd party code unless I either have the
source to review/compile/link. This means when I do use 3rd party code,
regardless of source, I test heavily to ensure there isn't something
broken in that code. I come from a background where the code must be
validated before usage, which means that anything, including pointers,
that can generate hard to find bugs, needs to be reduced or eliminated.
This is obviously not always feasible, but it's a goal all professional
programmers should strive for. Your love affair with pointers

My love affair with pointers? Don't get the wrong idea, I don't use them
every day. But on the other hand I don't avoid them when appropriate. I use
the correct tool for the job.
would disqualify you from any type of 24x7x365 development.

That's as silly a statement as you OS development one. :)
 
H

Harald M. Genauck

There is no asm support in C# but I'm not sure how that is relevant.

It's as relevant as pointers and unsafe code.
But then you need to purchase one of these libraries when I can write
a simple page of code to do the same thing and not spend $300.
Possibly I can do it better because I can tailor it more to my
situation.

Wow ...! I don't know how many hours you will work for $300. One day,
a few hours more or less? Doesn't matter, but, if you are able to
develop a graphics library in a stable, full functional and well
documented manner in that time frame, for that price ... you are
welcome to work for me.
;-)


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
M

Michael C

Harald M. Genauck said:
It's as relevant as pointers and unsafe code.

Rubbish. The framework returns pointers to you and they actually expect you
to use them. The simple fact is that you cannot write code faster any other
way.
Wow ...! I don't know how many hours you will work for $300. One day, a
few hours more or less? Doesn't matter, but, if you are able to develop a
graphics library in a stable, full functional and well documented manner
in that time frame, for that price ... you are welcome to work for me.
;-)

I don't need to develop a graphics library. I just to write one simple
function and a certain technique is useful for this function.

Michael
 
M

Michael C

Rory Becker said:
What I meant to say was....

If I spend my time redoing work already implemented perfectly well by a
thirdy party then I could well expect....

...to miss other project related issues whilst busy coding something I
don't need to.
...to code it worse than the experts I should have delegated to.
...the project to overrun
...the client to fire me or at the very least not employ my services
again.

Obviously you need to take into account the factors of the current project
when you make a decision. But that does not mean that you should always use
third party tools. There are many factors to consider. Do you need only a
very small subset of this tool so could code it easily? How long will it
take to evaluate all the possible tools and learn how to use them? Would
they have bugs you cannot fix? Would they not quite do what you want so
you'd be forced to make compromises? Would it add extra dependancies during
install?

The example I brought up before was the company I was working for wanted
their logo put into the background of the apps MDI form. The logo needed to
be embossed and needed to be coloured to match the users choice of MDI
background colour. I could have used a third party tool but for such a small
job it seemed like overkill. It certainly looked doubtful that this tool
would save time, in fact it was pretty much a dead certainty it would cost
time. I doubted I would get to spend any money on such a small job anyway.
In the end I just wrote a simple routine to modify the bitmap pixel by pixel
using pointers. It took half a day or so and was fast, stable and light. I
think in this situation to use a third party tool would have been the wrong
choice. Certainly if you have the attitude that pointers are bad and should
never be used then you don't have that choice.

Michael
 
H

Harald M. Genauck

Michael C said:
Obviously you need to take into account the factors of the current
project when you make a decision. But that does not mean that you
should always use third party tools. There are many factors to
consider. Do you need only a very small subset of this tool so could
code it easily? How long will it take to evaluate all the possible
tools and learn how to use them? Would they have bugs you cannot fix?
Would they not quite do what you want so you'd be forced to make
compromises? Would it add extra dependancies during install?

The example I brought up before was the company I was working for
wanted their logo put into the background of the apps MDI form. The
logo needed to be embossed and needed to be coloured to match the
users choice of MDI background colour. I could have used a third
party tool but for such a small job it seemed like overkill. It
certainly looked doubtful that this tool would save time, in fact it
was pretty much a dead certainty it would cost time. I doubted I
would get to spend any money on such a small job anyway. In the end I
just wrote a simple routine to modify the bitmap pixel by pixel using
pointers. It took half a day or so and was fast, stable and light. I
think in this situation to use a third party tool would have been the
wrong choice. Certainly if you have the attitude that pointers are
bad and should never be used then you don't have that choice.

Is this company changing their logo daily? Or why must it be embossed
at runtime? Otherwise I would prefer to emboss it once using a
graphics app like Photoshop.


Harald M. Genauck

"VISUAL STUDIO one" - http://www.visualstudio1.de
"ABOUT Visual Basic" - http://www.aboutvb.de
 
M

Michael C

Harald M. Genauck said:
Is this company changing their logo daily? Or why must it be embossed at
runtime? Otherwise I would prefer to emboss it once using a graphics app
like Photoshop.

The logo wasn't changed and it was embossed once, it just needed to be
coloured at runtime because we didn't know what background colour the user
would select until then.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top