Since deciding to use WebSockets instead of AJAX calls with Node.js I have discovered some interesting things. Some of these things are good, and some are bad.
Tag: Web
Asynchronous Loops in Node.js Are Driving Me Loopy
Node.js is great at times, but in some ways it’s a real pain in the ass.
Sure, it can create WebSocket servers, and it seems to be on the cutting edge of everything, but try to update an array of objects in a database then output a message and you’re in trouble.
AJAX vs WebSockets
I’m in the process of converting a web application from an Apache + PHP backend to Node.js. The application being converted is based heavily around real time interaction between users, so, it was a natural fit for WebSockets.
In fact the old application used a Node.js backend for WebSockets, but an Apache + PHP backend for everything else, including page generation and AJAX endpoints. This means every AJAX driven form had a PHP endpoint which performed a desired action and a WebSocket event listener waiting to broadcast the event to other users.
Having to recode this application from the ground up in a new asynchronous language presented an interesting question to me.
Why should I use AJAX when I have WebSockets?
Which Server Side Language is Right for You?
One of the biggest hangups I had when starting to program was deciding what technology to use. At the time I was only writing server side code and was working in shared hosting, so my options were limited to various versions of PHP.
Within the last year I started using cloud hosting and thus gained the ability to configure my servers to use any language I wanted. Shortly after realizing this a small amount of fear came over me. The choice of language wasn’t made for me anymore, I would have to pick from a giant pool of languages. I would also be spending at least three months learning all about this language I picked before I would feel secure in it. After that three months I might not like it and would have wasted three months of my life.
At the time I was doing a lot of freelance and was instructor at a college teaching web development. Because I was teaching I wanted to know the basics of all the languages I could use on the server, just in case my students asked me about them.
I knew the basics of most of these languages but I had never written anything substantial in them. So, over one long weekend I locked myself in a room and started writing hello world, testing frameworks, making CRUD, overall building projects in every language and every framework I could get my hands on.
Four days later here are the four things I learned.
Cross Browser Voice Recognition with PocketSphinx.js
For several months I have wanted a cross browser voice recognition system that doesn’t rely on a server, use browser plugins or extensions, or use external programs like Flash. Something that could continually listen for keywords and trigger functions when one is detected. I looked into the webkitSpeechRecognition()
object in Chrome, but unfortunately that relies on Google servers and is only available in Chrome. I looked into building extensions and plugins for Firefox and Chrome that package CMU Sphinx, but that is not native code. I even got voice recognition working in Flash, but wasn’t happy because it didn’t work on my Android device.
After months of looking I have found one that fits the bill completely and is really awesome.