----------------------------------------
> Date: Sun, 6 Jan 2008 14:57:27 -0800
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Introducing Cobra
> 
> I don't mean to be disparaging.  Declaration inference is immensely useful.
> Having to declare types of every variable and argument is a lot of what
> makes most static-type programming so tedious.
> 
>     LongArduousType foo = new LongArduousType(..);
> 
> I think distracts from readability.  It's much better to only declare the
> type there when it is going to be different.
> 

I could not possibly disagree more.  The most important part of an algorithm is 
what data it uses.  And the *MOST* important feature of a variable is its type. 
 It tells you what data the variable can hold.  That alone tells you more about 
the variable than any other clue.  If you've named your types well it should 
flow almost liek english.

Type variablename;

The type tells you what class of data you have.  The name tells you what 
instance of that data it will hold.  BAM! Everything you need to know about the 
data in one beautiful, elegant line.  Give me a series of lines like that, and 
I can deduce your algorithms without looking at them.  

This one feature of a language magnifies the readability of your programs  by a 
factor of 200-  at the minimum.  You don't need to read pages and pages of code 
to figure out what's being done and how the data is stored.  Its right there.  
You want to see the insides of that structure, to see how it manages its data?  
You know where to look.  A program is utterly unmaintainable without that.

Some people wax poetic about closures or recursion or functions as a first 
class objects.  They're all fools.  Variable declarations are the single 
biggest piece of genius in the history of programming.  And thats without even 
getting into how many freaking bugs it finds due to compile time checking of 
types.


Note:  to get this absolutely right, use of typedefs is a must.  Int should 
only be used for variables that actually count.  For anything else, make a 
typedef and name it what it actually holds, to get the full value of 
readability.  Then turn the warning the compiler spits out when you mix 
typedefs and ints into an error, because it almost always is.

Gabe
_________________________________________________________________
Put your friends on the big screen with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_012008
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to