Really sitting down with node

For discussions about game development that does not fit in any of the other topics.
Post Reply
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Really sitting down with node

Post by Jackolantern »

I have spent the last couple of months essentially working with alternatives to Node.js because I had tried it before and did not like the coding style ("Christmas Tree Code" lol). Finally, I realized that I was tip-toeing around the real solution for what I want to do, and that it couldn't be that tough to make well-structured code with it due to all the applications and developers using it now.

Well, I have been hitting it hard the last week or so and can say I have had a breakthrough. I absolutely love node now! The real key, at least for me, was digging into modules and really figuring out how to write and use them. They were the key to writing well-structured, maintainable node code. I tackled MongoDB yesterday and today, and I can say after just that amount of time I feel comfortable that I could use it for any of my needs now. After working with MySQL for my first 2 days many moons ago I didn't even feel like I had scratched the surface, but like node, mongo is small, self-contained, JS-based, and very easy to use! I also have to say I like the standard MongoDB node driver much more than Mongoose, as the schema-based style of Mongoose is not to my liking. I can simulate schemas if I need them simply by making Mongo accessor functions inside a module.

Express is also the bee's knees! It offers what I loved about MVC web frameworks without being pretentious, forcing me to code in an overly specific way, or being overly bloated. I am using the EJS view system rather than Jade, however. I just don't like the HAML Jade style. EJS is much more like the view engines I have used in other MVC platforms and frameworks.

WebStorm has been a great help, and may even be one of the driving forces in the passion I feel for node now. Debugging works great, and is something that is quite poor in notepad-and-shell node, and that I was sorely missing before. Even not on sale, I think WebStorm is worth every penny if you plan to do node development.

After doing some more exploring of Express, it will be time to move on to Socket.io! I just wanted to give a heads-up on my experience with node so far and that I am totally feeling it now. To anyone using PHP and Socket.io together, definitely check out Express. It has a very low learning curve for an MVC framework (although it isn't fully MVC, but who's counting?), and it is just great to get the whole stack under one roof (node). :cool:
The indelible lord of tl;dr
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Really sitting down with node

Post by Ark »

Yes NodeJS is awesome, and definitely choosing a framework to load files like Express is better than do it yourself in nodeJS imo. However I haven't encountered any other framework besides Express.
Orgullo Catracho
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Really sitting down with node

Post by Jackolantern »

There are a couple of others I briefly reviewed before going with Express, but they are so distant in usage it makes a hard deal to recommend them. Express is about like Rails with Ruby. Choosing anything else is basically going against the grain.

And yeah, doing it all yourself with vanilla node really isn't an option. It isn't like developing with PHP, where you can forego a framework and use a built-in web development layer. You would have to create a system to handle session data, and would even have to create a routing system just to attach CSS and JS files to your pages, among many other things. You would have to build an entire web server system to even get started without Express.
The indelible lord of tl;dr
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Really sitting down with node

Post by a_bertrand »

I use node.js since 1 month or so (for wsirc as well as my cubicverse prototype), and I'm actually surprise by the stability of the beast. I still dislike a lot JS code syntax, even if it's powerful it's just messy by default.

My biggest fear with Node.JS is the fact they do change their core JS libs over the time, which would make your old node.js code deprecated if not simply incompatible. I know node.js is still not "released" as final product, however this is quiet of a pain.

Another thing I pretty much dislike, is all the synchronicity of node.js and the way it's coded. I mean, it's great to have async functions calls, yet some time you would need sync calls and they are simply missing. Also, async code make you work with callback functions, and... doesn't help to make your code readable. Event based languages like C# do handle this in a better way, as well as their last asyn implementation shows a much smarter approach.

Overall node.js is a cool toy, but not something I may want to use for big software development.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Really sitting down with node

Post by Chris »

Jack, could you refer to a tutorial on setting up WebStorm? I've got a load of different versions, but don't know how to set it up with libraries and debuggers. I currently use Sublime Text with some Node.js extensions, but intellisence in Sublime Text is pretty much useless.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Really sitting down with node

Post by a_bertrand »

I do work all the day with .NET and C#, and indeed it's the way to go. The only big no-no is trying to host your web application on Linux or run your .NET software on Linux. Beside that, if you host your stuff on a windows server, or run in a windows environment, it's certainly the best choice.

