84
May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 A JavaScript Framework for Presentations and Animations on Computer Science Bachelor Thesis Technical Aspects of Multimodal Systems Department of Informatics University of Hamburg Laszlo Korte 1

and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

A JavaScript Framework for Presentations and Animations on Computer Science

Bachelor ThesisTechnical Aspects of Multimodal Systems

Department of InformaticsUniversity of Hamburg

Laszlo Korte

1

Page 2: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Outline

1. Introduction2. Web Platform

○ The Browser○ NodeJS○ Workflow○ Graphical User Interface

3. Components○ Demos

4. Architecture

2

Page 3: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Motivation

3

Introduction

Page 4: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Motivation

● Computer Science deals with abstract topics

● Hard to grasp without trying

● Short feedback cycle for building intuition

➔ Interactive learning experience

4

Page 5: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Matlab Components

● Boolean expression parsing and evaluation

● Binary number encoding and decoding

● Finate-state machine simulation

● Algorithm visualisation

● …

5

Page 6: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Matlab Components - FSM

6

finite-state machine simulator

Page 7: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Matlab Components - number encoding

7

number “circle”

Page 8: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Matlab Components - base conversion

8

visualisation of an algorithm for base conversion

Page 9: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Java Applets

● Karnaugh map editor

● Advanced FSM editor

9

Page 10: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Java Applets - Karnaugh map

10

Karnaugh map editor

Page 11: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Java Applets - Karnaugh map

11

Karnaugh map editor

Page 12: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Java Applets - FSM

12

Finite-state machine editor

Page 13: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Java Applets - FSM

13

Finite-state machine editor

Page 14: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Issues

● Matlab○ Not free, licensing restrictions

○ Not trouble-free with current Matlab version

○ Not on mobile devices

14

Page 15: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Issues

● Matlab○ Not free, licensing restrictions

○ Not trouble-free with current Matlab version

○ Not on mobile devices

● Java Applets○ Not on iOS (iPad, iPhone)

○ Not usable on touch screens

15

Page 16: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Objective

16

Introduction

Page 17: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Objective

● A new collection of components○ no licensing issues

○ not limitted to a small set of devices

➔ The web as free and open platform

➔ Touch screen support

➔ Support a wide range of screen sizes17

Page 18: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Objective - components

● Karnaugh map editor

● Finite-state machine editor

● Boolean expression editor

● Number circle

● ...

➔ Expandable later on

18

Page 19: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser

19

Web Platform

Page 20: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser

● Display HyperText Markup Language Documents (HTML)

● Documents can be styled via Stylehsheets (CSS)

● Documents may contain code to execute (JavaScript)

20

Page 21: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser - example HTML document

21

index.html

Page 22: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser - example HTML document

22

index.html

Page 23: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7623

index.html

+ CSS

Page 24: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7624

index.html

+ CSS

Page 25: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7625

index.html

+ JS

Page 26: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7626

index.html

+ JS

Page 27: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7627

index.html

+ JS

Page 28: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7628

index.html

+ JS

Page 29: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 7629

index.html

+ JS

Page 30: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser - example document

30

index.html

Page 31: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser

● HTML Document is the entry point○ links to/embeds stylesheets

○ links to/embeds javascripts

● Most of the application is defined in JavaScript (JS)

➔ start with an almost empty document, build everything in JS

31

Page 32: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser - Document Object Model

● DOM API allows querying and modifying the whole document

32

Page 33: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

The Browser - JavaScript

● No module system○ difficult to split application into modules

● No static type system

● Weird semantics○ 5 + "5" === "55"

○ 5 * "5" === 25

● API differences across browsers

33

Page 34: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

NodeJS

34

Web Platform

Page 35: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

NodeJS

● JavaScript runtime environment○ Based on Chrome’s JavaScript engine V8

○ Run JavaScript outside the browser

➔ Large ecosystem of open source libraries and tools

35

Source: https://nodejs.org/en/about/resources/

Page 36: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

NodeJS - Package Manager

● Command line tool for managing dependencies○ Like maven for Java or easy_install for python

● Access to >250.000 libraries

36

Source: https://www.npmjs.com/

Page 37: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow

37

Web Platform

Page 38: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Tools

● BabelJS○ Access to future JS features (eg. module system)

● ESLint○ Check source code for common errors

● Webpack○ Module bundler

○ combine multiple JS files and libraries into one file

38

Babel Logo: https://github.com/babel/babelESLint Logo: http://eslint.org/

Webpack Logo: https://webpack.github.io/

Page 39: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Babel

39

ES6 module import syntax

Source: https://github.com/babel/babel

Page 40: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Tools

40

moduleA.js

main.js

moduleB.js

vendor/LibX

Page 41: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - ESLint

41

moduleA.js

main.js

moduleB.js

Source: http://eslint.org/

Page 42: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Webpack

42

moduleA.js

main.js

moduleB.js

bundle application.js

Source: https://webpack.github.io/

Page 43: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Webpack

43

moduleA.js

main.js

moduleB.js

bundle

application.js

Source: https://webpack.github.io/moduleB.css

style.css

application.css

layout.css

Page 44: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Webpack Dev Server

44

Page 45: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Webpack Dev Server

45

● No manual recompile

● Watches the file system for changes

● Pushes changes to browser (via websocket)

Page 46: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Workflow - Webpack Dev Server

46

● No manual recompile

● Watches the file system for changes

● Pushes changes to browser (via websocket)

main.js

moduleB.js

moduleA.js

Dev Server

http://127.0.0.1:3000

watch

notify

connect

browser

file system

Page 47: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Graphical User Interface

47

Web Platform

Page 48: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

GUI - Graphical User Interface

● JavaScript provides multiple APIs for building GUIs

➔ HTML / CSS

