BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

my reflections after two weeks with .net
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical)
View previous topic :: View next topic  
Author Message
Mike Margerum
Guest





PostPosted: Fri Oct 20, 2006 3:03 am    Post subject: my reflections after two weeks with .net Reply with quote



Here's a perspecitve from an old C++ salt. I have a bcb6 application
that I built a few years back. I started to port it to C#/.Net 2.0 as
an excersize but after a few weeks into it, i'm definately moving the
app to .net.

I had very little c# experience when I started the app and in a few
weeks, i have written what took me probrably two months in BCB.

Here are a few of the reasons why:

1. IDE

The visual studio 2005 IDE's code completion is incredible. it's
instantaneous on my 1.8 ghz 1 gig ram laptop. it also completes a lot
of construct like new. it figures out the type and finishes the new
statement. there are lots of other places it does this too

The debugger is light years ahead of the BCB6.

The highlighting of loc that dont compile

I love the way the ide pulls the comments in from the .net source code
when you hover over a function or code completion activates.

It has not crashed in the year ive been using it.

2. Serialization

in my project, im throwing a lot of objects around via serialization and
sockets. in BCB 6 I had to write all of my serialization routines which
could easily break if i forgot to code for new attributes. I also had
to version my serialized objects. in .net i used an attribute which is 1
line of code [Serializable] and in .net 2.0 they added attributes to
handle versioning serialized objects. This saved my at least 100's of
lines of code.

3. binding controls

every gui control can be bound to just about anything. in BCB6, i had
to copy my objects to a TDataset derivative (kbmMemTable) to bind my
objects to db controls even though my objects lived in STL containers.
In .net, I can keep my objects in typeseafe containers and bind them
to form controls. They don't have a seperate set of db controls like
the VCL does. That never made sense to me... And it was so easy to do.
i remember trying to implement my own TDataset derivatives... ugggg

4. No header files

I dont have to do the header include dance. Everything in my namespace
is implicitly available to me with no imports. If i never have to
write another #ifndef/#define pair for a header include, i can die a
happy man.

partial classes
Also code like form initialization can be in a sepearate file. That way
i can edit it if i want to but its not in my way when I dont need it
(which is 99% of the time)


5. rich library

virtually everything you need is available in the net framework and
works well. I had to use 3rd party components for things like FTP, ssl,
grids, masked controls, etc. All of them had quirks and never worked
quite right. Worse yet, the vendors are dropping like flies and im
stuck with some controls that I cant use in BDS 2006 because I only have
dcus

6. garbage collection

I could simulate it with smart/scoped/ref counted C++ pointers but it's
just not the same. Garbage collection frees me from having to think
about managing the lifetime of my objects. This control is also the
scariest part to give up for me.... They added a using statement to
immediately dispose of an object as soon as it left scope.

7. WinForms is richer than the VCL

The built in controls are much richer than their VCL equivalents. I had
to buy a 3rd partry control library for BCB6 to do the things I can do
in C# for free. I understand borland doesnt want to piss off their 3rd
party folks but cripes what have you added to your grid/listview in the
last 10 years?


I'll continue to do C++ for quite a while as I do embedded and phone
development. It will continue to dominate there because of the hardware
limitations but I see no good reason to use it at this point for a new
desktop/server project.
Back to top
Peter Agricola
Guest





PostPosted: Fri Oct 20, 2006 8:10 am    Post subject: Re: my reflections after two weeks with .net Reply with quote



Why did you choose C#? I guess all the goodies you describe are available in
C++/CLI too.


Peter
Back to top
Martin Hart Turner
Guest





PostPosted: Fri Oct 20, 2006 8:10 am    Post subject: Re: my reflections after two weeks with .net Reply with quote



Mike:

Quote:
The visual studio 2005 IDE's code completion is incredible. it's
instantaneous on my 1.8 ghz 1 gig ram laptop. it also completes a lot
of construct like new. it figures out the type and finishes the new
statement. there are lots of other places it does this too

