Skip to content
modularidade para todos
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
browser
static
package.json
readme.markdown
server.js
slides.svg

readme.markdown

modularidade

browserify

browserify is a tool for smuggling node-style modularity into hostile browser territory

dragon

hacker wizard

{"cwd":"example/browserify"}

free software

npm

package manager for javascript

anarchy

king isaacs

whatever

king whatever

c

C is excellent

  • for writing fast things
  • for writing memory-efficient things
  • for writing operating systems
  • for writing code that still works decades later

unix

unix is about using tiny pieces that do 1 thing well

c was written FOR unix

c sickle

and yet...

C is terrible

  • for writing complicated things
  • for writing simple things

2038

We're going to have to refactor everything ANYWAYS.

include

require

export

#export= foo
int foo(int n) {
    return n * 111;
}

require as

sweet as

#require "./foo.c" as flibble

int main (int argc, char **argv) {
    var n = flibble(atoi(argv[1]));
    printf("%d\n", n);
}

dotc

dotc is a c/c++ preprocessor written in javascript!

$ dotc pre main.c

#include "stdio.h"
#include "stdlib.h"

namespace _7ce9a233 {

int foo (int n) {
    return n * 111;
}

};


int main(int argc, char **argv) {
    printf("%d\n", (_7ce9a233::foo)(atoi(argv[1])));
    return 0;
}

whatever.c

{"cwd":"example/dotc"}

npm

let's just put c code on npm

with a .c extension

dotc search color

is the same as

npm -s search '/\.(c|cc|h|cxx|cpp)\b/' color | grep -E '^\S+\.(c|Cc|h|cxx|cpp)\s'

which finds:

colors.cc  colors for C++  =divanvisagie  2013-09-19 18:18  0.0.0

king whatever

rationalizing putting c modules on npm

  • npm already exists
  • if they are on npm then somebody will build a nice pipline for loading them with require() from javascript or something
  • embedded systems I guess? arduino or whatever
  • v8 is written in c++
  • node v8 bindings are written in c++

widening the modularity tent

  • node, browsers, and now c!
  • we need to amateurize computer programming
  • make it easier to consume, easier to share
  • glsl, embedded systems, arduino

content-addressable data

revoluçao

guillotine

npms

let's use npm for now

but next...

content-addressable data

all libraries, code snippets, blog posts

can be hashed

anarchy os!

anarchy os is just a brand we can use to describe what npm has become and where it can go

We don't need to write anything new. You can just install whatever you want inside of whatever base operating system you already have. Everything is vendored, node_modules style.

Everybody can publish. Everything competes. Nothing is blessed. Not even npm itself is blessed! (npmd)

on npm we've already got:

  • packaging and module scheme for c (dotc)
  • a tiling window manager
  • the start of distributed peer-to-peer npm (npmd)
  • wireless networking tool (wit)

{"cwd":"example/npmd"}

what we still need:

  • getting modules from peers
  • alternate repos, hash versions in package.json dependencies

modularidade

Something went wrong with that request. Please try again.