Vi Visual S Studio Cod o Code e Shipping One of the Largest - - PowerPoint PPT Presentation

vi visual s studio cod o code e
SMART_READER_LITE
LIVE PREVIEW

Vi Visual S Studio Cod o Code e Shipping One of the Largest - - PowerPoint PPT Presentation

Vi Visual S Studio Cod o Code e Shipping One of the Largest Microso3 JavaScript Applica8ons Alexandru Dima Microso7 What do we ship? Visual Studio Code Monaco Editor Electron node.js Chromium Modern browsers Growing the code Growing


slide-1
SLIDE 1

Vi Visual S Studio Cod

  • Code

e

Shipping One of the Largest Microso3 JavaScript Applica8ons

Alexandru Dima Microso7

slide-2
SLIDE 2
slide-3
SLIDE 3

What do we ship?

node.js Chromium Electron

Visual Studio Code Monaco Editor

Modern browsers

slide-4
SLIDE 4

Growing the code

slide-5
SLIDE 5

Growing the code

slide-6
SLIDE 6

I enjoy programming in JavaScript

slide-7
SLIDE 7

Pains

Organizing a large and growing code base

Need to come up with “compensaLng” paNerns for classes and modules/namespaces

Refactoring JavaScript code is difficult

“JavaScript code rots over 0me” “Wri0ng JavaScript code in a large project is like carving code in stone”

Describing APIs

Keep the descripLon in sync with the implementaLon

slide-8
SLIDE 8

TypeScript to the rescue…

Starts with JavaScript

All JavaScript code is TypeScript code, simply copy and paste All JavaScript libraries work with TypeScript

OpLonal staLc types, classes, modules

Structural typing and type inference Enable scalable applicaLon development and excellent tooling Zero cost: StaLc types completely disappear at run-Lme

Ends with JavaScript

Compiles to idiomaLc JavaScript Runs in any browser or host, on any OS

slide-9
SLIDE 9

TypeScript Demo

slide-10
SLIDE 10

Growing the code

slide-11
SLIDE 11

Code OrganizaLon: Keep code structured

Our namespaces were glo global v bal variables ariables and thereby open Namespaces have no relaLonship to the actual files on disk Renaming files or namespaces was a pain… We had cyclic dependencies without noLcing…

slide-12
SLIDE 12

Growing Pains: Managing dependencies

…our dependency graph was such a mess that each area had a dependency on just about every other area.

  • - Ashamed Developer
slide-13
SLIDE 13

Our source at the Lme

hN hNp p

90% 10%

slide-14
SLIDE 14

Module Systems to the rescue…

AMD CommonJS

slide-15
SLIDE 15

Supports both AMD and CommonJS with one syntax Sharing code between AMD and CommonJS is easy

TypeScript: First class module support

slide-16
SLIDE 16

Lazy code loading

slide-17
SLIDE 17

Lazy code loading

slide-18
SLIDE 18

Lazy code loading

slide-19
SLIDE 19

CSS dependencies

AMD loader plugins

We implemented a css loader plugin, and TypeScript supports to generate non-TypeScript dependencies in the JavaScript code

slide-20
SLIDE 20

Performance: Bundle & Minify your Code

421 421 426 426 411 411 805 805 957 957 1208 1208 294 294 306 306 291 291 500 1000 1500 2000 2500 Bundled & minified Bundled, not minified Not bundled, not minified Electron Startup Load modules Open Shell, Viewlet & Editor

Minify everything (600): hNps://top.fse.guru/nodejs-a-quick-opLmizaLon-advice-7353b820c92e#.p52jv6nys

slide-21
SLIDE 21

Post Module System MigraLon

It feels like fresh showered. Self contained modules, no more cycles, no more globals, clean file system structure.

  • -Happy Developer
slide-22
SLIDE 22

Growing the code

slide-23
SLIDE 23

100% TypeScript

