use ↔ to navigate
small modules
and the node aesthetic
Bret Comnes
what distinguishes JS?
1. Ubiquity
2. Unique Module System
3. Small Modules
1. Ubiquity
JS is everywhere
JS is the language of the web
JS is actually portable...
...and is becoming the language of everywhere
JS runs on browsers
in computers and servers
smart phones
(all of them)
embedded devices
its the one programming language your entire extended family has installed on their computer
including multiple IDEs
JS = worse is better
(vs "the right thing")
JS isn't the best language
but its simple, flexible and available
JS is fit for survival...
JS is "better" because of where and how it works rather than languages that "get it right"
2. Unique Module System
What is a module?
A module is a unit of code that is packaged for reuse by other modules
What is a module system?
A module system = conventions and programs that facilitate module use
JS didn't use to have a module system
when node.js came out...
JS got a package manager and a module loading system:
npm did two things
rapid module authorship
nested, local module dependencies
most programming languages have flat, global module dependencies
javascript + npm has nested, local dependencies
Nested vs flat dependencies
Flat dependencies
Nested dependencies
Turtles all the way down
No more "DLL Hell"
Your app gets the modules it needs at the version it wants
updating your deps is no longer a threat to other project deps
local dependencies by default
dependencies are installed locally to the project folder...
...instead of a system wide location shared between different programs
nested dependencies reduce the cost of...
using, writing and publishing modules
$ npm init ; $ npm publish
making changes is just as easy
$ git clone dep ; $ npm install ; $ npm test ; $ npm start
so lets use lots of modules...
3. Small Modules
JS doesn't have a standard library
pre-internet tradition was "do-everything" modules
this tradition carried over to JS
Libraries like jQuery...
...were the norm.
...this kitchen-sink mentality toward including a bunch of thematically-related but separable functionality into a single package...
...appears to be an artifact for the difficulty of publishing and discovery in a pre-github, pre-npm era. - james halliday
This has a cascade of problems
· couples independent functionality to a single version number
...updating dependencies becomes a stressful ordeal
people didn't update their deps!
and it was all done by hand!!
· large modules requires more knowledge and time when making contributions
· useful and reusable code get burred and left undocumented and unexposed
our modules are designed in isolation, documented in isolation and can be used in isolation. -Jake Verbaten
· policing thematic collections takes time and emotion
· small modules allow you solve a narrow problem domain
· small modules compose together
less frameworks
more recipes
monolithic frameworks trade away long term flexibility...
for short term convenience
When applications are done well, they are just the really application-specific, ...
..brackish residue that can't be so easily abstracted away - james halliday
The good news:
Things are changing
Small modules are catching on
Large modules are breaking up...
...into smaller modules
Lets recap!
JS is Ubiquitous
JS (and npm) automates module consumption
Small JS modules help us write better software and stay sane
Thanks for Listening!