AtScript
We are NOT building a language
We you
and we would not force a language upon you
and we are sorry about our APIs
❤
module.directive('blink',
['$timeout', function($timeout) {
return {
require: 'options',
restrict: 'A',
link: function(_,element,__,options){
var selectors = someThirdPartyAPI();
element.query(selectors.join(','))
.forEach(e => options.apply(e));
}
};
}]);
module.directive('blink',
['$timeout', function($timeout) {
return {
require: 'options',
restrict: 'A',
link: function(_,element,__,options){
var selectors = someThirdPartyAPI();
element.query(selectors.join(','))
.forEach(e => options.apply(e));
}
};
}]);
module.directive('blink',
['$timeout', function($timeout) {
return {
require: 'options',
restrict: 'A',
link: function(_,element,__,options){
var selectors = someThirdPartyAPI();
element.query(selectors.join(','))
.forEach(e => options.apply(e));
}
};
}]);
Array<CssSelectors>
Element
@Directive({
selector: ['[blink]']
})
class Blink {
constructor(element:Element,
options:Options,
timeout:Timeout) {
var selectors:Array<CssSelectors> =� someThirdPartyAPI();
element.query(selectors.join(','))
.forEach(e => options.apply(e));
}
}
We are sorry
We will make it right
Why NOT build a language?
Ideal Development Environment
Introspection
Metadata
Optional�Types
AtScript
Contracts
// Public API
function addClass(selectors, name) {
document
.querySelectorAll(selectors.join(','))
.forEach(e => e.classList.add(name));
}
// Public API
function addClass(selectors, name) { ... }
// Public API
function addClass(
selectors:Array<CssSelectors>,
name:string) { ... }
// Public API
function addClass(
selectors,
name)
{
// Generated Code
assert(selectors).is(Array.of(CssSelector));
assert(name).is(string);
...
}
RTTS - Asserts
Check the server
JSON response
for correct type
Declarative Metadata
module.directive('blink',
['$timeout', function($timeout) {
return {
require: 'options',
restrict: 'A',
link: function(_,element,__,options){
var selectors = someThirdPartyAPI();
element.query(selectors.join(','))
.forEach(e => options.apply(e));
}
};
}]);
@Directive({
selector: ['[blink]']
})
class Blink {
constructor(element:Element,
options:Options,
timeout:Timeout) {
...
}
}
class Directive {
selector:string;
constructor({selector:string}) {
this.selector = selector;
}
}
@Directive({
selector: ['[blink]']
})
class Blink {...}
Introspection
var type = Door;
var material =
type.annotations[0];
expect(material.type)
.toEqual('wood'])
var parameters =
type.parameters;
expect(parameters)
.toEqual([Lock]);
class Material {
type:string;
constructor(type) {
this.type = type;
}
}
class Lock {...}
@Material('wood')
class Door {
constructor(lock:Lock){
...
}
}
Expressive Code Needs
Types & Annotations
Introspections
Abstraction
Why is abstraction important
Language�
Abstractions�
These are not new ideas
ES3 '99
- try/catch
- RegExp
ES4 '07
- Types
- Classes
- Modules
- (other)
ES5 '09
- strict mode
ES6 '15
- Classes
- Modules�- (other)
ES? '??
- Types
- Annotation�- Introspection
AtScript
- Annotations
- Introspection
TypeScript
- Types
ES6
- classes
- modules
ES5
Evolution of Syntax
ES5
function Blink(element,
options,
timeout) {
}
Blink.annotations = [
new Directive({selector: '[blink]'})];
Blink.parameters = [
Element, Options, Timeout];
ES6
class Blink {
constructor(element,
options,
timeout) {
}
}
Blink.annotations = [
new Directive({selector: '[blink]'})];
Blink.parameters = [
Element, Options, Timeout];
TypeScript
class Blink {
public static annotations = [
new Directive({selector: '[blink]'})];
public static parameters = [
Element, Options, Timeout];
constructor(element:Element,
options:Options,
timeout:Timeout) { }
}
AtScript
@Directive({
selector: '[blink]'
})
class Blink {
constructor(element:Element,
options:Options,
timeout:Timeout) {
}
}
CoffeeScript
class Blink {
@annotations = [
new Directive({selector: '[blink]'})];
@parameters = [
Element, Options, Timeout];
constructor: (element, options, timeout){
}
}
Roadmap
AtScript
traceur
*.ats
*.es5
*.dart
AtScript to �*.js & *.dart
Runtime Type Checking
Static Type Checking
Align with TypeScript
IDE
support
Browser Support
EcmaScript Proposal
EcmaScript Standard
AtScript != new language
AtScript = ES6
+ Types
+ Annotations
+ Introspections