Coisas que vicapow gosta Explore mais coisas populares no Tumblr

  1. 3 122
    Prosecutor as bully

    (Some will say this is not the time. I disagree. This is the time when every mixed emotion needs to find voice.)

    Since his arrest in January, 2011, I have known more about the events that began this spiral than I have wanted to know. Aaron consulted me as a friend and lawyer. He shared with me what went down and why, and I worked with him to get help. When my obligations to Harvard created a conflict that made it impossible for me to continue as a lawyer, I continued as a friend. Not a good enough friend, no doubt, but nothing was going to draw that friendship into doubt.

    The billions of snippets of sadness and bewilderment spinning across the Net confirm who this amazing boy was to all of us. But as I’ve read these aches, there’s one strain I wish we could resist:

    Please don’t pathologize this story.

    No doubt it is a certain crazy that brings a person as loved as Aaron was loved (and he was surrounded in NY by people who loved him) to do what Aaron did. It angers me that he did what he did. But if we’re going to learn from this, we can’t let slide what brought him here.

    First, of course, Aaron brought Aaron here. As I said when I wrote about the case (when obligations required I say something publicly), if what the government alleged was true — and I say “if” because I am not revealing what Aaron said to me then — then what he did was wrong. And if not legally wrong, then at least morally wrong. The causes that Aaron fought for are my causes too. But as much as I respect those who disagree with me about this, these means are not mine.

    But all this shows is that if the government proved its case, some punishment was appropriate. So what was that appropriate punishment? Was Aaron a terrorist? Or a cracker trying to profit from stolen goods? Or was this something completely different?

    Early on, and to its great credit, JSTOR figured “appropriate” out: They declined to pursue their own action against Aaron, and they asked the government to drop its. MIT, to its great shame, was not as clear, and so the prosecutor had the excuse he needed to continue his war against the “criminal” who we who loved him knew as Aaron.

    Here is where we need a better sense of justice, and shame. For the outrageousness in this story is not just Aaron. It is also the absurdity of the prosecutor’s behavior. From the beginning, the government worked as hard as it could to characterize what Aaron did in the most extreme and absurd way. The “property” Aaron had “stolen,” we were told, was worth “millions of dollars” — with the hint, and then the suggestion, that his aim must have been to profit from his crime. But anyone who says that there is money to be made in a stash of ACADEMIC ARTICLES is either an idiot or a liar. It was clear what this was not, yet our government continued to push as if it had caught the 9/11 terrorists red-handed.

    Aaron had literally done nothing in his life “to make money.” He was fortunate Reddit turned out as it did, but from his work building the RSS standard, to his work architecting Creative Commons, to his work liberating public records, to his work building a free public library, to his work supporting Change Congress/FixCongressFirst/Rootstrikers, and then Demand Progress, Aaron was always and only working for (at least his conception of) the public good. He was brilliant, and funny. A kid genius. A soul, a conscience, the source of a question I have asked myself a million times: What would Aaron think? That person is gone today, driven to the edge by what a decent society would only call bullying. I get wrong. But I also get proportionality. And if you don’t get both, you don’t deserve to have the power of the United States government behind you.

    For remember, we live in a world where the architects of the financial crisis regularly dine at the White House — and where even those brought to “justice” never even have to admit any wrongdoing, let alone be labeled “felons.”

    In that world, the question this government needs to answer is why it was so necessary that Aaron Swartz be labeled a “felon.” For in the 18 months of negotiations, that was what he was not willing to accept, and so that was the reason he was facing a million dollar trial in April — his wealth bled dry, yet unable to appeal openly to us for the financial help he needed to fund his defense, at least without risking the ire of a district court judge. And so as wrong and misguided and fucking sad as this is, I get how the prospect of this fight, defenseless, made it make sense to this brilliant but troubled boy to end it.

    Fifty years in jail, charges our government. Somehow, we need to get beyond the “I’m right so I’m right to nuke you” ethics that dominates our time. That begins with one word: Shame.

    One word, and endless tears.

      Carregando...
    1. 16
      On ES 6 Modules

      A few things have rubbed me the wrong way about the current Modules and Module Loader specification. I regret that I have not been very clear about what exactly my objections are, and worse still, I have not been very clear about what I think a better direction would be.

      Yes, this will be sent to ES-Discuss as a proper discussion proposal. This blog post is phase three of getting my ideas in order. (The first being “get annoyed that current proposals don’t fix the problem”, and the second being “rant about it with friends and colleagues on twitter and over tacos.”)

      First of all, I want to put to rest any ideas that I’m a die-hard JavaScript language conservative ideologue who will oppose any change whatsoever. I am well aware that what we have is lacking. I would love to see changes that make it easier to write JavaScript module systems, and debug programs that use them.

      I believe that there is a place for new syntax, especially in cases where it allows for optimizations in the implementation, ease of reading, or run-time behavior that must occur before the program is executed (that is, static analysis stuff.) Parsing a plain-old JavaScript AST is certainly possible, but it’s a bit unfortunate.

      We’ve spent a few years now doing modules in JavaScript. The claim that “JavaScript needs modules” is thus somewhat misguided: JavaScript needs better modules. Leaving aside Node.js for the moment, modular systems in JavaScript generally:

      1. Impose boilerplate restrictions on the programmer. This is ugly and error-prone, and there is no easy way to catch many of these errors early.
      2. Are not inter-operable with code that uses a different module system (or none at all).
      3. Either require that all modules be present in the page at the start, or delay the execution of the program unacceptably. (No one does sync XHR. I’m talking about r.js/AMD and the YUI3 seed file here.)
      4. Leaks internal implementation details in unfortunate ways, so that users are sometimes surprised when behavior violates intuitions.
      5. Do not isolate global leakage, making a missing var a felony, when it shouldn’t even be a misdemeanor. (At best, they wrap in a function.)
      6. To varying degrees, line and column numbers are obscured. (Sometimes just the first line’s column; sometimes the stack traces are completely meaningless.)

      All of these problems are issues with Node.js as well! We paper over #3 by using a package manager and requiring that the modules in your program are available on the disk at the start, but it’s still in my opinion unacceptable. We have the advantage of “startup time” and “run time” separation, but really, <script> tags are a web browser’s “startup time”, and the rest of the time is its “run time”. Build processes allow one to trade run-time delay (and complexity) for up-front download size (and a simpler synchronous require()), but generally only by making the other problems worse.

      TC-39 has one chance to specify a Module system that can address each of these issues, or allow host platforms to address them effectively. Problems introduced here will be with us forever. A half-way fix will be prohibitively expensive to fix once it’s in use, so we’ll be stuck with mistakes for some time (as we in Node.js are stuck with the mistakes in our system.)

      The Good in the Current Spec

      Though I think it has deep problems, there are very good parts in the current spec:

      1. It clearly is attempting to reach a module system that addresses the needs of Node.js (and whatever on-device JavaScript platforms succeed it), as well as those of browser-JavaScript authors and platforms like RequireJS and Browserify.
      2. The issues around globals and scope are pretty solid. I don’t have much to complain about there. Any changes to global behavior come along with a pile of edge cases, but they’re pretty thorougly evaluated and addressed.
      3. The goals of both the Module and Loader proposals had me pretty much cheering. It seems like TC-39 is actually interested in solving a problem, and that gives me hope.

      More than anything, reading the spec makes it clear that the problem is fairly well understood. However, the presented solution seems to be headed in the wrong direction.

      Problems with the Current Spec

      I’m not going to go through the issues that I have with the current spec one by one. It’s tedious and not the conversation we should be having. I’ll detail my alternative proposal below.

      However, there are a few points I’d like to highlight, because they are issues that probably ought to be informed by the experience that I and other module system authors and users can provide.

      1. It seems to be based on the assumption that nesting module systems is a thing that people want. Historically, in Node, we’ve made several API decisions based on the explicitly stated requests to make the module system more extensible and flexible. In practice, none of the supposed innovation panned out, and every one of those decisions was a huge mistake that increased flexibility with no tangible benefit.

        People don’t want to write module systems. People want to stop writing module systems. Once there’s a module system in place, it should be The module system, period.

        It bears repeating: no one wants to write a module system. A few of us take it on out of regrettable necessity. Anyone who actually enjoys writing module systems is too insane to be trusted. The only rational position is to do the simplest necessary thing, and as quickly as possible get to the business of building real programs with it. Optimize for that.

      2. It puts too many things in JavaScript (as either API or syntax) which belong in the host (browser/node.js). As I said, people don’t actually want to write module systems in their JavaScript programs. They want to stop having to think about it. Node’s module system has been successful (as has require.js and browserify) precisely because it requires a minimum amount of thought on the part of the user about the module system. (It’s still way too much.)

        Adding features that add complexity with the goal of making it easier to have lots of module systems in JavaScript is a mistake. Typically we can enable extension more effectively by reducing the scope of the specification, rather than by increasing it.

      3. It borrows syntax from Python that many Python users do not even recommend using. The import * from mod syntax is dated and highly contentious in the Python community (as is import com.foo.* in Java), because it is a recipe for name collisions. Learning from real implementations is winful; but we should be avoiding their mistakes, not copying them.

        Furthermore, let already gives us destructuring assignment. If a module exports a bunch of items, and we want several of them, then do var {x,y,z} = import 'foo' or some such. This import <x> from <module> as <blerg> is 100% unnecessary, adds nothing, and solves no problems. It does not pay its utility bill.

      4. It favors the “object bag of exported members” approach, rather than the “single user-defined export” approach. Node.js uses an exports object because the CommonJS approach seemed like a good idea at the time, and it works around the fact that we have no good way to handle transitive dependencies except via unfinished objects.

        However, it is widely acknowledged in the node community that using the module.exports = xyz style generally results in better programs. Changes at the language level can likely address the transitive loading issue more powerfully, and so should encourage the known best practices.

      A Simpler Proposal

      Clearly, the problems with the current state of JavaScript modules cannot be solved with zero changes to the language. Some cannot be changed without adding syntax. However, every change carries with it a cost. Therefor, it seems like the ideal approach is to try to find the minimum possible change that will address the issues — and, we ought to be ruthless on which bits of functionality don’t make the cut to be worth the risk. If we can get away with a much smaller fix by refusing to address part of the problem which is inessential, then that is the right course of action.

      I don’t know if this is minimal enough, but I’d like to propose the following, which I think picks some of the most essential aspects of the Loader and Module proposals. It’s very rough, and there are a lot of unanswered questions. But in general, this is what I would like to see from a Loader specification.

      This is very rough, and needs a lot of polish and edge-case exploration. I’m not pitching it to get it accepted, I’m sharing it to hopefully help pull the conversation in another direction, and help make it clear what a better proposal might look like.

      (I’ve numbered them simply so that I can refer to bits later, not so much because they’re a list of like things in order. I’m a spec n00b.)

      1. A Loader built-in object, with a few methods that must be specified before modules can be used. (And will typically be specified by the host object.)

      2. Within a module, the import <pathString> syntax that can be easily detected statically in program text before evaluation, and returns a module’s exported object. var foo = import 'path/to/foo.js'. Import returns a single value, always. The path must be a string literal. The import keyword is an operator, not a function, and thus cannot be assigned etc.

      3. Loader.define(<path>, <program text>) defines a module at the specified <path>, with the <program text> contents. That <program text> is statically analyzed for any import statements.

      4. Whenever an import <path> is encountered in <program text> then the Loader.resolve(requestPath, callerPath, callback) is called. This method should return a fully qualified path. If this method returns boolean true, then it will not be considered resolved until the callback is called. (The argument to the callback is the string path.) If it does not return true, and does not return a string path, then this is an error, and throws.

      5. Once a module is resolved to a full path string, then Loader.load(fullPath, callback) is called. callback should not be called until Loader.define(fullPath, contents) is called. This should be called at most once for any given fullPath. (Is the callback even necessary? Why not just wait for Loader.define and throw any errors encountered?)

      6. The Loader.main(fullPath) method executes the module referenced by fullPath (which must have already been defined), as well as evaluating each of the modules that it imports.

      7. Within a module, the export <expression> statement marks the result of <expression> as the exported value from the module. There can be at most one export statement in a module, and the exported expression is the module’s export. To export more than one thing, export an object with more than one thing on it.

        Modules export a single value. Exporting a second time throws.

        Maybe this is not a valid cause for syntax addition. I’m not sure. There are hairy problems around cyclic dependencies, so it’s worth at least having the option to address with static magic that has not yet been fully imagined.

      8. The global object within a module context is equivalent to Object.create(<global>) from the main global context. (The important thing is that leaks aren’t leaky outside the module, but for example, x typeof Error still works, because it uses the same Error function.)

      9. If a module does not contain an export statement, then its global object is its export. This is to provide support for legacy modules that create a global object (such as jQuery) rather than using an export statement. (Too magical? Probably. Also, what about having exports inheriting from global is weird. Is there a simpler way to make existing libs place nicely with this approach?)

      The default values of Loader.load, Loader.define, and Loader.resolve would typically be set by the host environment. However, for reasons of simplicity, they must be set in normal program text (ie, not in a module), and modules should not have the ability to alter them.

      In web browsers, modules could be defined straight away by using a new attribute on the script tag: <script module src='http://src.com/foo.js'></script> would be equivalent to doing Loader.define('http://src.com/foo.js', '<contents of foo.js>).

      Bundler programs could trivially translate files into modules using Loader.define (rather than wrapping in a IIFE), or JavaScript files could be loaded as-is, without requiring that existing libraries begin using any module { ... } syntax.

      In Web Browsers

      Web Browsers could implement the Loader object thusly:

      • Loader.resolve(request, from) Uses standard URL-resolution rules.
      • Loader.define could be sweetened by a <script module> tag.
      • Loader.main could be set via a <script module main> tag.
      • Loader.load could fetch the URL, and evaluate the contents, as if it had been added to the document with a <script module src=...> tag.

      For additional extensibility, these methods could be overridden by, for example, browserify or RequireJS.

      For security, the Loader object could be frozen with Object.freeze to prevent additional changes.

      I’m in no way attached to the specifics of the tag spelling. My point is that we in the JS community should specify the loader semantics, and then let host objects take advantage of them in application-specific ways.

      In Require.JS

      RequireJS and other AMD platforms would be pretty much made mostly obsolete by this specification, since the principle of AMD would just be “how it works” in web browsers by default. But, without the unfortunate boilerplate, and the resource loading mechanism could kick off much sooner, since import statements can be detected long before the script is actually run.

      In Browserify

      Most browserify modules would Just Work if they replaced require(..) with import ... However, it would probably be necessary to extend the Loader methods to provide shims for Node.js built-ins (ie, path, fs, url, assert, net, http, etc.) as well as pre-define node_modules dependencies into the browserify bundle.

      However, Browserify’s static analysis build step could be made much more effective by using a designated import operator rather than relying on knowledge of a require function.

      In Node.js
      • Loader.resolve(request, from) would do the current node_modules and NODE_PATH dance.
      • Loader.define would replace the existing module wrapper stuff.
      • Loader.main would be called on the module specified as a command line argument.
      • Loader.load would be very straightforward FS operations.

      This would also set the stage for making node-core itself more modular, and we could even explore new approaches like detecting module dependencies from code, rather than requiring the use of a package.json file, which is very exciting.

      What’s Missing from this Proposal

      There is no module syntax in this “module” proposal. That is because it is unnecessary, and its omission is intentional.

      A lot of work has also been done on the Harmony Module Loader proposal to flesh out some details of the Loader object. Most of this is good stuff. However, by removing the Module syntax portion of the proposal, a lot of those things can be streamlined.

      It’s also worth mentioning that this approach make sourcemaps unnecessary for useful stack traces, even in bundled or concatenated code, as the Loader.define() syntax would function as a sourcemap.

      While the experience in the wild has shown us that the “export one thing” approach is definition sound, I’m not sure exactly how to handle the transitive dependency issue in a way that doesn’t involve unfinished objects, or cause breakage in cases like this:

      // x.js
      var y = import './y.js'
      
      // y.js
      setTimeout(function() {
        export { fooled: 'you' }
      }, 100)
      

      Even more insidious is something like this:

      // x.js
      var y = import './y.js'
      export { real: 'x' }
      
      // y.js
      var x = import './x.js'
      assert.deepEqual(x, {real: 'x'}) // nope!!
      

      Because x sets its export after being loaded by y, the assignment does nothing. Currently, in Node.js (and most other systems as well) this is not handled, or not handled very well at least.

      Is there some way that it could somehow pass an object to the x module that would get swapped out behind the scenes when y.js changes its export? Is that too magical? I’m not sure.

      Next…

      My hope is that this post will help spark a more interesting conversation than the current tendency towards “YAY/BOO” that is so common in the internet. This isn’t politics. We’re not voting for parties. The goal is to figure out the best API, which is a complex thing. The solution space is wide, and it is naive to reduce it to a boolean prematurely.

      I would like to try out some implementations of this in Node.js as soon as possible. Also, I’d love to hear feedback about which parts of this you think are unnecessary or impossible.

      Let’s not forget that we all want these problems solved. No reasonable person thinks that JavaScript programs are optimally modular today. Most people who enjoy Node’s module system only like it because they’ve never taken a close look at it. As one of its maintainers and chief architects, I feel qualified to say that it’s pretty terrible. (Though, in my opinion, it is the best I’ve used, and the only that is optimized for maximum utility and an absolute intolerance for boilerplate. It’s just that the language is lacking, but that’s what this is all about.)

      Not every change is an improvement, but every improvement is a change. My friends in the “no new syntax” crowd would do well to remember that.

      That being said, since JavaScript cannot be easily changed, and can only be changed in one direction, we must be very careful to make sure that every change is an improvement. It’s more important to proceed carefully than to proceed quickly.

      Future generations will thank us for our care, and curse us for our haste.

        Carregando...
      1. 60
        Components

        With the advent of numerous client-side JavaScript package managers, I wanted to write up some of my thoughts about the fragmentation that we have today, and some ways that I think we could really improve delivering packages a community. Keep in mind that these are only my opinions, everyone has done a great job and there’s a lot of cool work going on out there.

        I think there are a few problems with the current environment, though some are subjective. The first of these and the most important in my opinion is the lack of unification around package consumption and definitions. The second issue is package delivery, what’s going to transport them to your machine? The final issue is the use of the components, how are they exposed to the browser for your application.

        Once I’m done rambling I’ll show you how we’ve been using components to build our application at LearnBoost, and how they really fare. Before getting into all that let’s dig into what I mean by “component”.

        Building components

        There have been many attempts to come up with some sort of client-side package manager, and some of them do it very well, however I think they are missing the big picture, a “component” is much more than just JavaScript.

        Create components, not JavaScript packages

        A component can be not just JavaScript, but CSS, images, fonts or other resources, or a component may be any combination of these. This is the main idea that I want to sell, we need to broaden modularity beyond just JavaScript source. This is not a new concept at all, Drupal has been employing it for over 7 years but it seems like something that hasn’t really caught on in most communities, at least not beyond the private application level.

        A great example of a component would be a popover from the Twitter Bootstrap library (not picking on you guys, it’s just a good example):

        This thing looks so sexy that I just want to install it with my package manager, and have it automatically available to me in the client. For this to happen we need to admit that a component is much more than JavaScript, and should be packaged accordingly. Like the “dialog” in UIKit for example:

        UIKit even at this state is not a good example of a solution for this problem, it uses its own custom build script to produce a single ui.js and ui.css file from the components in the repo, so it’s still not something the community can consume directly without the custom build step. I’ve started moving UIKit components over to github.com/component.

        Another problem in the community is the size and scope of projects.

        Size and scope

        The classic battle between DOM manipulation libraries such as jQuery and MooTools serve as an obvious example of fragmentation. Even if one is more popular than the other this doesn’t mean we don’t have a problem. Have you ever seen a great jQuery plugin and thought to yourself “damn! I’m using MooTools!” or perhaps the other way around? That highlights the problem right there, we should have no “jQuery plugins”, no “Dojo modules”, just simply “components” that we can all consume.

        Components could then utilize these smaller, more modular dependencies to perform tasks. Instead of requiring jQuery as a dependency to convert a string of HTML into elements, one could simply add domify as a dependency and invoke domify(html), similar components could facilitate event handling etcetera. My point here is that ubiquitous libraries like jQuery will eventually be a thing of the past and fragmentation will hopefully decrease.

        Another thing I think we really need to avoid, is the use of pre-processed assets within components, this includes things like Stylus, LESS, Sass, Jade, CoffeeScript among others. These are all great and can increase productivity in your application, my opinion is that they do not belong in public components, they fragment the community and reduce contributions, chances are if you’re depending on these tools for UI packages your component’s scope is too large.

        A package such as “UIKit” could then simply aggregate all its parts into one convenient component for those who wish to consume the entire thing, but there’s no reason these need to live together, we’re just lacking the tools to make this convenient.

        This leads to the next issue, modernization!

        Modernization

        There are a lot great tools being produced to deal with modernization, within reason we should not have to deal with these kinds of issues at the component level. Stylesheets are particularly bad for this, libraries are either faced with using CSS preprocessors to provide vendor prefixed versions of their styles, or of course need to manually declare them. This is a huge pain, and forever changing. What do we do? Nothing!

        I strongly suggest that we write our public component stylesheets using regular old CSS. Other tools can still be utilized at the application level if you really need them. With explicit vendor prefixing out of the way we can enjoy building components since we’re not focused on vendor details (when possible), they will remain light-weight, and customizable via consumer manipulation via a library such as CSSOM or node-css.

        On to the next topic! Structural styling.

        Structural styling

        Structural styling is another thing I frequently have issues with. JavaScript libraries, jQuery plugins and others often ship with stylesheets, this is great but these libs should only define structural styles.

        What do I mean by “structural styling”? Take for example the Dialog from UIKit, it contains only styles necessary to make the component presentable, but does not force a ton of extra styling on you, and serves as a good base to build on. I even took this a little far, box-shadows etc should be omitted by default.

        The basic idea here is let stylesheets be stylesheets, application should define the look and feel of things, if you must provide “themed” versions simply have a component named “dialog-dark-theme” with only a stylesheet in it, and so on.

        package.json

        Components could have a “component.json” much like the commonjs package.json, or we can simply extend package.json. This would of course act as the package manifest, letting the world know if it has stylesheets, templates, scripts, images and so on. I believe we should avoid the minimal gains of magical auto-globbing of files, we can just simply list these and avoid unnecessary complexity and I/O.

        A Dialog component would simply look like the following, nothing fancy here, just an explicit manifest.

        {
           "name": "dialog",
           "version": "1.0.0",
           "scripts": ["index.js"],
           "styles": ["dialog.css"],
           "templates": ["dialog.html"]
        }
        

        The reason I would name these styles, and templates instead of css and html would be that when using private components within your application, the build tool could simply sniff out things like ["login.jade"], realize it’s a Jade template and compile it appropriately. Like I’ve mentioned though I dont think these tools belong in public code.

        It may also be useful in the future to define optional dependencies for legacy browser support. Suppose I dont care anything below IE 9, I should be able to tell the build system that I’m fine with omitting legacy functionality, and the packages that handle this sort of things for events, the DOM etcetera would simply not load those in, the APIs that those modules provide would remain identical.

        Require fragmentation

        Another huge issue in the community right now is fragmentation regarding javascript loader definitions, the most common probably being AMD. Personally I’m not a fan of AMD for one reason, it’s ugly.

        Granted that’s not a very good reason to dislike something. AMD provides the nice benefit of working without a build step, however when you need a library to test out a script anyway I feel like a quick build step to convert the more convenient commonjs require() style wins here, at least for me.

        The real problem today is that if you want to share your public client-side code, you end up with something like the following:

          // AMD support
          if (typeof define === 'function' && define.amd) {
              define(function () { return Cookies; });
          // CommonJS and Node.js module support.
          } else if (typeof exports !== 'undefined') {
              // Support Node.js specific `module.exports` (which can be a function)
              if (typeof module != 'undefined' && module.exports) {
                  exports = module.exports = Cookies;
              }
              // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
              exports.Cookies = Cookies;
          } else {
              window.Cookies = Cookies;
          }
        

        This sucks. I hope to never look at this, nor support this sort of concept ever again! This is really painful. I completely understand that perhaps AMD nor sync-style requires are perfect, but if we pick one we can easily translate scripts to an async style for production builds if necessary.

        Delivering components

        We’ll obviously need a way to store and deliver components, existing tools are close but I think we can still do a little better and think a little larger.

        Package managers

        Tools like node’s npm(1) package manager are again very great, but there are several reasons I think these packages should not live in the npm registry.

        The first reason being that not everyone uses node, only us as node developers can be convenienced by using it, other communities should be able to easily access and consume these components with whichever tools they prefer, or if they really want to use one written in another language then sure why not!

        Client-side packages in the npm registry are ambiguous, without tagging them as such it’s unclear which are intended for which environment. Many packages also end up disambiguating with a suffix, for example debug works both on the client and in node, however without augmenting package.json one would need to publish “debug” and “debug-component” or similar to the registry.

        Another reason is that the package manager simply should not matter, and it usually does not matter. You just want some packages on your local machine, these should absolutely be as decoupled as possible.

        Component registries

        Arguably the best registry would simply be Github, or git repositories in general. There are a few downsides to this of course:

        - even shallow clones can be slow
        - coupled with git both at the consumer and producer levels
        - large dependency urls (unless we default github to "username/project" etc...)
        

        Some nice benefits as well:

        - clear & explicit dependency origins
        - github is awesome
        
        Utilizing components

        Most “real” applications require build steps these days, however even with this being the case, build scripts are extremely implementation specific and may vary greatly for your private application(s) depending on the scope of the project.

        Here I would propose a free-for-all, use whatever you like from whichever community you’re a part of. As long as the “package manager” can transfer these to your machine, you do whatever you need to integrate them into your application, the details here are largely irrelevant.

        Components in practice

        Traditionally most applications (that I’ve experienced) are built in more of a “vertical” approach, spreading a single concept into multiple sections of an application. Making the application, and the components of a specific feature very difficult to reason with. This is akin to how unix libraries splatter themselves all over your system into various directories and files.

        At LearnBoost we’ve been using components for a while now, but like I’ve mentioned not only for abstract UI components, but for everything in our application, even the build system and application bootstrap are implemented as components.

        What does look like? Nothing more than a simple list of directories as shown in the following screenshot. Each component here is comprised of any combination of server-side logic, styles, scripts, images, fonts and so on.

        Beyond obvious organizational benefits this helps our team focus on specific tasks without stepping all over each other. Testing is also easier, as each component providing server functionality simply exports a fully self-contained express application, which has its own set of tests, then our root make test iterates those.

        Our build system simply produces the output scripts and styles that we need into our root ./public directory, wrapping scripts with commonjs require()s, images, fonts and other assets are served from the self-contained servers.

        My point here is that this concept goes beyond public components. Obviously it would be next to impossible, and ill-advised to start sharing components with server portions, but for your own application sticking to whatever language / platform you’re using it works very well.

        What next?!

        Keep building! The JavaScript community has been moving in great directions lately, take what I’ve said with a grain of salt but I hope to see some attempts at “component” management, not just JavaScript ;)

        Until then you may want to keep your eyes on https://github.com/component for future work from us at LearnBoost in regards to this topic. EDIT: I’ve started a component wiki where we can toss around ideas.

        EDIT: Work on the component(1) executable have begun, as well as a JavaScript implementation of a builder for components, aptly named component/builder.js. For now component-build(1) is shipped with component(1) to ease use, otherwise the tools are not coupled. For example you could use `component(1) to perform installation and then use builder.js directly in code and customize your build, use the command, or use an entirely custom solution if you wish. I’ve started documenting some frequently asked questions, and we’re starting a Wiki page listing some of the components available so far, with well over 70 within the last month or so we’re off to a good start!

          Carregando...