Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions TypeAnnotations.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
UPDATE
======

My hope when I started hacking UberScript was to eventually get the changes merged into CoffeeScript & slowly persuade CoffeeScript folks that a bit of type inferencing and the odd optional type annotation isn't that big a deal - and can be very useful; though its looking like thats never gonna happen.
My hope when I started hacking UberScript was to eventually get the changes merged into CoffeeScript & slowly persuade CoffeeScript folks that a bit of type inferencing and the odd optional type annotation isn't that big a deal - and can be very useful; though it's looking like that's never gonna happen.

Since I started UberScript; [TypeScript](http://www.typescriptlang.org/) has come along; with type inference, type checking, optional type annotations, generics, source maps and various other features of ES6 all in a nice compiler along with great tooling in Intellij / WebStorm.
Since I started UberScript, [TypeScript](http://www.typescriptlang.org/) has come along; with type inference, type checking, optional type annotations, generics, source maps and various other features of ES6 all in a nice compiler along with great tooling in IntelliJ / WebStorm.

While I refer the high level syntax of CoffeeScript (the use of whitespace indentation instead of "{" and the more ruby-ish general syntax and lack of semi-colons) the type inference and optional static types of TypeScript and Intellij tooling for me are a pretty awesome combination of writing scalable JavaScript; the use of "{" and ";" is a small price to pay for the lovely benefits of TypeScript!
While I prefer the high level syntax of CoffeeScript (the use of whitespace indentation instead of "{" and the more ruby-ish general syntax and lack of semicolons) the type inference and optional static types of TypeScript and IntelliJ tooling for me are a pretty awesome combination for writing scalable JavaScript. The use of "{" and ";" is a small price to pay for the lovely benefits of TypeScript!

So if you're writing JavaScript (and don't want a language leaky abstraction like GWT/Dart et al) and want some type inferencing/type checking/optional static types, I'd highly recommend you check out [TypeScript](http://www.typescriptlang.org/)!
So if you're writing JavaScript (and don't want a language leaky abstraction like GWT/Dart et al.) and want some type inferencing/type checking/optional static types, I highly recommend that you check out [TypeScript](http://www.typescriptlang.org/)!

If you want to see a TypeScript / AngularJS project I'm working on a lot these days, please do check out [hawtio](http://hawt.io/)

Background
==========

Increasingly as developers we're spending more of our development effort on the client side; whether iPhone/iPad/iPod, Android, mobile phones, tablets & set top boxes, web applications and native desktop applications. In many ways the client side UI is getting much bigger & more complex and the server side is often becoming more simple (e.g. server side might be SimpleDb/BigTable/CouchDb et al). So far the clear leader in a universal language & platform for rich UIs is HTML + CSS + JavaScript particularly with frameworks like [Appcelerator](http://www.appcelerator.com/) and [PhoneGap](http://www.phonegap.com/). (Ducks flamewars - if you only create iOS apps then maybe Objective-C is right for you; but wouldn't you rather a nicer, more reusable language? ;).
Increasingly as developers we're spending more of our development effort on the client side; whether iPhone/iPad/iPod, Android, mobile phones, tablets & set top boxes, web applications or native desktop applications. In many ways the client side UI is getting much bigger & more complex and the server side is often becoming simpler (e.g. server side might be SimpleDb/BigTable/CouchDb et al). So far the clear leader in a universal language & platform for rich UIs is HTML + CSS + JavaScript (especially with frameworks like [Appcelerator](http://www.appcelerator.com/) and [PhoneGap](http://www.phonegap.com/)). (Ducks flamewars - if you only create iOS apps then maybe Objective-C is right for you; but wouldn't you rather use a nicer, more reusable language? ;).

As many of us are aware JavaScript [has some issues](http://oreilly.com/catalog/9780596517748) such as == not working, lexical scoping being broken etc. However [CoffeeScript](http://jashkenas.github.com/coffee-script/) creates a simple & elegant ruby/python style language syntax that compiles quickly direct to native JS; such that you can read the JS and understand what its doing (handy for debugging until browsers support CoffeeScript debugging). So no weird Java wrappers to use some JavaScript library required or slow compilation steps like GWT etc. We're aiming at a very rapid RAD UI development platform which you want to save code your editor/IDE then your [browser automatically reloads ](http://blog.envylabs.com/2010/07/livereload-screencast/) in milliseconds.
As many of us are aware, JavaScript [has some issues](http://oreilly.com/catalog/9780596517748) such as == not working, lexical scoping being broken etc. However [CoffeeScript](http://jashkenas.github.com/coffee-script/) creates a simple & elegant ruby/python-style language syntax that compiles quickly and directly to native JS; such that you can read the JS and understand what it's doing (handy for debugging until browsers start supporting CoffeeScript debugging directly). So no weird Java wrappers to use some JavaScript library required or slow compilation steps like GWT etc. We're aiming at a very rapid RAD UI development platform which you want to save code your editor/IDE then your [browser automatically reloads ](http://blog.envylabs.com/2010/07/livereload-screencast/) in milliseconds.


UberScript
==========

This fork of the [CoffeeScript language](http://jashkenas.github.com/coffee-script/) adds optional type annotations. Ideally we'd like these fairly minor changes to get merged back into [CoffeeScript](http://jashkenas.github.com/coffee-script/), though if thats not an option we need another name for this fork. Current working name is UberScript (as it supports various points on the religious dynamic-static type checking debate ;).
This fork of the [CoffeeScript language](http://jashkenas.github.com/coffee-script/) adds optional type annotations. Ideally we'd like these fairly minor changes to get merged back into [CoffeeScript](http://jashkenas.github.com/coffee-script/), though if that's not an option we need another name for this fork. The current working name is 'UberScript' (as it supports various points on the religious dynamic-static type checking debate ;).

We've added optional type annotations to every point of the language AST; we've only added them so far to the grammar for assignments - but they should be most places in the language soon such as function arguments & object properties etc.
We've added optional type annotations to every point of the language AST; we've only added them so far to the grammar for assignments - but they should be in most places in the language soon (such as function arguments & object properties, etc).

UberScript is a superset of CoffeeScript; in UberScript you can now do stuff like this:

Expand Down Expand Up @@ -59,9 +59,9 @@ The type annotations are completely optional; they provide a consise syntax that
What if I don't want to use them?
---------------------------------

Thats totally fine! In many ways lots of JavaScript pages are quite simple; doing a bit of Ajax + DOM manipulation with jQuery and whatnot; the help type checking (dynamic or static) brings to small & simple scripts doesn't help hugely.
That's totally fine! In many ways lots of JavaScript pages are quite simple; doing a bit of Ajax + DOM manipulation with jQuery and whatnot; the help type checking (dynamic or static) brings to small & simple scripts doesn't help hugely.

However increasingly folks are writing bigger and bigger codebases in CoffeeScript; to run both on the client and server side; so type annotations can help you scale your code across different teams & help catch refactoring bugs earlier. Though YMMV so relax, don't worry - just enjoy CoffeeScript / UberScript and see if/when you wanna annotate some code with type annotations.
However, increasingly folks are writing bigger and bigger codebases in CoffeeScript; to run both on the client and server side; so type annotations can help you scale your code across different teams & help catch refactoring bugs earlier. Though YMMV so relax, don't worry - just enjoy CoffeeScript / UberScript and see if/when you wanna annotate some code with type annotations.

We hope to keep UberScript syntax 100% compatible with regular CoffeeScript (but just with the optional type annotations added) so you should be able to mix and match CoffeeScript, UberScript, JavaScript and even Java (via GWT) on a project.

Expand Down