[program-l] Re: C# attributes

  • From: "Mark Long" <marklon@xxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Thu, 24 Mar 2005 00:12:07 -0000

Ah, George, I am sure that you are not old enough to be my father. Tyler's 
certainly but then, so am I with years to spare.
 
Why do applications take more memory these days? It is all bloatware? No, not 
all bloatware although there is an element of that.
 
Let us take a trip back in time to when bands contained musicians rather than 
dancers. Let us say 1985. These were the early days of the PC.
 
All code was 16 bit. Memory addresses were short. Op codes were short. 
Applications only did one thing at a time. When you loaded an application, it 
unloaded the command shell. You could have little background applets called 
TSRs (Terminate - stay resident) but not many and they didn't run at the same 
time as your application. It was a single tasking world. Even in 1985, we were 
using EMS and XMS because 640K simply wasn't enough especially when the OS took 
as much as 32K of that. Most apps were character based. I know that had its 
good points for accessibility and that the switch to windows was more painful 
than root canal work. 
 
I was writing code in those days. A 10,000 line program was a big old beast. 
There was no runtime system to speak off - just some simple IO and a handful of 
libraries and you pulled in what you needed. There was little interdependancy. 
You didn't integrate with the operating system to do things like drag and drop 
or cut and paste because there was no OS to speak of. Even the command shell 
got unloaded when your app loaded and the remainder of DOS was less than 20K. 
 
Expectations were different. If wordpad had a spelling checker then it would 
have been hailed as the best word processor known to man. Now we regard it as 
so feature poor that we would never use it. I had to check if it still shipped 
with the OS. It comes to a little under 6MB running which is about 8 times the 
memory requirement of Wordstar 2000 which was the king WP at the time. The 
bitmaps probably come to about 300K.  Lets have a look at what is loaded in to 
the process on my machine.
 
NVWRSENG.DLL at 221K - part of the NVIDEA driver

ophook32.dll at 176K - part of the OCR DLL that came with the scanner

ctagent.dll at 64K - part of the sound drivers for my Audigy card

nvwddi.dll at 53K - part of my video driver again

nView.dll at 1.1 MB - wow, that video driver sure plugs in a lot of stuff.

2.9 of SP2 message files. I have no idea what they do.

uxtheme.dll at 291K - part of the themes
 
Well, I will spare you the rest but there is over 2.3 MB of third part drivers 
and hooks and filters and more than 4 MB of system stuff in there. The only 
bits that are comparable to the old DOS days are the rich text editor DLL and 
Wordpad.EXE itself. Together they make up 800K, about the same as Wordstar 
2000. Ok, so it has a lot more OS support than we did in the old days but on 
the other hand, it is a 32 bit app compared to a 16 bit one.
 
So, for a similar feature set, things really are not so much larger. It is 
hooking in to a complex, rich, highly multithreaded, interoperational operating 
system with graphics and multiple desktops and 7.1 surround sound that makes 
things bloat.
 
Actually, this anaysis does show one thing very clearly. You know the way that 
a newly installed OS is nice and crisp to respond and over time it gets slower 
and slower? It looks like a great deal of that is third party drivers for 
everything and its brother hooking in to every application. I have never used 
the OCR software. I doubt that I ever will. I think that I might just uninstall 
it.
 
Just a thought.
 
Mark
 

________________________________

From: program-l-bounce@xxxxxxxxxxxxx on behalf of George Bell
Sent: Wed 23/03/2005 22:44
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: C# attributes



I could be a mile off base here, so it may result in another
burning thread.

I'm sure Mark will remember trying to squeeze code such that
it would run in 512k or if you were lucky 640k

Notice that it is the letter k as in kilo above.  And do
appreciate that we are talking here about MEMORY.

"Stone the crows", to quote an English colloquialism, but I
have a MEGABYTE of memory in my system here, and can still
run out of memory.  And oh yes, there's a whopping great
Swap file on my hard drive - as well!

Perhaps it's time to haul some of you guys over the coals
and find out just why you need to use so much memory these
days?

And don't give me some lame excuse about memory being cheap
and fast, or blame the inefficiency of the compilers.  I'm
old enough to be Mark's father, and probably grandfather to
many more of you.  It won't wash!

George.

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of Tim
Burgess
Sent: 23 March 2005 10:30
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: C# attributes

Hi,

I think "syntax sugar" is a bit of a harsh term.
Programming's a way of solving problems, so we should be
spending our time thinking about the problem to be solved
instead of fiddly syntax.  Granted, performance has a place
in this, but I was taught to get a more powerful processor
running solid code rather than to over-tweak the code to fit
a poor hardware platform - always a trade-off, but not such
bad advice as a guideline.

Just my tuppence worth...

Best wishes.

Tim
-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Mark Long
Sent: 21 March 2005 14:00
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: C# attributes

Essentially, properties are just procedure calls like any
other. They are an invitation to think of the thing that you
are getting back as a aspect of the object. So, syntax
sugar? Yes, to a degree. An awful lot of Oops features are.
In the old days, we did polymorphism with untyped pointers
and the first 2 bytes were a type field. We had arrays of
function pointers instead of methods. The actual machine
code is not so very different but the syntax sugar makes it
go down a lot better.

