strong typing versus weak typing,java weak,strong and weak typing,strong typing variables,weak type variables,javascript typing variables,strong and weak variables java,strong and weakly type,strong interpretations versus weak interpretations,strong typing the variables, xml%%%strong typing versus weak typing - Re: Strong versus (weak

[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Strong versus (weak|runtime) typing


strong typing versus weak typing
>Static Typing - Type of variables must be declared at compile time (e.g.
>C++)
>Dynamic Typing - Type of variables determined from usage at runtime
>(e.g. JavaScript) 
>Strong Typing - Variables cannot be coerced to unrelated types. (e.g.
>Java) 
>Weak Typing -  Variables can be coerced to unrelated types. (e.g. C) 

That matches my recent experience of the terms, though I think the
emphasis on variables in that is a bit misleading.  Several different
things can have types, notably objects (which exist at runtime)
variables and expressions (which exist at compile time).

Both Python and Java have typed objects - objects have some indication
of their type attached to them - unlike (say) C where objects are just
some bits interpreted according to the expression that refers to them.

Java has typed variables, Python doesn't.  Java is a little strange in
that although objects are typed, the interpretation of an object also
depends on the expresion used to refer to it: you may see different
slots ("instance variables" in Java-speak) depending on the compile-time
type of the expression.

C is not weakly-typed in normal use.  Most casts are genuine
conversions.  If x is an int, (double)x is no different from a
function call that converts an int to a double.  The compiler inserts
casts where needed in assignments and prototyped function calls.  The
only weak-typing constructs are pointer casts, function calls with the
wrong argument types in old-fashioned C without prototypes, and maybe
one or two others.

As I think Guido pointed out, static typing only catches a fraction of
even the simple non-algorithmic errors you can have.  It doesn't help
that you type-checked an integer assignment if the LHS is in inches
and the RHS is in centimetres.  It doesn't stop you getting arguments
in the wrong order unless they happen to be of different types.
And the incredible verbosity of common constructs like iteration in
Java is largely due to static typing, and is a source of errors just
by ensuring that your method doesn't fit on the screen.

-- Richard


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.