Linked by Thom Holwerda on Mon 1st Oct 2012 22:55 UTC
General Development "Everyone seems to have a replacement for JavaScript - Google even has two. Now Microsoft has revealed that Anders Hejlsberg has been working on a replacement and it has released a preview of TypeScript. TypeScript is open source - Apache 2.0 license - and a superset of JavaScript. As you would expect from a Hejlsberg language it incorporates type checking, interfaces and lots of syntactic sugar."
Permalink for comment 537344
To read all comments associated with this story, please click here.
Alfman
Member since:
2011-01-28

butters,

"In my view, a weakly-typed language must support implicit type coercion at least to some extent. C is a weakly-typed language which will, for example, happily add an integer to the ascii representation of a character. Python is an example of a strongly-typed language which will complain loudly if you attempt the same. But you'll never find type annotations in Python."


In my opinion, C doesn't have a "character type" (like a pascal CHAR). The 'char' is actually an integer type in C, which in most (all?) implementations happens to be an 8 bit byte. Because C doesn't have a string type either, we've become accustomed to representing strings as array of bytes (char). But that doesn't make the 'vector of chars' nominally equivalent to a 'string', they are different concepts.

If you follow my reasoning, then you wouldn't say C has a construct for "add an integer to the ascii representation of a character". If we renamed C's 'char' type to 'byte', you would have recognised the type for what it is (an integer instead of a character type, which C doesn't have).

Edit: If C did have a character type, I assume it wouldn't support direct arithmetic without a cast. Pascal doesn't support character arithmatic. .net doesn't. Javascript, which unifies characters and strings, doesn't. PHP does it's own thing by re-interpreting the character as a ascii digit.

Edited 2012-10-02 15:20 UTC

Reply Parent Score: 2