Javascript beyond the browser

As a web developer, i am using javascript on a daily basis.
I use it to manipulate elements in the DOM, set css properties, animate objects, interact with user elements, etc. etc.
Now i can’t say that i’m a true javascript ninja, but let’s say javascript and i get along pretty well. I like writing javascript; it’s a flexible, easy to write language, and there are some excellent frameworks that makes life a whole lot easier. Especially when writing cross-browser compatible code.

All the above mentioned usage of javascript is from within the browser, on the client side.
About a couple of weeks, click-happy as i am with links on Twitter i stumbled upon this talk about Node.JS by Ryan Dahl on Ontwik (great website for technical screencasts!).

Now the first thing that got my attention was that Ryan was visibly nervous, and i wanted to see how he made it through the hour. But soon the contents of this talk became my main point of attention. It’s very interesting how Node.JS’ approach to I/O operations leads to high scalability in terms of concurrent users. Now if you are interested in Node.JS specifically, i would suggest viewing this talk, and i’m not going into details in this post.
(Although Node.JS is on my “things to write about” list)

A week or two after that, i was experimenting with PhoneGap, an “Open Source framework for building cross-platform mobile apps”. PhoneGap enables a developer to create mobile apps (for iOS, Android, Symbian, Windows Mobile, BlackBerry and Palm) using HTML, CSS and javascript.
Now the best thing is you can still use platform specific core features like camera, contacts, geolocation or network.

After playing around a bit i got this great idea about using my laptop’s browser, a Phonegap app and a Node.JS server app to link up my mobile phone with my laptop. This enables real-time interaction between the two (or three, or four, or five)!! Now how awesome is that?!

First off an Android app with PhoneGap would send data from the phone’s accelerometer using ajax (but streams are excellent for this purpose aswell) to a Node.JS server application.
The Node.JS app would then broadcast it to all browser clients,  who will then *do stuff* with the data received from the phone.
Eventually i got this communication between my mobile phone, server app and browser running in real-time, which is what it was all about. Pretty awesome!

Now both of these (at least to me) ‘new’ technologies put javascript in a whole different perspective for me. I already knew the javascript language, but didn’t realize it has a lot more potential than just manipulating the DOM.

The use of javascript outside the browser has been a trending topic for quite some time now, but i’ve always been a bit in doubt of how this would be a good addition to our current stack of of tools, and how it would make a developer’s life easier.
Node.JS and PhoneGap proved to be very easy to use, and opened a new perspective of interaction to me.
Profit++!

If you know how to write javascript, don’t limit yourself to the browser!