node.js

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

node.js

Post by Jackolantern »

Does anyone here have experience with node.js? I had heard the name over and over, but I was always getting a rather shallow, bland answer as to what it was: "It is server-side Javascript". That answer was rather unappealing to me, as I have always had my stylistic difference with Javascript and was in no hurry to change to it from PHP or .NET.

But now, after looking into it more (which was prompted after seeing about my 100th WebSocket server made in it, and almost no WS servers made on other platforms), it looks interesting! It really seems to have 2 different goals: to be a scalable web application server, and to be a real-time server (sockets, Comet, etc.). And the latter is by an event system rather than through threads. So part of node's entire existence is to be a real-time server! And Socket.IO just looks awesome! If WebSockets are not available, it starts rolling through other options automatically, from Flash sockets, to Comet, etc.

So maybe .NET or Java isn't the way to go to make complicated real-time online game servers to back HTML5 games. I started getting a bit concerned when I was reading how much you have to do on the server-side to ensure you can work with older WebSocket protocols. I don't know if that is straight-forward in another platform such as .NET or Java (I know it is possible, since both do have WebSocket servers, but I was not sure if it was the easiest way).

So does anyone have any practical experience or tips for using node.js? Are there any good development packages like WAMP is for PHP/Apache/MySQL? I picked up a book (Paktpub Node Web Development) and am planning on looking in to it. I may need to brush up again on OO Javascript, as I experimented with it a while back but have forgotten a lot about how to work with Prototypes, chaining, etc.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: node.js

Post by Chris »

node.js is my new best friend. I also recommend you look up Express framework and also CoffeeScript, it's its own language that compiles to JavaScript. Comes with a lot of cool libraries too.

http://jashkenas.github.com/coffee-script/
http://expressjs.com/

Also check out Mongodb
http://www.mongodb.org/downloads#

The first best part of node.js is you don't need apache anymore.. 6 lines of code and your server is online. It also works great on windows. Just download the .exe

I was thinking of starting a few tutorials next week over the autumn holiday. Maybe write halls that free chat he was looking for..
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: node.js

Post by Jackolantern »

Wow, thanks! And Ooooo, it has its own language that compiles to Javascript? Does it have traditional OO capabilities? Dear lord how I would love to not deal with prototypes and all that jazz!

EDIT: I checked it out, and it does still seem to us the JS OO model, which is alright. I just need to get back into the JS OO game and relearn how to use it lol.
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: node.js

Post by Jackolantern »

Hey Chris, I have a question: I don't have a Linux box and am using Windows 7. node.js seems very Linux-oriented, and while it is cool that there is a version for Windows, it appears there is not a version of NPM for Windows (well, there is an "experimental" one, but I don't really want to try that one lol). Do you have to have NPM? I know it is a package manager, but can I manage them through the node executable itself? Thanks!
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: node.js

Post by Chris »

I develop on a CentOS vm. Also have a CentOS vps.. So actually do very little with windows.

Don't know if you've seen this already but might be worth a try:
http://icewalker2g.wordpress.com/2011/0 ... needs-npm/
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: node.js

Post by Jackolantern »

Exactly what I was trying to find! Awesome, and thank you!! :)
The indelible lord of tl;dr
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: node.js

Post by Jackolantern »

I am getting a little disheartened with node for Windows. I keep finding all these posts with people talking about things that aren't in the native windows version yet. So I downloaded Virtual Box and am in the process of downloading a Linux distro to create a virtual machine to work with, at least until Windows support catches-up (hopefully by the end of the year). I will see how that goes, probably tomorrow.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: node.js

Post by hallsofvallhalla »

I would LOVE to see some tutorials on this!
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: node.js

Post by Chris »

Okay well then lets get writing :P
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: node.js

Post by Jackolantern »

Hmm...the Virtual Box was hopelessly slow. Lumping on top of that that I don't know Linux very well and would be trying to learn it, it is just too much that way. I am going to work towards getting a used computer to act as a Linux box, or if I can find my Windows disc I may partition my current desktop and set it up to dual-boot.

Bottom-line is that I am going to need a real Linux installation to continue further with node.
The indelible lord of tl;dr
Post Reply

Return to “Coding”