Microsoft MVP Logo

Hear that? I think someone just fired the first shot in a new battle about to ensue in the front-end space theatre...

Earlier today I noticed HackerNews posted a link to the AtScript Primer, a draft document authored by Misko Hevery & Rob Eisenberg. If you don't know who those people are, you should as they have a lot of influence in this space (and something like this would likely be dismissed if it was by another random person). Misko is the father of AngularJS and Rob is the father of Caliburn.Micro (an MVVM framework for XAML based languages) and DurandalJS, an alternative to AngularJS.

So what is AtScript? As stated on their draft document:

JavaScript ... has a large, thriving community. However, it is missing some features which would make it much more manageable for large-scale application development. The goal of AtScript is to enhance the language with these missing features without infringing upon its current capabilities.

Sound familiar? Yeah... I thought so too... this is taken from the first paragraph of the TypeScript 1.0 language spec (published April 2014):

JavaScript applications such as web e-mail, maps, document editing, and collaboration tools are becoming an increasingly important part of the everyday computing. We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically-loadable modules. TypeScript’s optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code re-factoring.

For those of you who aren't familiar with this space, let me boil it down for you: one challenge people have with JavaScript is that it can be hard to maintain large projects & ensure type safety (among many other things). Many of these challenges are adressed in EcmaScript 6 (ES6)... things like classes and modules. ES6 is in the later stages of being finalized, but even once we reach there, it will still take time for all the browser to support it. Today most of us are using ES5 in our browsers.

The idea behind TypeScript is that all JavaScript is actually TypeScript. What you can do though is add some extra annotations to your JavaScript to define some types. The TypeScript compiler & tools will make sure you are using the right types and help you find bugs before deploying your code or running it thorough your tests. You can go further and create classes, just like in managed languages, that have even more complex types.

What is AtScript?

Announced at ng-europe this week, the idea is to take what we have today with TypeScript, which adds types to JavaScript, and add annotations and introspection to our code. What are these? Read the AtScript Primer draft as it does a good job of explaining it. In a nutshell, type introspection gives the program the ability to examine the type of properties of an object at runtime. Annotations allow us to describe things... such as TypeScript's type & field annotations.

Misko & Rob said in the draft document that their plan is to use AtScript to build Angular & make it easy for developers to use AtScript to build Angular applications. AtScript will be independent of Angular and can be used in non-Angular projects.

Why Something New?

They actually addressed this... what's wrong with TypeScript? From their point of view, TypeScript's types are only analysed statically which makes it challenging to have optional types. While TypeScript does have type inference, they take the position that it has limits. Static typing also cannot be used to assert data returned form the server as JSON has valid structure.

In addition, AtScript will have two things that TypeScript does not currently have:

  • TypeScript lacks metadata
  • TypeScript does not provide a way to access annotations at runtime

So where are we?

Well it looks like a whole new chapter has opened up in the JavaScript typing debate ahead of ES6.

Will AtScript be a competing thing with TypeScript? It doesn't appear so... one picture shown implies that AtScript is a superset of TypeScript. TypeScript is a superset of ES5 today and Microsoft is working to make it a superset of ES6 (when it's finalized). Misko said as much in his presentation (see video below).

Today Misko said they currently have an AtScript compiler running on top of traceur (similar to TypeScript's compiler, it's a transpiler that can generate ES5 from ES6) that consumes a *.ats file and can generate a *.es5 and *.dart file.

This will be interesting to see evolve... need input!

See Misko Hevery talk about it in this video.

Comments powered by Disqus