Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,652 members, 7,801,899 topics. Date: Friday, 19 April 2024 at 04:47 AM

Nodejs Viable In Nigeria ? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Nodejs Viable In Nigeria ? (3099 Views)

Angularjs, Laravel, Magento, Twitter Bootstrap, Nodejs Are Some Of My Skills / Javascript With NodeJS (2) (3) (4)

(1) (2) (Reply) (Go Down)

Nodejs Viable In Nigeria ? by Nobody: 6:56am On Nov 15, 2013
I got a mail from a friend; who wanted me to join the team on NodeJS Development; let's leave the full details anyway; i explained not being around and advised to look around in Nigeria online for Node Devs; and he complained about almost "Non-availability" compared to PHP; my question are there much devs in Nigeria considering NodeJS and if not; why because NodeJS is the lighter and less resource intensive option to PHP. A number of startups are looking at NodeJS; and is there anyway we can create a NodeJS awareness and adoption on NL. Because having played with it; its really something else

1 Like

Re: Nodejs Viable In Nigeria ? by dwittyc0der(f): 9:20am On Nov 15, 2013
Holla me smiley ..... am a NODE.js fan ... thanks to my brother NEDY grin grin grin grin
pc guru: I got a mail from a friend; who wanted me to join the team on NodeJS Development; let's leave the full details anyway; i explained not being around and advised to look around in Nigeria online for Node Devs; and he complained about almost "Non-availability" compared to PHP; my question are there much devs in Nigeria considering NodeJS and if not; why because NodeJS is the lighter and less resource intensive option to PHP. A number of startups are looking at NodeJS; and is there anyway we can create a NodeJS awareness and adoption on NL. Because having played with it; its really something else
Re: Nodejs Viable In Nigeria ? by Nobody: 9:29am On Nov 15, 2013
First I will load some NodeJS Books here but i want to know if that's appropriate i don't want to be called a name; then will we can discuss NodeJS toolsets and don'ts and dos, and also it be glad to have worldbest here; because working in a community pays better who knows we can create a better community for devs with chat and all; cuz NL kinda is limiting.

2 Likes

Re: Nodejs Viable In Nigeria ? by Nobody: 10:37am On Nov 15, 2013
oh well if its okay just let me know if not; i will just advise you buy the books and we continue from there, but first anyone with prior experience on Node before we start

2 Likes

Re: Nodejs Viable In Nigeria ? by dwittyc0der(f): 1:01pm On Nov 15, 2013
Alright i get books on node.js ! i love d shhit cheesy cheesy
pc guru: oh well if its okay just let me know if not; i will just advise you buy the books and we continue from there, but first anyone with prior experience on Node before we start
Re: Nodejs Viable In Nigeria ? by Nobody: 1:13pm On Nov 15, 2013
Okay Installation also i don't know shit about NodeJS on Windows only Linux; and i have no interest on Node development on windows so if anyone can assist with windows development it'd be great. to install on Linux its best to use chris's repository which is found here:


deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu quantal main
deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu quantal main


To install you need to use the Aptitude command


sudo apt-add-repository deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu quantal main
sudo apt-get update
sudo apt-get install nodejs


Another required IDE is Sublime Text 2/3 and ensure to have the Package Control installation; you can go to wbond to have that installed ; from there you get access to numerous NodeJs packages which are vital to this, also note that am not an expert on Node but only on javaScript but i do use Node and have no problem with it; the major criteria is understand Evented Programming and Asynchronous Methods,Callbacks and JavaScript Closure and yes another important thing is also CommonJS (this is the preffered style of coding Js compared to AMD)

1 Like

Re: Nodejs Viable In Nigeria ? by Ajibel(m): 2:29pm On Nov 15, 2013
@pc guru, what fascinates you about node.js I was also introduced to it via worldbest last year buh it didn't tickle my fancy after downloading and going thro' it a bit :-/
Re: Nodejs Viable In Nigeria ? by Nobody: 2:36pm On Nov 15, 2013
Ajibel: @pc guru, what fascinates you about node.js I was also introduced to it via worldbest last year buh it didn't tickle my fancy after downloading and going thro' it a bit :-/

shocked shocked shocked shocked shocked shocked shocked shocked shocked shocked shocked shocked shocked

1. Imagine creating an HTTP Server in JavaScript.
2. Creating a socket and real time connection on PHP is difficult, you might be used to twisted on python imagine NodeJS as the better version of twisted.
3. Expose C++ Objects which will be consumed by JavaScript meaning you can have C++ apps behind the scene
4. Minimal use of resources PHP and others spawns god knows how many thread to request, but JavaScript is single threaded meaning it can handle many concurrent request.

The List is long but the best option so far ability to build a web server in JavaScript with Asynchronous style, obviously you should know that building real time apps on PHP is flawed because PHP is blocking.

Here are some demos

Take a lot at this entries; its superb for I/O Operations e.g imagine have a 3D Multiplayer Game online using NodeJS for the server to handle the request at the same time;
http://nodeknockout.com/entries

1 Like

Re: Nodejs Viable In Nigeria ? by greenPHP(m): 9:15am On Nov 19, 2013
I am following?
Hitting us with node again when your head is full of javascript and PHP @ PC guru.
Hoping to do nodes someday.
Re: Nodejs Viable In Nigeria ? by Nobody: 9:57am On Nov 19, 2013
greenPHP: I am following?
Hitting us with node again when your head is full of javascript and PHP @ PC guru.
Hoping to do nodes someday.

Actually i do C# and Processing and other stuff, but i believe in specialization which is JS,PHP and Processing.

1 Like

Re: Nodejs Viable In Nigeria ? by Nobody: 10:00am On Nov 19, 2013
Today we get to talk about Asynchronous i will explain in a short word.
//PHP
$file_get_content('porn.flv');
echo "Hello";
//Hello Here prints after file has been loaded

//NodeJS
(require('fs')).readFile('porn.flv',function(){console.log('Done')});
consoel.log('Hello');
//Hello Prints first before the file has been loaded which brings us to two concepts


1. Asynchronous
2. Callbacks
Re: Nodejs Viable In Nigeria ? by Nobody: 10:02am On Nov 19, 2013
From Microsoft

Asynchronous programming in JavaScript (Windows Store apps)
JavaScript is a single-threaded language. This means that invoking a long-running process blocks all execution until that process completes. UI elements are unresponsive, animations pause, and no other code in the app can run. The solution to this problem is to avoid synchronous execution as much as possible.

One way to do this is to have a function execute at a later time, as with event handlers, which are invoked after another call has raised an event. Callback functions are another kind of asynchronous processing, because they call back into the code that initiated the process.
Problems when using asynchronous programming

Asynchronous programming can quickly become complicated. Many of the standard JavaScript APIs rely heavily on callbacks, which are often nested, making them difficult to debug. In addition, the use of anonymous inline functions can make reading the call stack problematic. Exceptions that are thrown from within a heavily nested set of callbacks might not be propagated up to a function that initiated the chain. This makes it difficult to determine exactly where a bug is hidden.

Asynchronous programming in Windows Store apps that use JavaScript
Windows Runtime and Windows Library for JavaScript provide a way to overcome these problems by implementing the Common JS Promises/A proposal. A promise object returns a value at some time in the future. You can use these objects to construct chains of asynchronous code that are easier to read.
All of the Windows Runtime APIs that are exposed to Windows Store apps are wrapped in promise objects. This allows you to use Windows Runtime APIs in a way that you're comfortable with. The promises in WinJS are important because many interactions with Windows Runtime are asynchronous.

Promises explained
A promise is an object. The most frequently used method on a promise object is then, which takes three parameters: a function to call when the promise completes successfully, a function to call when the promise completes with an error, and a function to provide progress information. In both the Windows Runtime and the WinJS you can also use the done function, which takes the same parameters. The difference is that in the case of an error in processing, the then function returns a promise in the error state but does not throw an exception, while the done method throws an exception if an error function is not provided.
Let's look at a basic example of a promise with two (made-up) asynchronous methods, one to call a web service and another to store the results in a database.
JavaScript

myWebService.get("http://www.example.com")
.then(function(result) {
return myDb.add(result);
})
.then(function() {
console.log('data successfully saved');
}, function(error) {
console.log('an error occurred while saving:');
console.dir(error);
});


You append the then function to the myWebService.get method. Since this method returns a promise, you can append a second then function to the myDb.add method, and handle any errors in the error function you pass to the second then function.
You can also group multiple promises. For example, you can use the join function to run multiple asynchronous operations that call several web services and then aggregate the results.
JavaScript

function loadData() {
var urls = [
'http://www.example.com/',
'http://www.example.org/',
'http://www.example.net'
];

var promises = urls.map(function (url) {
return myWebService.get(url);
});


WinJS.Promise.join(promises).then(function () {
//do the aggregation here.
});
}


First we create an array of URLs, then we use the Array.map function to convert the array of URLs into an array of promises (because mywebService.get returns a promise). Finally, we use the join function, which accepts an array of promises and returns a new promise after all of the promises have completed. We do the data aggregation inside the complete function of the then method.

The Same Concept applies

2 Likes

Re: Nodejs Viable In Nigeria ? by Nobody: 10:07am On Nov 19, 2013
Another thing i noticed was i could run PHP code on terminal in a child process and communicate with my terminal via my parent process or even pipe all the response to a text. WTF
Re: Nodejs Viable In Nigeria ? by Nobody: 6:56am On Nov 20, 2013
Today we will look at Callbacks
Re: Nodejs Viable In Nigeria ? by Nobody: 7:04am On Nov 20, 2013
This Article best explains the Callbacks, these are vital for us before touching NodeJS
http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
Re: Nodejs Viable In Nigeria ? by greenPHP(m): 7:15am On Nov 20, 2013
Following
Re: Nodejs Viable In Nigeria ? by CODEEATER(m): 7:58am On Nov 20, 2013
When I learn this thing,m gona create something massive with it...d idea is fully ready, jst missing the knowledge
Re: Nodejs Viable In Nigeria ? by Nobody: 8:04am On Nov 20, 2013
CODE-EATER:
When I learn this thing,m gona create something massive with it...d idea is fully ready, jst missing the knowledge

You know JavaScript ? if yes send me your mail, there's a book i can send to you, read it and in 2 days i could get the underlying concept frm it, its striaght to the point
Re: Nodejs Viable In Nigeria ? by CODEEATER(m): 8:45am On Nov 20, 2013
pc guru:

You know JavaScript ? if yes send me your mail, there's a book i can send to you, read it and in 2 days i could get the underlying concept frm it, its striaght to the point
Yea...to an intermediate level.... As 4 my mail,mail me tru NL mail,I dont want to post it publicly
Re: Nodejs Viable In Nigeria ? by Nobody: 8:49am On Nov 20, 2013
CODE-EATER:

Yea...to an intermediate level.... As 4 my mail,mail me tru NL mail,I dont want to post it publicly

Everytime i respond to a mail , a mailer daemon appears
Re: Nodejs Viable In Nigeria ? by Nobody: 1:34pm On Nov 21, 2013
Today we will talk about CommonJS which NodeJs is based on, a bit like Python and also similar to AMD here are the api of the CommonJS module package:

Require



// package/lib is a dependency we require
var lib = require('package/lib');

// some behaviour for our module
function foo(){
lib.log('hello world!');
}

// export (expose) foo to other modules
exports.foo = foo;
Re: Nodejs Viable In Nigeria ? by Nobody: 1:38pm On Nov 21, 2013
The Require function loads a module which is basically a 'JavaScript Source File' .js however compared to JavaScript on the Frontend which loads all Global Objects on the Window, there's no Window Object here thus making global pollution almost impossible, the lib will contain the module resolved by the require function, this makes it easier to separate your codes and load it easily, and multiple use of require calls once and caches the module, saving expensive calls. before explaining the exports let's look at 'package/lib'

1 Like

Re: Nodejs Viable In Nigeria ? by Nobody: 1:50pm On Nov 21, 2013

function Util(){

this.log=function(){
console.log('Logged');
}
}

module.exports=new Util;
Re: Nodejs Viable In Nigeria ? by Nobody: 1:52pm On Nov 21, 2013
This simply creates a Function (First Class Object), defines a log method however because we want this module to return an instance for the user we return a new Util because we are using the Pure Function you can return whatever you like if i had return Util, then i would have had to do a new lib() before accessing log.
Re: Nodejs Viable In Nigeria ? by Nobody: 1:57pm On Nov 21, 2013
function Util(){

this.log=function(){
console.log("Logged');
}
}

return new Util();


This returns an empty object
Re: Nodejs Viable In Nigeria ? by Nobody: 2:06pm On Nov 21, 2013
module.exports.debug=new Util;


Rename this means to access this it becomes

lib.debug.log();


For now try this out and practice before moving forward also i'd like some feedback i feel am writing this for myself
Re: Nodejs Viable In Nigeria ? by curiouslad(m): 10:18pm On Nov 21, 2013
pc guru:
module.exports.debug=new Util;


Rename this means to access this it becomes

lib.debug.log();


For now try this out and practice before moving forward also i'd like some feedback i feel am writing this for myself

You lost me after promises embarassed
Re: Nodejs Viable In Nigeria ? by Nobody: 6:54am On Nov 22, 2013
curiouslad:

You lost me after promises embarassed

A Promise is an Object that holds the result of an async task e.g when you run an Ajax in Jquery there is a success and function however in Promise, its an Object that has two aspect the error the success and the then, error when an error triggers and success when the result is ok, the then will run regardless of the two state its the last method, also there's a Whenable Object it takes a Promise, meaning when the promise has been resolved it calls. in short words it contains result of async tasks
Re: Nodejs Viable In Nigeria ? by curiouslad(m): 10:57am On Nov 22, 2013
pc guru:

A Promise is an Object that holds the result of an async task e.g when you run an Ajax in Jquery there is a success and function however in Promise, its an Object that has two aspect the error the success and the then, error when an error triggers and success when the result is ok, the then will run regardless of the two state its the last method, also there's a Whenable Object it takes a Promise, meaning when the promise has been resolved it calls. in short words it contains result of async tasks

I do understand promises - via angularJs.
You lost me at the commonJs, reading up on it though. Might have to actually delve into nodeJs
Re: Nodejs Viable In Nigeria ? by Nobody: 12:23pm On Nov 22, 2013
curiouslad:

I do understand promises - via angularJs.
You lost me at the commonJs, reading up on it though. Might have to actually delve into nodeJs

sorry i have that bad habit of not explaining why, CommonJs is just a spec that allows JavaScript to be in Packages just like java, that's the best definition. Sure no problem, am curious how is AngularJS am more of Dojotoolkit Fanatic and never bothered to touch any other JS Framework except jquery(which i hate).
Re: Nodejs Viable In Nigeria ? by curiouslad(m): 12:53pm On Nov 22, 2013
pc guru:

sorry i have that bad habit of not explaining why, CommonJs is just a spec that allows JavaScript to be in Packages just like java, that's the best definition. Sure no problem, am curious how is AngularJS am more of Dojotoolkit Fanatic and never bothered to touch any other JS Framework except jquery(which i hate).

AngularJs is cool, easy to start with, can be tough to wrap the head around uphill but definitely worth it. It actually implements its own jQlite version of jQuery.

Angular is modular and implements dependency injection, so i can inject modules/libs where needed at runtime rather than 'require'ing them.

Still following this page though
Re: Nodejs Viable In Nigeria ? by Nobody: 1:08pm On Nov 22, 2013
curiouslad:

AngularJs is cool, easy to start with, can be tough to wrap the head around uphill but definitely worth it. It actually implements its own jQlite version of jQuery.

Angular is modular and implements dependency injection, so i can inject modules/libs where needed at runtime rather than 'require'ing them.

Still following this page though
Di in JavaScript never knew of that, CommonJS is almost like that than AMD you can still use your AngularJs with Node, Node is just for the backend

(1) (2) (Reply)

A Call To Game Developers! / How To Say "Hello World" In Different Programming Languages / Efficient Training For A Career In Software Development

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 57
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.