➔ Canvas (2D bitmap)

➔ Scalable Vector Graphics (SVG)

48

Page 49: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

GUI - HTML / CSS

● Layout calculations are done by the browser○ text wrapping, adjusting height of elements

● Native support for responsive layouts

● API for user interactions

● Only rectangular shapes

49

Page 50: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

GUI - Canvas (2D Bitmap)

● Fine grained control on a pixel level

● All kinds of shapes (arcs, bézier curves…)

● Hard to support multiple screen sizes

● Hittesting needs to be done manually

50

Page 51: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

GUI - Scalable Vector Graphics (SVG)

● XML based format for vector graphics

● Embeddable into HTML

● All kinds of shapes (arcs, bézier curves…)

● Support for Stylesheets

● API for user interactions (event handling)

● sharp on all display sizes

● Manual layout (text wrapping, element height)51

Page 52: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

GUI

● HTML / CSS for base layout

● SVG for advanced visualisations and icons

● no Canvas

52

Page 53: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo

53

Components

● Logic expression editor● Logic expression checker● Karnaugh map editor

● LED editor● Number circle● FSM editor

https://thesis.laszlokorte.de/

Page 54: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Logic expression editor

● Parse boolean expression○ In various dialects

● Generate a function table

● Generate an operator tree○ Color branches

● Enter multiple expressions

54

thesis.laszlokorte.de/demo/logic-editor.html

Page 55: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Logic expression editor - Details

● Expressions are parsed by PEG.js via parsing expression grammar

● Tree is drawn via Buchheim algorithm(C. Buchheim, M. J Unger, and S. Leipert. Improving Walker's algorithm to run in linear time.)

● Labelled expressions are sorted topologically

55

Page 56: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Logic expression checker

● Simplified GUI for comparing two expressions

● Highlight differences in function table

56

thesis.laszlokorte.de/demo/logic-checker.html

Page 57: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Karnaugh map editor

● Create Karnaugh maps of various sizes

● Creating loops on a touch screen

● Show Programmable Logic Array

● Import and export expressions

57

thesis.laszlokorte.de/demo/kvd-editor.html

Page 58: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Karnaugh map editor - details

● PLA view is it’s own component

58

Page 59: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - LED editor

● Build function tables for 7-segment display…

● … or other displays

59

thesis.laszlokorte.de/demo/led-editor.html

Page 60: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Number circle

● Arrange binary numbers in a circle

● Adjusting the circle size

● Compare various encodings

● Highlight overflows

60

thesis.laszlokorte.de/demo/number-circle.html

Page 61: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Demo - Finite-state machine editor

● Edit Moore and Mealy machines

● Edit transition graph

● Not yet implemented:○ Accept logic expressions as transition conditions

○ simulating the machine

61

thesis.laszlokorte.de/demo/fsm-editor.html

Page 62: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture

62

Page 63: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture

● Based on Functional Reactive Programming

● Each component is a pure function, that transforms input to output

● Components do not modify any outside state

● inspired by Cycle.js library

63

Source: http://cycle.js.org

Page 64: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

● Events and state are modelled as streams

● Streams represent data over time

● A component takes stream of events (clicks, key presses…) as input

● A component produces a stream of state (document state) as output

64

Page 65: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

65

Logic Expression Field

Stream<KeyPress> Stream<MouseClick>

Stream<DocumentTree> Stream<AbstrSyntaxTree>

Page 66: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

66

23 16 42 8

23 42

filter((x) => x > 20)

time

Page 67: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

67

23 16 42 8

map((x) => x * 2)

time

46 32 84 16

Page 68: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

68

23 16 42 8

scan((acc, x) => acc + x, 0)

time

23 39 81 89

Page 69: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Architecture - Functional Reactive Programming

69

● many more operators available (reactivex.io)

● The whole GUI is built via stream transformation

● especially drag-drop and touch gesturesare easy to build on top of event streams

Page 70: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

70

Page 71: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

71

● Componenents work across all major browsers:○ Chrome, Firefox, Opera, Safari, IE11, Edge

● usable on various screen sizes○ (sharp on retina screens)

● usable on touch screens

Page 72: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

72

Stats:

● ~12.000 lines of JavaScript

● 217 JavaScript files

● 610 Git Commits

Page 73: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

73

Potential improvements:

● Performance could be improved

● Printing support would be nice○ eg. export expression tree or function table as PDF

● Expression parser via command line

● Splitting component into separate projects

Page 74: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

74

Potential improvements (Cont.):

● Output file size could be further reduced○ by tree shaking vendor libraries

○ currently ~500KB for Karnaugh maps

● For long term maintanance use a stronger

language than JavaScript○ eg. PureScript or TypeScript

Page 75: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Conclusion

75

Potential improvements (Cont.):

● No animations yet!○ easy to built via stream transformation…

○ … or CSS animations

Page 76: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Thank you for your attention! Questions?

76

● Web Platform○ The Browser○ NodeJS, NPM○ Workflow (Babel, ESLint, Webpack)○ Graphical User Interface (HTML, Canvas, SVG)

● Components○ Logic Expression editor/checker○ Karnaugh Maps○ LED editor○ Number Circle○ FSM editor

● Architecture

Page 77: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map recursion

77

Page 78: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map recursion (Cont.)

78

Page 79: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map recursion (Cont. 2)

79

Page 80: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map drag-’n-drop

80

Page 81: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map layout #1

81

Page 82: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map layout #2

82

Page 83: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map layout #3 a

83

Page 84: and Animations on Computer Science A JavaScript ......May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76 Workflow - Tools BabelJS Access to

May 3, 2016 - Laszlo Korte - JavaScript Framework for Presentations on Computer Science / 76

Bonus - Karnaugh map layout #3 b

84