________________________________

From: program-l-bounce@xxxxxxxxxxxxx on behalf of Shaikh,
Saqib, VF UK - Technology
Sent: Mon 21/03/2005 13:57
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: C# attributes



Hi David

Thanks for your quick reply.  It's quite possible that I
have got the terminology wrong and I actually mean
properties instead of attributes,
e.g.:
label.text="text";
label.font=bla bla bla

It is quite possible that using the form designer would help
me but I don't have the money to ffork out on VS - about
£750 or more I believe.  I've just graduated from uni and
started my first job - it'll be many many many years before
I can afford that kind of software <grin>.  I bought VS6
many years ago but of course that is now showing its age.

Saqib


Saqib Shaikh
Business Analyst
Wholesale Delivery

Telephone: +44 (0)1635 682958
Mobile: +44 (0)7747 461634
Email: saqib.shaikh@xxxxxxxxxxxx

> Vodafone Limited
> Registered Office: Vodafone House, The Connection,
Newbury, Berkshire,
> RG14 2FN Registered in England No 2227940


-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]On Behalf Of David
Lant
Sent: 21 March 2005 13:43
To: 'program-l@xxxxxxxxxxxxx'
Subject: [program-l] Re: C# attributes


Hi Saqib,

Firstly I'll qualify anything I'm about to say with the
caveat that I am
neither a Java nor a C# programmer.  However, having got
into .NET a fair
bit, I think I may have some input.

Part of the problem may be nomenclature.  I understand
attributes to be
something very different than parameters to functions.
Attributes as I
understand them are qualities of the class itself that can
be specified at
design time, such as whether the class is serializable or
supports some
Enterprise Services feature or other.  E.g.

<Serializable()> Public Class MyWidget()

However, the sample code you supplied looks more like
constructors for a
class than anything.  If so, then you can indeed do that
with C#, as long as
the object you are instantiating has the overloaded
constructor defined to
allow you to specify those parameters.  Since both VB and C#
use the same
class libraries for controls, I can check to see if Labels
do indeed have
constructors as you indicate.  And on looking, I see that
the Label class
does not have any overloaded constructors to allow this.
So, on that basis,
you are right in that you need to individually specify the
properties of the
label.

However, You could always create your own Label class which
inherits from
the standard class, and set your own overloaded constructors
to make your
coding life easier.  It would only be a one-off effort.

Lastly, I would ask why you don't use the form designer to
lay out the
controls?  That way, Visual Studio would generate the
necessary lines, and
as they are placed within the form generated code section,
you can collapse
that region of code so you don't need to browse through it
all the time.
This may simply be a matter of preference, and I can respect
that.

Just some of my uninformed musings...  Do with them as you
will. <smile>

David Lant

I.T. Consultant
Consultancy & Development
ICT Services
Tel: (01392) 382464

Devon County Council accepts no legal responsibility for the
contents of
this message. The views expressed do not reflect those of
Devon County
Council.


-----Original Message-----
From: Shaikh, Saqib, VF UK - Technology
[mailto:Saqib.Shaikh@xxxxxxxxxxxxxxxxx]
Sent: 21 March 2005 13:21
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] C# attributes


Hi

I've been programming in C/C++ for about ten years and Java
(my current
prefered language) for about 5).  I recently started
developing in C# and
the problem is that it is too similar to Java.  This lulls
me into a false
sense of security; but every so often I find something
different.  Syntactic
differences are ok, but what is ahrder is the philosophical
differences.

A case in point: what I believe are called attributes.  If
I'm right, it
feels like C# gives one the ability to say
classname.attributename instead
of classname.getAttributename() or set as well.

This is kind of nice, but at the end of the day if I am
right it is nothing
more than syntactic sugar.  What do other people think?  I'd
much rather say
something like:
Label l=new Label("some text", Orientation.CENTER, new
Font("arial",
Font.BOLD|Font.ITALIC)); Component.add(l, x, y);

In C# the way I see it written this would take up at minimum
six lines; I'd
also have to specify the size of the label (I hate doing
this), and also the
tabstop order, etc, giving about nine or ten lines of code
in totoal.  As a
blind person who cursors down through code this is highly
annoying.

Can anyone enlighten me as to why this is a good idea?  Are
parameters to
functions old-fashioned? <grin>

Saqib

Saqib Shaikh
Business Analyst
Wholesale Delivery

Telephone: +44 (0)1635 682958
Mobile: +44 (0)7747 461634
Email: saqib.shaikh@xxxxxxxxxxxx

> Vodafone Limited
> Registered Office: Vodafone House, The Connection,
Newbury, Berkshire,
RG14 2FN
> Registered in England No 2227940
>
** To leave the list, click on the immediately-following
link:-
**
[mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on
the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following
link:-
**
[mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on
the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following
link:-
**
[mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on
the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq



** To leave the list, click on the immediately-following
link:-
**
[mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on
the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq



This Message has been scanned for viruses by McAfee Groupshield.
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq


Other related posts: