Amazon.com Widgets My Take on TypeScript

My Take on TypeScript

By Nick at October 17, 2012 21:43
Filed Under: Delphi, Tech Stuff, Software Development

Microsoft has been keeping the renowned Anders Hjelsberg busy on a new language called TypeScript.  Typescript is an open-source project (using the Apache 2.0 license) that allows you to write a super-set of Javascript that allows for a stronger typing system.  You can watch Anders’ original launch presentation

I’ve said a million times that I’ve said a million times that Javascript is the new Assembler – that Javascript will become the thing that everyone compiles higher level code into.  You’ll write your web apps in a higher order language, and then compile them to Javascript for execution in the browser. 

I refuse to believe that any rational person actually likes to write Javascript, and as it is designed currently, it really isn’t a language for developing the kind of large-scale applications that people seem to be wanting to use it for.  In the deep, dark past, Assembler used to be all there was, and we created higher order solutions that compiled to assembler.  And in the same way, for a while, Javascript was all there is for the browser.  Now, however, we are beginning to see higher order languages being brought to bear to produce Javascript for us. 

If Javascript is the “new Assembler”, then the Browser becomes the “new operating system”.  The cool thing about that is that the “new OS” is ubiquitous.  Just about every computer in the world – computers running Windows, OS X, Linux, Unix, whatever – has a browser that runs Javascript.  That means your application can run on any computer.  That’s a very compelling idea.

You can actually do that today with Delphi using a very cool tool called Smart Mobile Studio.  There is also the Elevate Web Builder tool from Elevate Software.  Both have the same idea – leverage the power of Delphi to produce Javascript-based applications.  Pretty cool, really.

Anders talked to Scott Hanselman about Microsoft’s offering in the “Language to compile down to Javascript” arena in the latest episode of Hanselminutes.  Anders is always a good interview – I love a guy who thinks and speaks as clearly as he does.  (That’s why I always loved a Danny Thorpe presentation.  Danny is pretty quiet and mellow, but his talks were always so clear and well organized – every single word he said was worth listening to – that they were always excellent and enormously educational.  Anders is the same way….) He does a great job discussing the notion behind TypeScript.

Here are some of my thoughts on what Anders said and on TypeScript in general.

  • TypeScript seems to exist for two reasons – to make Javascript “tool-able” and scalable. 
    • First, the type annotations, classes, modules, and other enhancements exist to allow Visual Studio and other IDEs to do things like Code Completion (the RAD Studio term that Anders used in the podcast instead of Intellisense – I loved that.  Smile  ), refactoring, and other language-based features that modern IDE’s do.  Javascript doesn’t provide enough information to let development tools do all the things that we expect, but TypeScript does. 
    • Second, TypeScript is also a way to make Javascript scale. By providing the notion of typed classes and modules, you can create larger, well-organized TypeScript applications which then compile to Javascript.   TypeScript is a language ready to do the heavy lifting that Javascript cannot.
  • Since TypeScript is a super-set of Javascript, it follows that pure Javascript is valid TypeScript.  Anders points out that you can use your existing Javascript as is inside of TypeScript.  The idea, though, is that TypeScript becomes the language you’d use instead of Javascript because of all the tooling support, and because it can be used to build applications via modules (units, for you Delphi folks).    Typescript doesn’t have any runtime or virtual machine – it literally just compiles to Javascript. 
  • You can create an external declaration file to define the types in your *.js file, so that means that existing Javascript libraries like Node.js and jQuery.js can be “typed” and thus used in the TypeScript environment.  I think that is a pretty cool idea – and I’m sure that Microsoft will be delighted if the community follows their lead and “converts” the existing popular libraries.
  • Anders also points out that TypeScript puts a “dial” on the typing level of your code.  Pure Dynamic advocates can leave everything untyped, and the strong-typing zealots can type everything if they want, and the folks who want to type some things and not type others can do that if they want.  That’s a very interesting notion – a language with a variable level of type-safety.

Now one thing to note is that tools like Smart Mobile Studio and Elevate Web Builder offer pretty much all these features as well.  There isn’t any reason that Embarcadero couldn’t make Javascript be something that is output by the Delphi compiler.  Heck, there is even a project out there to get LLVM to produce Javascript.  TypeScript would integrate well into HTML5 Builder. Whatever higher-end language you want to use, it seems pretty clear to me that Javascript will be the thing our compilers will be producing in the not-to-distant future.

