JSJS A Strongly Typed Language for the Web Ayush Jain Gaurang - - PowerPoint PPT Presentation

jsjs
SMART_READER_LITE
LIVE PREVIEW

JSJS A Strongly Typed Language for the Web Ayush Jain Gaurang - - PowerPoint PPT Presentation

JSJS A Strongly Typed Language for the Web Ayush Jain Gaurang Sadekar Bahul Jain Prakhar Srivastav Just another day in the Javascript world Feature JSJS JS Type Safety Type Inference Why JSJS? Immutable


slide-1
SLIDE 1

JSJS

A Strongly Typed Language for the Web

Ayush Jain · Gaurang Sadekar · Bahul Jain · Prakhar Srivastav

slide-2
SLIDE 2

Just another day in the Javascript world

slide-3
SLIDE 3

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?

slide-4
SLIDE 4

A Sneak Peak - Syntax

slide-5
SLIDE 5

A Sneak Peak - Syntax

slide-6
SLIDE 6

Functional Programming

Functions everywhere...

slide-7
SLIDE 7

Closures

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

slide-8
SLIDE 8

Error Handling

Error Reporting Exceptions and Exception Handling

slide-9
SLIDE 9

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
slide-10
SLIDE 10

Immutable Collections - Lists & Maps

  • Uses Facebook’s Immutable.js library to enforce immutability.
  • All library functions written is JSJS.
slide-11
SLIDE 11

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)

slide-12
SLIDE 12

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)

slide-13
SLIDE 13

JSJS Type System

T(_) is a generic type that helps with type

Inference 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

slide-14
SLIDE 14

Type Inference - Our ‘Inspiration’

slide-15
SLIDE 15

Type Inference - JSJS vs OCaml

JSJS OCaml

slide-16
SLIDE 16

Type Inference - JSJS vs OCaml

JSJS OCaml

slide-17
SLIDE 17

Type Inference with user annotations

slide-18
SLIDE 18

Type Errors - JSJS vs OCaml

JSJS OCaml

slide-19
SLIDE 19

Type Errors - JSJS vs OCaml

JSJS OCaml

slide-20
SLIDE 20

Demo

slide-21
SLIDE 21

What next?

➔ Tuples ➔ Option Type ➔ Pattern Matching ➔ Javascript FFI ➔ Line Number Error Reporting

slide-22
SLIDE 22

Thank You So long, and thanks for all the fish.