Have you tried CodeRush from DevExpress? It makes the developer
experience even more enjoyable. When combined with Refactor! (also from
DevExpress) life is a panacea!!

Regards,
Martin.
Back to top
Martin Hart Turner
Guest





PostPosted: Fri Oct 20, 2006 8:10 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

Peter:

Quote:
Why did you choose C#? I guess all the goodies you describe are available in
C++/CLI too.


Sorry for butting in, but I also made the move and evaluated C++/CLI
first, but under VS2003 it was pretty limited as far as visual designers
were concerned. I believe this has changed under VS2005 and .NET2.

After playing with C# for a few weeks I saw just how easy it was to use
and had many new constructs built into the language itself, so I decided
to stay with it rather than C++/CLI.

Finally, C# is Microsoft's 'favorite son' currently, and practically all
samples, demo projects etc. are in C#, not C++/CLI.

HTH,
Martin.
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Oct 21, 2006 12:44 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

At 19:42:49, 20.10.2006, mr_organic wrote:

Quote:
You're using "global" to stand for any application-persistent value or
reference, which is IMO wrong -- you're using it more in the
"Singleton" sense, which that you have one and only value or object
reference within a given app at a given time.

Good, then explain what a global is, and in what way it is different from
a static class member.

Quote:
A Singleton is not a global

I never said so. I said that you can use globals to reference singletons,
which will take care that the lifetime of the singleton is, unless you
change this in code, will be from creation to the end of the program.


--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"If you gaze long into an abyss, the abyss will gaze back into
you." -- Friedrich Nietzsche (1844-1900)
Back to top
Guest






PostPosted: Sat Oct 21, 2006 12:53 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

I would think Weak References could help in this case
Back to top
mr_organic
Guest





PostPosted: Sat Oct 21, 2006 12:55 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espf9e8hbazk01d-velthuis (AT) www (DOT) teamb.com:

Quote:
At 19:42:49, 20.10.2006, mr_organic wrote:

You're using "global" to stand for any application-persistent value or
reference, which is IMO wrong -- you're using it more in the
"Singleton" sense, which that you have one and only value or object
reference within a given app at a given time.

Good, then explain what a global is, and in what way it is different
from
a static class member.


A global variable exists in the global namespace, is immutable (in theory
if not in practice), and is dereferencable by any thread running in the
application space. (It also exists in the global symbol table in a way a
Singleton instance does not.)

A static class member is just that: a member of a class. It does not
exist in the global namespace, therefore *by definition* is not global. I
can define a static class variable as protected or private, after all --
declaring it as public doesn't make it global, because it must still be
qualified by the class name. (In fact, in C# you are prohibited from
declaring any kind of variable outside the scope of a class. I think Java
has the same restriction.)

A Singleton is a semantic construct that avoids polluting the global
namespace but still gives you the semantic and structural benefits of a
one-and-one-only construct. But a Singleton value is not global *by
definition* because it does not exist in the global namespace. A
Singleton can also place a layer of "intelligence" when referenced (for
locking, synchronization, etc.), whereas a global variable may only be
referenced (or de-refrerenced), thus putting all the checking overhead on
the caller.

Is this nit-picking? Probably. But I'm arguing that you're using
"global" in a pretty loosey-goosey way that can lead to bad design
decisions -- Singletons and globals *are not* the same thing, even if
they do serve some of the same purposes.

mr_organic
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Oct 21, 2006 1:26 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

At 21:55:04, 20.10.2006, mr_organic wrote:

Quote:
"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espf9e8hbazk01d-velthuis (AT) www (DOT) teamb.com:

At 19:42:49, 20.10.2006, mr_organic wrote:

You're using "global" to stand for any application-persistent value
or >> reference, which is IMO wrong -- you're using it more in the
"Singleton" sense, which that you have one and only value or object
reference within a given app at a given time.

