Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Conquering a large JavaScript codebase

Conquering a large JavaScript codebase

JavaScript was originally conceived to write little scripts that could add some interactivity to a web page. Today, it is used for increasingly large applications — in the browser, but also on the server, e.g. using node.js.
Cloud9 IDE is an Integrated Development Environment developed exclusively in JavaScript, both on the client and server-side, counting over 240,000 lines of JavaScript code. Managing a code base this large requires a good architecture, good solid code foundation as well as solid tools. During this talk I will describe the Cloud9 infrastructure as well as the techniques, libraries and tools we are developing to make it scale, and also how language analysis is helping us make sure that our code is rock-solid thoughout all our application.

B083b8207ccd0744a5abb18c8e75d24d?s=128

Sergi Mansilla

May 18, 2012
Tweet

More Decks by Sergi Mansilla

Other Decks in Programming

Transcript

  1. a large JavaScript codebase Conquering

  2. @sergimansilla

  3. None
  4. None
  5. None
  6. Create Share Test Deploy Run/Debug

  7. The$easiest$way$to$create$Node.js$apps

  8. Ftp WebDAV Heroku Git Language Analysis Vim mode Run/Debug Cloud

    storage Revisions Search Collaboration Cloudfoundry Azure Testing CLI Bitbucket Plugins
  9. Pretty big app

  10. More than 1M lines (with semicolons)

  11. Of JavaScript

  12. Pure madness

  13. Why sparta madness?

  14. Javascript/Node.js make you more productive

  15. But they won’t help you through your growing pains

  16. What about some examples

  17. None
  18. Why Node.JS?

  19. None
  20. V8 JavaScript engine

  21. Bindings to libuv

  22. Best cross-platform I/O library

  23. API accessible from JavaScript

  24. Async I/O

  25. Async I/O is a big deal

  26. You can do things like this without blocking

  27. You can do things like this without blocking Loop$monkey,$loop! Write$a$‘.’$for$each$read$file

    Read$this$very$file
  28. None
  29. You probably want something like this Read$this$very$file Write$a$‘.’$for$each$read$file Loop$monkey,$loop! Only$100$items$at$a$

    Dme,$thanks
  30. Never, ever, ever, EVER block

  31. None
  32. In node, all APIs are asynchronous

  33. In node, all APIs are asynchronous?

  34. Getting a hash

  35. Getting a hash

  36. Getting a hash

  37. Getting a hash

  38. Profile before going live

  39. DTrace + node-stackvis http://blog.nodejs.org/2012/04/25/profiling-node-js/

  40. Embrace the paradigm

  41. Push processing to the client

  42. Use workers

  43. Use workers serialization < computation BUT only if

  44. Use workers worker.postMessage(...) Small objects only!

  45. Modularize your code

  46. Your application will fail

  47. Be prepared

  48. Architect github.com/c9/architect

  49. “A simple yet powerful plugin system for large-scale node applications”

  50. Isolation

  51. Security

  52. Providers / Consumers

  53. Advanced IPC between processes

  54. Sourcemint github.com/sourcemint/sm-npm

  55. Package manager that wraps package managers

  56. Understands any kind of dependency (npm, pip, git, zip...)

  57. Easy edit/publish

  58. Tooling matters

  59. Normal developers

  60. JavaScript Developer

  61. None
  62. Tooling matters

  63. Tooling matters especially for JavaScript

  64. None
  65. Use the power of...

  66. tatic

  67. program analysis

  68. None
  69. Iterating using undeclared variable

  70. Warning: you are in an anonymous inner function with its

    own “this” pointer
  71. Did you mean length?

  72. “The most important thing I have done as a programmer

    in recent years is to aggressively pursue static code analysis.” John Carmack
  73. treehugger.js github.com/ajaxorg/treehugger

  74. “The jQuery of AST analysis.”

  75. What can you do with it?

  76. Low-level tooling

  77. Intelligent code completion

  78. Complex refactoring

  79. Automate everything

  80. Human error happens

  81. Human error happens ALL THE TIME

  82. Spend time on automation scripts

  83. Spend time on automation scripts It really pays off

  84. Happy coding!

  85. Questions?

  86. http://github.com/sergi @sergimansilla http://c9.io