22
JSJS A Strongly Typed Language for the Web Ayush Jain · Gaurang Sadekar · Bahul Jain · Prakhar Srivastav

JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

JSJSA Strongly Typed Language for the Web

Ayush Jain · Gaurang Sadekar · Bahul Jain · Prakhar Srivastav

Page 2: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Just another day in the Javascript world

Page 3: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Why JSJS?

Feature JSJS JS

Type Safety

Type Inference

Immutable values

Immutable Collections

Programming Style Functional Imperative

Works with Node

Works in the browser

How does JSJS compare to JS?

Page 4: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

A Sneak Peak - Syntax

Page 5: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

A Sneak Peak - Syntax

Page 6: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Functional Programming

Functions everywhere...

Page 7: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Closures Local value for a function - kept alive after function has returned

Page 8: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Error Handling

Error Reporting

Exceptions and Exception Handling

Page 9: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Immutability

● Immutability makes it easier to reason about code

● The val keyword defines a value. No variables in JSJS.

● Names cannot be redefined in the current scope

Page 10: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Immutable Collections - Lists & Maps

● Uses Facebook’s Immutable.js library to enforce immutability.

● All library functions written is JSJS.

Page 11: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Immutable Collections - Lists

List Collection Library

hd, tl, empty?, filter, map, fold_left, rev, iter, range, concat, insert,

remove, sort, nth, length

All functions return new

lists (do not modify the

list in place)

Page 12: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Immutable Collections - Map

Map Collection Library

get, set, has?, length, values, keys, count, merge, del

All functions return a

new map (do not modify

the map in place)

Page 13: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

JSJS Type SystemT(_) is a generic type that helps with typeInference or generic user annotations.

TAny is only used for type inference.

TNum, TBool, TUnit, TString are data types.

TFun is the function type comprising of args

(list of primitives) and a return type.

TList and TMap are composite List and Map types

Page 14: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Inference - Our ‘Inspiration’

Page 15: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Inference - JSJS vs OCaml

JSJS

OCaml

Page 16: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Inference - JSJS vs OCaml

JSJS

OCaml

Page 17: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Inference with user annotations

Page 18: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Errors - JSJS vs OCaml

JSJS

OCaml

Page 19: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Type Errors - JSJS vs OCaml

JSJS

OCaml

Page 21: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

What next?

➔ Tuples

➔ Option Type

➔ Pattern Matching

➔ Javascript FFI

➔ Line Number Error Reporting

Page 22: JSJS - Columbia Universitysedwards/classes/2016/4115-spring/report… · Feature JSJS JS Type Safety ´ µ ... sort, nth, length All functions return new lists (do not modify the

Thank You

So long, and thanks for all the fish.