Good, then explain what a global is, and in what way it is different
from
a static class member.


A global variable exists in the global namespace, is immutable (in
theory if not in practice), and is dereferencable by any thread running
in the application space. (It also exists in the global symbol table in
a way a Singleton instance does not.)

Ok, then what is the functional difference between a globla variable and
a static class member, except that the latter is not in the global
namespace? Static (public) class members are also accessible by any class
in the application space.

Like I said, you could use a global (or, alternatively, a static class
member, since C# does not have globals) to hold a reference to a
singleton, so you have complete control over its lifetime.

And if global variables were immutable, they would not be seen as
problematic by so many people.
--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"I'm not into working out. My philosophy: No pain, no pain."
-- Carol Leifer.
Back to top
mr_organic
Guest





PostPosted: Sat Oct 21, 2006 1:28 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espgee8itgup01i-velthuis (AT) www (DOT) teamb.com:

Quote:

Ok, then what is the functional difference between a globla variable and
a static class member, except that the latter is not in the global
namespace? Static (public) class members are also accessible by any class
in the application space.


Rudy, I've simplified it as much as I can. If you're still not getting it,
go buy the Gamma book on patterns and read it for yourself. Singletons are
not globals and globals are not Singletons, and saying that they are is
simply wrong.

But if you want to *think* they are...well, good luck with that.

mr_organic
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Oct 21, 2006 1:30 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

At 21:55:04, 20.10.2006, mr_organic wrote:

Quote:
But a Singleton value is not global *by
definition* because it does not exist in the global namespace.

You repeat what you said before, and to which I replied. But you
apparently ignored my reply:

<<
Quote:
A Singleton is not a global

I never said so. I said that you can use globals to reference singletons,
which will take care that the lifetime of the singleton is, unless you
change this in code, will be from creation to the end of the program.
Quote:


IOW, I said "use globals to reference singletons", and not "globals are
singletons".
--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"Glory is fleeting, but obscurity is forever."
-- Napoleon Bonaparte (1769-1821)
Back to top
mr_organic
Guest





PostPosted: Sat Oct 21, 2006 1:37 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espgij8izi7e01j-velthuis (AT) www (DOT) teamb.com:

Quote:

I never said so. I said that you can use globals to reference
singletons,


But why? You don't *need* a global to do this. Simply declare a static
instance() method on the Singleton class and get your reference from that
method. The method's implementation takes care of the housekeeping
(locking, reference-counting, whatever), and thus frees the caller from
having to figure this junk out. Which is why you *don't* want to use a
global variable to reference your singleton!

Repeat, Rudy: globals are bad. For every instance you can bring up where
they're useful, I can bring up about ten thousand where they're not.

This is the canonical way of using a Singleton, and nearly every
implementation I've seen for both C++ and C# uses the Singleton in this
way.

mr_organic
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Oct 21, 2006 1:52 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

At 22:28:59, 20.10.2006, mr_organic wrote:

Quote:
"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espgee8itgup01i-velthuis (AT) www (DOT) teamb.com:


Ok, then what is the functional difference between a globla variable
and a static class member, except that the latter is not in the global
namespace? Static (public) class members are also accessible by any
class in the application space.


Rudy, I've simplified it as much as I can. If you're still not getting
it,

I am. You seem to think I am confusing Singletons and global variables. I
am not. I am merely saying that one can, to keep singletons alive during
the lifetime of a program, assign a reference to them to a global
variable, or, alternatively, in languages which don't have them, to a
static member of a class.

Quote:
go buy the Gamma book on patterns and read it for yourself.
Singletons are not globals and globals are not Singletons

I NEVER SAID SO! YOU are apparently not getting it. I know damned well
what a singleton is.

I was comparing STATIC CLASS MEMBERS with GLOBAL VARIABLES as ways to
hold at least one REFERENCE to a singleton alive as long as one likes,
i.e. to prevent the GC from collecting the singleton before it was used.
That was actually what started this entire subthread about global
variables.
--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"There is no reason anyone would want a computer in their home."
-- Ken Olson, president, chairman and founder of Digital
Equipment Corp., 1977
Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Oct 21, 2006 2:06 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

At 22:37:11, 20.10.2006, mr_organic wrote:

Quote:
"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0espgij8izi7e01j-velthuis (AT) www (DOT) teamb.com:


I never said so. I said that you can use globals to reference
singletons,

But why? You don't need a global to do this. Simply declare a static
instance() method on the Singleton class and get your reference from
that method.

Sure, and that returns a reference to an instance you create on the first
call. Being a singelton, you would want to return the same instance on
any later call. How do you make sure that instance is not collected
prematurely, i.e. when the last reference to it is lost, but the instance
may still be needed at a later time, or how do you even remember the
reference for later calls? I guess you'll use a (non-public, this time)
static member to hold a reference to it. And then we are back to where we
started.
--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"And God said, 'Let there be light' and there was light, but the
Electricity Board said He would have to wait until Thursday to be
connected." -- Spike Milligan.
Back to top
mr_organic
Guest





PostPosted: Sat Oct 21, 2006 2:18 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0esphhx8k9kwu01t-velthuis (AT) www (DOT) teamb.com:

Quote:

Sure, and that returns a reference to an instance you create on the
first
call. Being a singelton, you would want to return the same instance on
any later call. How do you make sure that instance is not collected
prematurely, i.e. when the last reference to it is lost, but the
instance
may still be needed at a later time, or how do you even remember the
reference for later calls? I guess you'll use a (non-public, this time)
static member to hold a reference to it. And then we are back to where
we
started.

Here's a vastly-oversimplified Singleton interface class:

class MySingleton
{
private:
static MySingleton *pInstance;
public:
static MySingleton * instance()
{
if (!pInstance)
pInstance = new MySingleton();
return pInstance;
}
};

Just making the private variable static does not make it a global, and
I'm not sure why you keep insisting that it is. The instance() call may
hide a quite complicated implementation -- reference counting,
instantiation, locking, what-have-you -- but the interface is very simple
(and NOT global).

mr_organic
Back to top
mr_organic
Guest





PostPosted: Sat Oct 21, 2006 2:20 am    Post subject: Re: my reflections after two weeks with .net Reply with quote

"mr_organic" <mr_organic (AT) yourmamashouse (DOT) com> wrote in
news:45393d21$1 (AT) newsgroups (DOT) borland.com:

Quote:
"Rudy Velthuis [TeamB]" <newsgroups (AT) rvelthuis (DOT) de> wrote in
news:xn0esphhx8k9kwu01t-velthuis (AT) www (DOT) teamb.com:


Sure, and that returns a reference to an instance you create on the
first
call. Being a singelton, you would want to return the same instance
on any later call. How do you make sure that instance is not
collected prematurely, i.e. when the last reference to it is lost,
but the
instance
may still be needed at a later time, or how do you even remember the
reference for later calls? I guess you'll use a (non-public, this
time) static member to hold a reference to it. And then we are back
to where
we
started.

Here's a vastly-oversimplified Singleton interface class:

class MySingleton
{
private:
static MySingleton *pInstance;
public:
static MySingleton * instance()
{
if (!pInstance)
pInstance = new MySingleton();
return pInstance;
}
};

Just making the private variable static does not make it a global, and
I'm not sure why you keep insisting that it is. The instance() call
may hide a quite complicated implementation -- reference counting,
instantiation, locking, what-have-you -- but the interface is very
simple (and NOT global).

mr_organic


Be aware, too, that the private declaration of MySingleton is not
strictly necessary. You can play some tricks with shared memory or
memroy-mapping to obviate the necessity for a private static variable.
I've seen this kind of Singleton implemented on multiprocessor or
heavily-threaded systems.

mr_organic
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical) All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.