Are you going to give TypeScript a look, or are you more interested in the Delphi-to-Javascript solutions?  I’ll probably check out both.  Either way I have to use a different IDE, so I’m guessing I’ll lean towards the Delphi-based solutions.  Plus, I frickin’ hate curly braces.  Winking smile

What do you guys think?

Comments (12) -

10/17/2012 10:33:13 PM #

Alister Christie

Anders H is a pretty brilliant guy and amazing communicator - it will be very interesting to see where TypeScript goes, even though, to me, the name suggests a Latex replacement or something.

Alister Christie New Zealand |

10/18/2012 1:17:20 AM #

Larry Hengen

When you get into Typescript please blog about your experience and thoughts.  There never seems to be enough time in the day to learn everything I'm interested in, so until TypeScript/Javascript becomes an economic requirement, I'm going to stick with learning ObjC/XCode.

Larry Hengen Canada |

10/18/2012 1:31:18 AM #

deksden

Did you notice some progress for RemObjects new Oxygene derivation - Nougat? Its Oxygene for Objective-C based environments (iOS/OSX)! Pretty cool, IMHO.

deksden Russia |

10/18/2012 1:32:13 AM #

deksden

I can mention that we have not only LLVM - JS bridge, you can look at JSIL.org project. It's goal is compile any IL-based assembly into JavaScript. I did not test it yet)

deksden Russia |

10/18/2012 4:50:07 AM #

Steven Camilleri

There's been a lot of irrational arm waving and teeth gnashing about it. I haven't seen any rational arguments against typescript. From early on, I was always taught to write code defensively. Some languages make this easier to do than others. Javascript is a bit of a free for all really. Typescript allows you to put a little bit of structure into your code, and to weed out those hard to find bugs at compile time. Compile time is the 'cheapest' place to find bugs and fix them. Typescript doesn't guarantee good code. You can write spaghetti mess in any language. I'm also sure you can write good code in Javascript, but it takes discipline, and in a team, discipline sometimes needs a compiler to enforce it.

Steven Camilleri France |

10/18/2012 5:08:16 AM #

Craig

I work on a large web project with some great developers (including an ex-Borlander well known to you). And despite being a web developers the hate of Javascript is palpable. This is not unique, a lot of people just don't like the way Javascript works. Typescript will make it something a bit more palatable form many developers used to the Delphi/C#/Java way of doing things. Ruby and other dynamic language dev's of course hate it.

Craig Australia |

10/18/2012 6:14:17 AM #

Adam Johnston



On the Hanselminutes Podcast

What is TypeScript and why with Anders Hejlsberg

www.hanselminutes.com/.../what-is-typescript-and-why-with-anders-hejlsberg

Adam Johnston Australia |

10/18/2012 11:23:07 AM #

Eric

LLVM to JS however starts from a low-level translation of high-level code, so a lot of the abstraction is lost, with very little of the LLVM optimizations having a positive effect.

The end result is thus quite bulky and inefficient compared to what could have been achieved when starting from any of the high-level "to JS" compilers (be it TypeScript, Dart, GWT, SmartMobileStudio, etc.).

Eric France |

10/19/2012 4:30:13 PM #

Nick Hodges

Eric -- good info, thanks.

I wonder if there is a "real" LLVM project to produce Javascript in the works/planned for/conceived....

Nick

Nick Hodges United States |

10/18/2012 11:45:36 AM #

skamradt

I did find it interesting that Anders uses Chrome to show of debugging techniques, not IE.  Open sourcing the project should also help it gain traction.




skamradt United States |

10/23/2012 3:13:53 AM #

andrew barton

I use NoScript.

When JavaScript was announced I said Crazy! No tech person will allow unknown code to run on their PC!

andrew barton United States |

10/24/2012 10:15:22 AM #

Hossein

There is so many great projects on Github, but I don't why this project is in other place.
What happen when some one in jQuery or Node team decide (two framework mentioned in this article) to change some thing in Type-script? They must login to codeplex and pushing the code.
I think, that codeplex make developing process of this language slower.

Hossein Iran |

Comments are closed

A Pithy Quote for You

"Sometimes you have to stop to sharpen the axe"    –  Peter Grumblatt

Amazon Gift Cards

General Disclaimer

The views I express here are entirely my own and not necessarily those of any other rational person or organization.  However, I strongly recommend that you agree with pretty much everything I say because, well, I'm right.  Most of the time. Except when I'm not, in which case, you shouldn't agree with me.

Month List