MigraLon happened out of developer will MigraLon is code clean-up but real work… My velocity around 300 LOCs per hour Team specific rules No implicit ‘anys’ No missing return types JSDoc comments No unused variables

slide-24
SLIDE 24

Towards 100% TypeScript

In JavaScript, you really are at the mercy of your ability to spell: delete this.markers[range.statMarkerId]; Soon enough, I realized how inconsistent I was, the same data was flowing around in at least 3 different formats...

slide-25
SLIDE 25

Components

We consume: typescriptServices.js & typescriptServices.d.ts We ship: monaco-editor.js & monaco.d.ts vscode.d.ts - defines our extension API

slide-26
SLIDE 26

Dependency InjecLon

Constructor service injecLon in many places

slide-27
SLIDE 27

Dependency InjecLon

slide-28
SLIDE 28

Dependency InjecLon

slide-29
SLIDE 29

Dependency InjecLon

slide-30
SLIDE 30

Growing the code

slide-31
SLIDE 31

Electron Demo

hNp://electron.atom.io/

slide-32
SLIDE 32

Electron Main Process Electron Renderer Process Once Electron is started Per Electron Window

ExecuLon environments

slide-33
SLIDE 33

Electron Main Process VS Code Main Process Electron Renderer Process Once VS Code is started Per VS Code Window

ExecuLon environments

Check for updates Manage extensions

slide-34
SLIDE 34

Electron Main Process VS Code Main Process Electron Renderer Process VS Code Extension Host Once VS Code is started Per VS Code Window

ExecuLon environments

Run extensions

slide-35
SLIDE 35

Electron Main Process VS Code Main Process Electron Renderer Process VS Code Extension Host VS Code Search Service VS Code Git Service Once VS Code is started Per VS Code Window

ExecuLon environments

Run a search Run a git operaLon Run a search Run a git operaLon

slide-36
SLIDE 36

Electron Main Process VS Code Main Process Electron Renderer Process VS Code Extension Host VS Code Search Service VS Code Git Service Web worker Once VS Code is started Per VS Code Window

ExecuLon environments

Compute diff Compute links

slide-37
SLIDE 37

Electron Main Process VS Code Main Process Electron Renderer Process VS Code Extension Host VS Code Search Service VS Code Git Service Web worker Once VS Code is started Per VS Code Window

ExecuLon environments

slide-38
SLIDE 38

ExecuLon environments

Electron Main Process VS Code Main Process

Electron Renderer Process VS Code Extension Host VS Code Search Service VS Code Git Service

Web worker

Once VS Code is started Per VS Code Window

ES5 + node.js ES5 + node.js + electron (main) ES5 + node.js + electron (renderer) + browser ES5 + web worker Fo Folder path RunLme me Al Allowed ed t to d

  • dep

epen end on

  • n

common ES5

  • node

ES5 + node.js common browser ES5 + browser common electron-main ES5 + node.js + electron (main) common, node electron-browser ES5 + node.js + electron (renderer) + browser common, node, browser worker ES5 + web worker common

slide-39
SLIDE 39

Demo developing vscode

slide-40
SLIDE 40

Performance: Virtual scrolling

slide-41
SLIDE 41

Minified code: an editor’s worst nightmare

slide-42
SLIDE 42

Minified code: an editor’s worst nightmare

What’s in 42 lines?

3409 spans (~tokens) 281 spans (~tokens)

slide-43
SLIDE 43

Get to know your tools: Scrolling Performance

The Timeline shows the big picture:

But Chrome Developer Tools has a few hidden gems:

slide-44
SLIDE 44

Get to know your tools: Scrolling Performance

slide-45
SLIDE 45

A few translate3d`s later…

BEFORE AFTER BEFORE AFTER

slide-46
SLIDE 46

Resources

VS Code hNps://github.com/Microso7/vscode TypeScript hNps://www.typescriptlang.org/ Electron hNp://electron.atom.io/ gulp-tsb hNps://github.com/jrieken/gulp-tsb TwiNer @code