> Yes, it will work, that's not the point.

Then give me an example that does make the point.  I'm a little
thick-headed.


On Mon, Oct 1, 2012 at 2:59 PM, Rick Waldron <[email protected]> wrote:

>
>
> On Mon, Oct 1, 2012 at 5:53 PM, Mark Hahn <[email protected]> wrote:
>
>> > The above example is fairly contrived
>>
>> And useless.  The JS would work fine passing it a number.
>>
>
> Did you actually read the entire example? I said that for you, but thanks
> for the additional coverage.
>
> Yes, it will work, that's not the point. The point is that the runtime can
> optimize the execution if it can find ways to make assumptions about the
> code it's executing. One the most common is based on types.
>
>
> Rick
>
>
>
>>
>> On Mon, Oct 1, 2012 at 2:36 PM, Rick Waldron <[email protected]>wrote:
>>
>>>
>>>
>>> On Mon, Oct 1, 2012 at 5:15 PM, Gustavo Machado <[email protected]>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 [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> 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 [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to