The biggest thing I had to learn was npm, the Node.js Package Manager, which makes adding features to Node.js pretty simple.
Now, to rewind just a bit, I’ve also recently been trying to learn Python, and the first thing you learn about Python is that if you want to do it, someone else already has, so just install the package and use their framework. But I’m still learning Python’s syntax.
But it was a simple matter of learning that single process, and after that I was able to port the entire concept into a project.
Whenever I learn a new language, or a new system like Node.js, I do the requisite “hello world” examples, but then I say, “Ok, I’m going to spend some time and put together a project.” I do this so I can feel it, I can feel how the code works top to bottom, and see the errors, handle the errors, and find the work around that I’m going to need when I tackle it in a production environment.
So I did it, it took me about an hour, and I had a very basic Node IRC Bot running. It did nothing but greet itself when it hit the room, but it was able to join and stay alive without issue. I did this by using the Node IRC package.
But, I wanted more. That was simple, and it made me really want to expand my knowledge.
Since I was 13 or so I’ve been in love with the concept of artificial intelligence, specifically neural networks. I’ve had this idea for a while to learn how to build a proper neural network, but I had yet to find a neural network framework that allowed it. FANN — Fast Artificial Neural Network — is a C neural network framework that has many ports, but none had been put together and easily documented enough for me to learn.
Then I found Node FANN. Node FANN was a Github project I found that wasn’t documented at all, but the code was readable, so I was able to figure it out.
So I ended up spending the weekend adding a Neural Network to this IRC Bot. What it does now is joins a channel, and builds the nick list. It then randomly selects anyone in the channel, and watches what all the people write. If the person whom it is watching speaks, it goes into training mode.
What it’s doing is using up to the 5 latest messages from other people as inputs, and training the neural network to output whatever the person the bot is watching would output.
Is this a great idea for a neural network? Hell no, it’s a horrible idea. But it was fun to write, it taught me how to convert letters to numbers without using a key map, and I was able to learn a bit about how Node works. I’d say I know Node enough now to be comfortable working with it in my day job. That’s how simple it is.
So why write this post? No reason. It’s been a while since I blogged, and I wanted to spread the love about Node.js that I’m feeling. I’m still a PHP guy at heart, but I’m adding Node.js as a permanent tool in my toolbox.
If you’d like to play around with the bot, or if you have any ideas about how to make the Neural Network work better than it does, feel free to fork my repo on Github. I’ll keep playing with it, and adding things here and there.