Yet I would pick C# and not VB, maybe for the syntax, or some goodies (even if they are nearly 1 to 1), C# speaks to me more than a VB code.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Really sitting down with node

Post by Chris »

a_bertrand wrote:I do work all the day with .NET and C#, and indeed it's the way to go. The only big no-no is trying to host your web application on Linux or run your .NET software on Linux. Beside that, if you host your stuff on a windows server, or run in a windows environment, it's certainly the best choice.

Yet I would pick C# and not VB, maybe for the syntax, or some goodies (even if they are nearly 1 to 1), C# speaks to me more than a VB code.
VB is C# but without the braces.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
a_bertrand
Posts: 1536
Joined: Mon Feb 25, 2013 1:46 pm

Re: Really sitting down with node

Post by a_bertrand »

Yes and no... there is a bit more difference than that:
http://www.codeproject.com/Articles/997 ... -NET-and-C

For example I used quiet a few time unsafe pointers to speed up some memory work, or use all the time the "using" statement, as well as many other things.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Really sitting down with node

Post by hallsofvallhalla »

Node is my hero. I would marry it if I could. I have yet to get into MongoDB but may jump into that very soon. I have some more JS and Node tutorials coming soon. Hopefully by this weekend.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Really sitting down with node

Post by Jackolantern »

a_bertrand wrote:I use node.js since 1 month or so (for wsirc as well as my cubicverse prototype), and I'm actually surprise by the stability of the beast. I still dislike a lot JS code syntax, even if it's powerful it's just messy by default.
I would like traditional OOP, as I am sure many other people would. However, the module system of Node really helps you to avoid the prototype OOP system of JS if you want to, and can provide good structure.
a_bertrand wrote:My biggest fear with Node.JS is the fact they do change their core JS libs over the time, which would make your old node.js code deprecated if not simply incompatible. I know node.js is still not "released" as final product, however this is quiet of a pain.
This is true, and I would like to know more about a roadmap to v1.0. Node is seeing such widespread usage that it really needs to settle down immediately. Of course, for proprietary code, if they ever made a breaking update, you would not need to actually download the new version, as almost all of the older versions are easily available.
a_bertrand wrote:Another thing I pretty much dislike, is all the synchronicity of node.js and the way it's coded. I mean, it's great to have async functions calls, yet some time you would need sync calls and they are simply missing. Also, async code make you work with callback functions, and... doesn't help to make your code readable. Event based languages like C# do handle this in a better way, as well as their last asyn implementation shows a much smarter approach.
Check out Promises for Node.js. It is a way to make the async nature of node more flexible. However, there are modules that do all kinds of craziness with node's async functionality, including emulating .NET async with await(). Callback nesting is just the fastest and easiest way to handle async calls, but it definitely isn't the only way. There are even threading systems for node.
Chris wrote:Jack, could you refer to a tutorial on setting up WebStorm? I've got a load of different versions, but don't know how to set it up with libraries and debuggers. I currently use Sublime Text with some Node.js extensions, but intellisence in Sublime Text is pretty much useless.
Provided you are using the newest WebStorm, Webstorm 6, much of the set-up is done for you when you install it. I am not sure about WebStorm 5, but I believe the node support is quite unrealized there (basically just a simple connection to the node runtime). While it can require a bit of clicking around, the WebStorm documentation is the best resources I have found for getting started with node and Webstorm. A couple of things I have found in my usage of it though:

1. If you are not making an Express app, simply start a JS project. Click the green NodeJS "JS" icon on the toolbar, and setup a configuration with the path to node.exe and a bit of other info. You will then be able to debug and run your app through WebStorm.

2. If you use EJS instead of Jade, the *.ejs filetype is not bound in WebStorm. Go to File >> Settings >> File Types >> Highlight "HTML" in the top pane >> Click the green "+" in the bottom pane and add "*.ejs". EJS views needs to be associated as HTML files.

If you need any more help with getting it setup, let me know. I can't call myself a WebStorm master at this point, but I do definitely feel like it is working with me and not against me lol :cool:
The indelible lord of tl;dr
Post Reply

Return to “General Development”