Node.js Bootcamp at Microsoft
May 10, 2013 |
On Saturday, I went over to the Microsoft campus to learn about Node.js, a lightweight solution to serving requests on a webserver.
One of the features of Node.js is the ease of using sockets. Because sockets leave the connection open between the client (browser) and the server, sending little bits of data back and forth is quick and requires less resources than opening a connection for each request.
After a morning of a quick introduction to Node.js, we had an opportunity to get our fingers coding.
I was pleasantly surprised at how easy it was to get the example Matt Pardee showed us up and running. After installing Node.js on my local machine, it was a simple command line node command pointing to the JavaScript file to get it running.
If you’ve ever coded in JavaScript and used the event object, dispatching and receiving events is pretty straightforward. I really liked how I could make any custom event and attach a custom object of data that was easy to send to the server and then to all connected clients.
It actually took me many times over more time to figure out what my UI would consist of and the types of events that I would send between clients and the server. This is how it should be. The technology should never consume your time, the idea and functionality should.
Having already had an itch to scratch, the problem of multiple students in the classroom being able to communicate with a teacher in realtime, I made a quick example where students click on words in a passage (each time dispatching an event). The teacher’s screen shows realtime counts of clicks for each word, and a list of students who have clicked on that word.
One last feature I rushed before time was up was a way for the teacher to push content back to all the students, a way to begin an activity based on the feedback the students sent to the teacher.
Because there was literally about three hours of coding time, I ran out of time to bullet-proof the system.
During my demo, I invited the audience to join and pretend to be the students. Before I had even started explaining what I was showing, several members of the audience had already started clicking on words. Clicking so many times that the use case was being compromised. I believe one word was clicked on more than 70 times.
But the concept worked well. To add the cherry on top for the demo, I clicked on a word on the teacher’s screen and sent those connected a definition of that word. It was a rough prototype, but it got the point across.
I already knew the potential “abuse” allowing audience members to participate, but it was fun dealing with it and learning how to make a joke of it. I am just as guilty when given the opportunity to sabotage a speaker’s demo. In fact, Matt’s demo was “compromised” as well. It was all fun and games and actually engages the audience.
Node.js is definitely a tool I now have in my arsenal that I plan to put to use. I had always thought real-time communications between users required large servers and lots of networking knowledge. Instead, a JavaScript coder can build a game in no time and handle lots of concurrent users.