Node and NPM

Session 2015-01-05

Summary points:

We had a great session were we started talking about how to focus our sessions and we let clear
that can be very useful if we start with the doubts or questions that I have from what I’ve been studying, so
I’ll keep it in mind and we’ll come over the doubts I have.

We focused our conversation in NodeJS, started talking about were the NodeJS comes from
and the difference between synchronous and javascript asynchronous.

Synchronous is when we have to wait until one task is completed and we got the result back to continue with the next one.
Asynchronousis when once we have started one task, we can start the next one without the need of waiting for the previous one to be completed.

We commented why Ryan Dahl choose V8 from Google over other JS engines, and it was because Google is a powerful company with a lot of interest in
JS since they got Gmail, Google Maps and so many other tools running in JS.

Actually JS is getting high efficiency performance and is actually close two times slower than C for a quick comparison, php is 10 times slower than C
and Ruby is 20 times slower than C.

We checked that I have the latest (or one of the latest) versions of node installed node -v we also checked latest versions of npm npm -v.

Created a new folder to do some testing and created a new file called index.js with the content

console.log('hello world');

So at terminal we typed node index.js and the js code at the file was executed showing us the result. *Wow! we can execute at terminal the code without need of the browser to check if it works as expected, great!`.

Then we came to use the npm site and installed the colors package with the command npm install colors (now we have in this project the plugin colors installed).

then we modified the index.js file and added the following lines:

var colors = require('colors');
console.log('hello world'.cyan);
console.log('hello'.cyan, 'world'.magenta);

After running the command node index.js we saw the following result:

2874699936-Screenshot 2015-01-06 12.28.24

After checking how awesome the terminal can be, AirCrewMentor remarked how important is to test your code and how publish
this information when sending some code can really make a difference in the quality of your work and public profile.

I need to learn how to test the software and how to see if the software I am using from npm or other sources is valid or not.
It is not the same if we are using some code we got from a source where the file explains really detailed all what I can do with
this code and show the testing and the result of the testing, or how I can run the test for the software.

The documentation for the projects is really important because when I am going to use a new code, I need to be productive asap and
not loose the time reading the code and figuring out what I am able to do with it.

Well documented & tested code is a must when coding.

Next Session Objective

  • Start testing with the console the code
  • test and document the code cuanto cuesta
  • Publish it on GitHub.

Thanks Mentor, as I told you yesterday, you are keeping me really excited and motivated to keep learning. Looking forward to the next session.