It appears you are the one who is not up on the debate. You
seem like an old-time C++ guy who can't comprehend why people
wouldn't want to throw anything and everything including the
kitchen sink into a language and damn the people who think
it's messy, inconsistent and not standardized.
hmm.. have to step in here, even though you were attacking someone else..
a) const is hardly messy inconsistent or not standardized! It is a very
defensive tool. Many people now are realising that as coding gets out of
the cowboy corral that TESTING is more and more important - especially
regression tests.
Now, suppose you have the lines:
Point x = new Point( 5, 3 );
Point transformed = F(x);
Test.Assert( x.Equals( new Point(5,3)), "check that X hasn't been
changed");
In non-const world - that assert will not guarantee to pass. In a const
world... it will.
I put it to you:
without const (or some workaround, like const interfaces)
it is impossible to test anything more than a trivial example
with any degree of confidence, in any practical situation.
While you are correct that there are some OO people argue who against const,
OO is a good paradigm, but not the be-all and end-all of development. It is
very good for modelling a business problem. However, other paradigms, such
as functional programming, are vastly superior in almost every other way.
I believe a synergy of many programming techniques is the optimal solution,
as in MS's intentional programming model. In fact, we are already going
this way - you use a UI to produce your forms, and a designer to produce
your data types (datasets) - as time goes on, more and more people will
use the appropriate tool to solve the appropriate problem. OO only solves
one very specific part of the whole programming problem. (look up aspect
orientated development/workflows/etc etc)
C# is a general purpose programming language, so it handles simplistic
paradigms like structured design or stack based programming very well. It
also has been built with lots of OO features, so can be used for OO design,
development as well. The single keyword, const would give you a lot of the
benefit of a functional programming language! (In fact, iterators and
Anonymous methods (can you say lambda?
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
) give you most of the rest of the
benefits.. (see
http://www.gotdotnet.com/team/csharp/learn/Future/default.aspx)
So - is const trivial? It almost singlehandedly brings a new tool to the
programmers arsenal, and if you look at the debates between functional and
other languages, one which is probably more important than the entire OO
enablement of the language put together.
I would say that any programmer not using at least a workaround of const,
such as const interfaces or events on all modifiers could not consider
themselves anything more than a beginner/intermediate coder.
b) as for templates: what's more messy/inconsistent/standardized?
Hashtable bad = new HashTable();
bad.Add( 1, "red" );
string theObjectIAmHopingLikeHellWillActuallyBeAString = (String) bad[ 1 ];
--- or ---
Hashtable good = new HashTable<int, string>();
good .Add( 1, "red" );
string theValue = bad[2];
and type safety is just one of a million different reasons good programmers
who code using generics use far less code, take far less time, and produce a
much more stable result than their specific compatriots.