vi visual s studio cod o code e
play

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


  1. Vi Visual S Studio Cod o Code e Shipping One of the Largest Microso3 JavaScript Applica8ons Alexandru Dima Microso7

  2. What do we ship? Visual Studio Code Monaco Editor Electron node.js Chromium Modern browsers

  3. Growing the code

  4. Growing the code

  5. I enjoy programming in JavaScript

  6. 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

  7. 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

  8. TypeScript Demo

  9. Growing the code

  10. 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…

  11. 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

  12. Our source at the Lme 90% 10% hN hNp p

  13. Module Systems to the rescue… AMD CommonJS

  14. TypeScript: First class module support Supports both AMD and CommonJS with one syntax Sharing code between AMD and CommonJS is easy

  15. Lazy code loading

  16. Lazy code loading

  17. Lazy code loading

  18. CSS dependencies AMD loader plugins We implemented a css loader plugin, and TypeScript supports to generate non-TypeScript dependencies in the JavaScript code

  19. Performance: Bundle & Minify your Code Not bundled, not minified 411 411 1208 1208 291 291 Bundled, not minified 426 426 957 957 306 306 Bundled & minified 421 421 805 805 294 294 0 500 1000 1500 2000 2500 Electron Startup Load modules Open Shell, Viewlet & Editor Minify everything (600): hNps://top.fse.guru/nodejs-a-quick-opLmizaLon-advice-7353b820c92e#.p52jv6nys

  20. Post Module System MigraLon It feels like fresh showered. Self contained modules, no more cycles, no more globals, clean file system structure . --Happy Developer

  21. Growing the code

  22. 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

  23. 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...

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

  25. Dependency InjecLon Constructor service injecLon in many places

  26. Dependency InjecLon

  27. Dependency InjecLon

  28. Dependency InjecLon

  29. Growing the code

  30. Electron Demo hNp://electron.atom.io/

  31. ExecuLon environments Electron Renderer Electron Main Process Process Once Electron is started Per Electron Window

  32. ExecuLon environments Check for updates Manage extensions Electron Renderer Electron Main Process Process VS Code Main Process Once VS Code is started Per VS Code Window

  33. ExecuLon environments Run extensions Electron Renderer Electron Main Process Process VS Code VS Code Main Extension Host Process Once VS Code is started Per VS Code Window

  34. ExecuLon environments Run a search Run a search Run a git operaLon Run a git operaLon Electron Renderer Electron Main Process Process VS Code VS Code VS Code VS Code Main Extension Host Search Service Git Service Process Once VS Code is started Per VS Code Window

  35. ExecuLon environments Compute diff Compute links Electron Renderer Web Electron Main Process worker Process VS Code VS Code VS Code VS Code Main Extension Host Search Service Git Service Process Once VS Code is started Per VS Code Window

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

  37. ExecuLon environments ES5 + node.js Electron Electron Renderer Web Process worker Main Process ES5 + node.js + electron (main) VS Code VS Code VS Code VS Code Extension Host Search Service Git Service Main Process ES5 + node.js + electron (renderer) + browser Once VS Code is started ES5 + web worker Per VS Code Window Fo Folder path RunLme me Al Allowed ed t to d o dep epen end on on 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

  38. Demo developing vscode

  39. Performance: Virtual scrolling

  40. Minified code: an editor’s worst nightmare

  41. Minified code: an editor’s worst nightmare What’s in 42 lines? 3409 spans (~tokens) 281 spans (~tokens)

  42. Get to know your tools: Scrolling Performance The Timeline shows the big picture: But Chrome Developer Tools has a few hidden gems:

  43. Get to know your tools: Scrolling Performance

  44. A few translate3d`s later… BEFORE AFTER BEFORE AFTER

  45. 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend