Thursday, June 19, 2014

Day 28: Javascript libraries and intro to node.js

After tackling a bunch of javascript challenges and learning a bunch of cool ways javascript can do animations and illustrations of data, I decided it was time to move on to the back-end.

I really needed to hit the brakes and take my time when learning node.js. It's the first time we actually learn a server languages. Previously when we were learning PHP, we were simply using Apache as a server in the MAMP stack (mac, apache, mysql, php). But this time we actually begin configuring what the server will do when a user makes an http request.

Node.js is the most effective in situations when a two-way (or more) connection has to be persistent. Because of the nature of Javascript and how it's event-based, it runs continuously rather than other languages that stop running once the code is finished. Javascript and node continuously are listening for event that will trigger other events.


Here I have my node server listening for events on port 7077. Whenever a user makes a request to localhost:7077, the server acts accordingly.


And here is my server-side code, telling the program what to render depending on what the request url is.

Once again, nothing flashy here because we're dealing with server-side but node.js has seriously optimized the speed at which content can be delivered. Really excited to be diving deeper in this topic.

No comments:

Post a Comment