Node即学即用

最新书摘:
  • [已注销]
    2012-05-18
    Depending on your application, you can pick either a widely deployed algorithmsuch as MD5 or (preferably) the newer SHA1, or a less universal but more hardenedalgorithm such as RIPEMD, SHA256, or SHA512.
  • [已注销]
    2012-05-18
    Because Node relies on an event loop to do its work, there is the danger thatthe callback of an event in the loop could run for a long time. This means that otherusers of the process are not going to get their requests met until that long-runningevent’s callback has concluded
  • [已注销]
    2012-05-18
    One of the challenges of writing a book is trying to explain things in the simplest way possible.
  • [已注销]
    2012-05-18
    This means that you should follow two strategies when writing a Node.js server:• Once setup has been completed, make all actions event-driven.• If Node.js is required to process something that will take a long time, considerdelegating it to web workers.
  • [已注销]
    2012-05-18
    A 3Ghz processor runs 3×109 instructions a second, so each instructiontakes 10-9/3 seconds each. There are typically two types of memory in a CPU, L1 andL2 cache, each of which takes approximately 2–5ns to access.
  • [已注销]
    2012-05-18
    One of the criticisms leveled atNode.js fairly often is its lack of “concurrency.” That is, it doesn’t use all of the CPUson a machine to run the JavaScript. The problem with running code on multiple CPUsat once is that it requires coordination between multiple “threads” of execution.
  • [已注销]
    2012-05-18
    Partials are mini-templates for code that is expected to repeat again and again with different data.
  • [已注销]
    2012-05-18
    Example 2-17. The basic folder structure of an Express app.├── app.js├── public└── views └── partials
  • [已注销]
    2012-05-18
    The first thing we should do is install the Express module (Example 2-13). This webframework for Node makes it much easier to create web applications by adding supportfor common tasks, such as MVC, to the existing http server.
  • [已注销]
    2012-05-18
    We should fix this in two ways. First, we should make sure that when a client disconnects,we remove it from the clients array so it stops getting write() method calls.。。。Second,we should be a bit more defensive when we write to a socket.
  • [已注销]
    2012-05-18
    In 2012, we now have a proliferation of JavaScript experts advocating well-written,performant, maintainable JavaScript code. People such as Douglas Crockford, DionAlmaer, Peter Paul Koch (PPK), John Resig, Alex Russell, Thomas Fuchs, and manymore have provided research, advice, tools, and primarily libraries that have allowedthousands of professional JavaScript programmers worldwide to practice their tradewith a spirit of excellence. Libraries such as jQuery, YUI, Dojo, Prototype, Mootools,Sencha
  • [已注销]
    2012-05-18
    To overcome all doubts, I needed a demo in 10 days. I worked day and night, and consequently made a few language-design mistakes (some recapitulating bad designpaths in the evolution of LISP), but I met the deadline and did the demo.