On Mon, Oct 1, 2012 at 5:15 PM, Gustavo Machado <machad...@gmail.com> wrote:

>
> For less sophisticated developers (most people, and most of the VS
>> market), the compiler errors will remove much debugging frustration and
>> allow them to focus on creating rather than debugging.
>>
>>
> It also allows them to focus on "creating" instead of understanding what
> they are doing. Take the sample on the playground for instance:
>
>  constructor (message: string) {
> this.greeting = message;
> }
>
> will translate to:
>
>     function Greeter(message) {
>         this.greeting = message;
>     }
>
> If you can only handle string, should you not be doing a check and writing
> a proper message? What will happen to javascript users that consume your
> code generated with TypeScript? It's not a huge gain IMO, and a few CONS:
>
> - only get intellisense in VS (a gigantic IDE which will handle from
> databases, to manual tests).
> - TypeScript seems to be making the code longer to type and less readable
> instead of shorter/better (like others do).
> - yet another language/dependency on your project.
> - most of the type-related things could be handled gracefully with
> comments.
>

You can't get runtime optimizations with comments.


Take a look at this example:

function f( a ) {
  return "Hello Number " + a;
}

// Say you called it like this, of course it will work,
// but the runtime won't necessarily optimize
// because you've given it no information about what
// it CAN optimize. Besides, you really wanted a string.
f(1);


// So enforce it...
function f( a: string ) {
  return "Hello Number " + a;
}

// throws on compilation
f(1);

// Which would encourage you to go back to your code
// and make it a string:
f("1");

// Now it passes the compilation and this is what it outputs:
function f(a) {
  return "Hello Number " + a;
}
f("1");

The point is that it made you think about what you were passing to the
function.


The above example is fairly contrived and I'm sure that most runtimes will
figure that specific case out and optimize just the same, but allow it to
serve as a simplified example case.


Rick




>
> Gus
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to