This post explains my struggles trying to get into writing NodeJs dealing with finding developer tools and support for library’s all in preparation for my a new job position that I had accepted!
About 6 months ago I decided to join a start-up that were building an application in NodeJS whilst being funded by a parent company, prior to joining I had many years of experience in many other fields mainly Microsoft tools such as the .net framework, azure and mssql but no experience with NodeJs.
A month before I joined this new company I began my journey into NodeJs, I began studying online, following tutorials and trying to feel my way around eventually I became frustrated and rage quit. I tried again and again but each time I kept reverting back to the comforts of asp.net for my web development projects.
Eventually I started my job at this new company where I found myself forced to work with node on a daily basis that I was able to gain some proper real-world experience with the platform and come up with a list of things that I believe if I had known when I started learning NodeJs I wouldn’t have given it up so easily
1. What IDE for NodeJS?
When I started this venture into NodeJs I was told by almost every blog… guide… tutorial and youtube video on the planet that sublime text 2 was as good as it gets for NodeJs ide’s sadly this was not the case, I came from a visual studio background where I had access to real-time debugging, code peeking, benchmarking and performance tools, amazing context aware code completion. I couldn’t deal with writing out the console every 3 lines of code to check what status my variables were in to debug it was driving me nuts.
That’s until I found Jet Brains Webstorm 7 this is the same IDE that Google packages with the android sdk for java, It takes a little bit of getting used to but don’t all complex applications? after spending some time with it I got my work flow sorted regained intelligent code completion and real-time debugging with features like pause and step over, step into. I HIGHLY recommend downloading the trial and giving it a shot as it will improve your NodeJs workflow 10 times over and wont make you feel like your writing your applications back in the 80’s.
2. Packages and Libraries
I got into this mindset when I started out with NodeJs that you had to write html file generates yourself using fs.readFile and regex and all sorts of complicated crap, Mainly because most of the tutorials out there start off reading html files from disk and streaming them back to the client this is WRONG. If blink tags still existed I would have wrapped that within them to emphasize my point.
NodeJs is built around packages and almost everything you’d ever want to do in an application has been done and is freely available for you to use via NPM for example.
Express / Locomotive
Express is a web application framework for NodeJs. Locomotive is built on top of express to provide you with an MVC Layer so you can organize your web app’s logic.
- This library handles everything from simple Local authentication strategy’s to complex oauth systems like facebook, twitter, openid and no joke like 140+ other providers.
- You don’t have to write api wrappers to access mongo db databases and compile the drivers yourself simply install this and you’ll get beautiful strongly typed model support coupled with advanced database querying tools.
The point I am trying to make here is that in NodeJs all your core functionality has been done for you so don’t waste time like I did learning how to use the core library’s in NodeJs and getting frustrated that its a ridiculous effort setting up and configuring http server settings then reading html files from disk, appending headers and streaming them to the client because there are absolutely 0 node developers out there right that are purely using ‘core’ nodejs
On top of all that, the three librarys i have mentioned above are basically 99% of your website done so forget about core NodeJs and go find some tutorials on locomotive. I have even written a base template which I used for my start-up http://www.siteloader.net that gets you started with Locomotive, Mongoose and Passport js called “PLEB Stack” which you can find on github here https://github.com/rm2kdev/PLEB-Stack
MVC is like the nutella you put in the bread! I cant believe how I lived without this for so long prior to my adventures with NodeJs I was mainly focused on writing asp.net object oriented web forms my only experience with the MVC was from writing crappy iPhone applications in objective-c which lead to my dismissal of the pattern because of the lets just say interesting way it is implemented.
After I had finished judging this book by its cover and given up on MVC I went back to writing my applications in object oriented asp.net web forms. Little did I know that there are about a billion implementations of MVC and objective c’s was just one that I didn’t enjoy.
After spending some time with the locomotive framework discussed earlier I found it clear and concise to work with in an MVC pattern, separating my logic and data structures was once something that felt odd but now feels natural and makes a lot more sense when you really think about it.
4. Heroku and Mongolab
Working on applications in .NET I always had access to cheap and reliable hosting for my applications and MsSQL databases via windows Azure, I was seeking an alternative after all I had just started writing my web apps in an entirely new platform… with a new database engine that I’d never heard of I was worried that I’d end up needing to buy a VPS and install all this opensourcey technology myself and maintain security and permissions I didn’t want to deal with any of that.
Thankfully there are NodeJs hosts and mongo DB hosts out there such as Heroku and Mongolab who take care of this stuff for you these resources are amazing had I not had good friends tell me about these places then I probably would have given up on NodeJs purely because I didn’t want to maintain these servers for every little web application that I built.
I have always hated version control it always seems to me the kind of things you’d only need if you were working in a team… and it was only until I started working in an actual team that I started to learn how awesome version control could be even for a single person project.
Not only by giving you a place to store your code but an easier way to (branch) off and test out new features of your project without ruining the current functioning integrity as well as well… versioning which is always useful to go back and look at what’s changed plus in the future you have the option to easily open up the history of the project to other developers and expand your team.
So I hope this article helps out any new comers or even veterans to the NodeJs game these were some of my biggest problems when I started and it was for these reasons that it took me many tries to actually make the switch from .NET to NodeJs but in the end I have found myself now capable of setting up and deploying an application in under two days a feat which prior to NodeJs was taking me twice that time.
For me though, the biggest support was switching from notepad++ / sublime to Web storm 7 (check it out here)as this tool really helps out with real time debugging and all those advanced features I was missing from visual studio.
So thanks for reading everyone and please if you found any of this information useful leave a comment below I really enjoy engaging with my readers and do my best to reply to you all!