This project is read-only.

Blog writer's opinion on TypeScript

Topics: General
Oct 21, 2012 at 2:26 AM

I happen to read upon this article which is the writer's opinion about why we don't need TypeScript.  After reading it, I didn't like what he's saying but he does have a point "no need for more complex javascript".


What is your thought on the writer's Honest Opinion.  Please no flaming war here, let's be civil because I'm so exciting to want to use TypeScript but it's not quite ready for prime time just yet.


Oct 21, 2012 at 6:02 PM

I love JavaScript... I came to JavaScript from C# so like many at first I thought the langauge was nuts.  But then once I got the hang of thinking about things the JavaScript way I fell in love.  I realized that in C# I spent way too much time defining types and I felt that I could be 2 - 3 times as productive in JavaScript because I spent less time defining types.  But then I started working on a large JavaScript project with 7 other developers and that's when the problems with JavaScript really started to show.

Fundamentally, the problem with JavaScript isn't the language it's the fact there's no compile step.  We tend to think of compiling as the process of coverting what you typed into some lower level representation (which JavaScript doesn't need) but it also serves another purpose which is to validate that what you typed looks basically correct (something JavaScript needs badly.)  TypeScript adds a bunch of new constructs like classes, interfaces, and modules, all of which are great (and completely optional) but the most important thing it adds is a compile step where it does a static analysis of your code to make sure everything looks basically correct.

If you're an individual developer working on a small to medium sized JavaScript project you have less of a need for TypeScript (although I'd argue there's plenty of benefit to be had for individual developers.)  If you're on a team, however, and working on a medium to large sized JavaScript project there's tons of benefit to using TypeScript, even if the only thing you use are the type annotations. 

To give you an example... Lets say you and I are part of a team of 10 developers and we're working on a decent sized project with some 30,000 - 50,000 lines of JavaScript (yes there are plenty of projects with that much code.)  A developer on our team, Joe, needs me to change the way a set of functions I wrote work.  These changes require me to have to change the parameters passed to that function.  I make the changes and Joe's happy.  The problem is you use the functions too and my changes now have likely broken everyplace where you use the function.  In the JavaScript world I would need to do a global search to see if I can find everyplace you're using the functions so I can fix your code for you.  With TypeScript all I need to do is compile and it's going to give me a build break for anywhere I need to change.  With TypeScript I simply need to keep fixing breaks until the project compiles and I can then be pretty certain that I've update all places that reference the code I changed.  The more complex the change the more TypeScripts compile step is going to help you.

That was a refactoring example but even when you're writing new code there's a benefit with using TypeScript... typeo's... ever misspelled a function name?  with TYpeScript that's not going to happen because the compilers going to catch your typo.      

Oct 21, 2012 at 6:03 PM
Edited Oct 21, 2012 at 6:05 PM

(they should have a delete... my reply was submitted twice)

Oct 21, 2012 at 7:29 PM
Edited Oct 21, 2012 at 7:30 PM

People tend to forget that "Statically typing" has just as much value when you are talking "communicating design,contract and intend"...
And on projects with more than, hell 1 developer... that just becomes an extremely convenient tool to leverage that.

And boy oh... The fact that I don't have to sit and look up one JavaScript method after another in some documentation somewhere is just lovely... And you could argue that that is a tooling issue, but how will you create that tool when all the type information is gone... If that was so easy, why doesn't we have it today?...

And it's not that you couldn't do allot annotations etc. in pure JS it self to leverage that, and I doubt that they haven't got things on the Facebook teams as well that helps them to leverage these things directly in the source... and if not... then the bugs I often encounter in the "not so used" parts of facebug (hah!... lol... I actually typed that by accident somehow, but ill leave it as is :P )... suddenly doesn't surprise my that much anymore...

(I name Facebook as he seems to be working on their engineering team)


Is an awesome watch, and might lighten up the subject a bit... I have so deep and true respect for those two... 

Oct 22, 2012 at 9:33 PM
Edited Oct 22, 2012 at 9:33 PM

I don't understand all the fuzz about it... 
does anyone HAS to use TypeScript: no

if someone wants to continue writing javascript without any type checking, without refactoring, without decent code completion... well that is their choice.

I love any attempt to make the life of a developer better, I love to have the choice... I tried ScriptSharp, I tried Saltarelle and now I'm checking out TypeScript, and so far, I like TypeScript the most... It's still very close to javascript, so everything applying to javascript applies to TypeScript.

If one doesn't like it, then don't use it... it's that simple.