Node js vs Ruby on Rails For Web Development

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys in this video we're going to be doing a comparison of nodejs versus Ruby on Rails for web development now the main reason I do these types of videos is because I'm constantly being asked which language or which framework is best to learn and I never give a simple answer to that because they're almost always isn't a simple clear-cut answer so I think the next best thing is to look at all the facts and statistics and valid points on both sides and that's what I kind of want to do in this video so we're going to take a look at some of the advantages and some of the disadvantages of both no js' and Ruby on Rails for server-side technologies so before we begin I just want to make a couple of points so I can already hear the critics saying how are you going to compare no js' which is a runtime to Ruby on Rails which is a framework and I get that argument but what I'm comparing is the two server-side technologies and web stacks all right so looking at what's better to learn right now also what's better to implement for a business so I'm not I'm not saying you know compare straight up features of Ruby on Rails to no DJ s if it makes you feel better replace nodejs with something like Express or some other node based framework even something like meteor then you have two frameworks which still isn't quite apples to apples because Express is much lighter and much more flexible and it's in its structure so think of it more as compared comparing back-end structures and stacks not the individual technology all right so hopefully I explained that right so as far as what I base this on I'm basing it on statistics on the internet facts my experience and opinion i've worked with both technologies and I like both technologies I'm not promoting one over the other all right it's also important to understand that what works for me may not work for you and vice versa and remember that everyone's brain is different there's no cookie cutter answer for this question just like there is there isn't with most technology comparisons so I encourage interaction and even arguments all that I ask is that your spectacle to one another and listen to the other points of views all right a lot of you guys asked how I got to where I am today and how I know so many different frameworks and you know languages and so on and I attribute to that a lot of that to not picking one thing and saying it's better than the rest I take the time to learn about multiple languages and frameworks and technologies and it gives me kind of a good overview of everything and really realizing that there are certain tools for certain jobs okay there's not there's not a clean-cut answer for everything all right so enough babble let's go ahead and get started with looking at some of the similarities between both technologies all right so both no js' and rails are there well respected and popular server-side technologies that can do many different things that can work with many different stacks and databases and so on both are fairly easy to learn node uses javascript and rails uses ruby but they're both of them Ruby and JavaScript are easier to learn than something like Java or C sharp or some of those higher-level languages they're both pretty forgiving languages and there's a ton of resources for learning both both perform really well and we'll talk about the level of performance of both of them in a little bit there's many examples of popular websites that use both technologies and I'll go over some of those as well both node and rails have very strong and opinionated communities rails has been around a little longer and has more old timers but note is becoming more popular every day now MVC or Model View controller is a design pattern and Ruby on Rails is hard MVC you have a folder for your models your controllers and your views MVC is possible with certain frameworks in nodes such as Express but Express is much more flexible in its structure than rails is you can just take certain aspects of MVC it's not the only structure possible all right and both are used for rapid development and prototyping rails has an awesome a folding feature and Express as generators and command-line tools as well all right so first we're going to take a look at the advantages of Ruby on Rails and then the disadvantages and then we'll look at nodejs alright so like I said in the previous slide rails has a very strong MVC structure most rails applications are going to look very similar in terms of the core files and folders you know you have that strong foundation and then you build upon that with gems and custom packages and libraries alright to add to that rails is very opinionated meaning that it makes you adhere to its way of doing things rails is going to assume that you're going to write code in a certain way and some people may say that's a little restrictive but it also makes for easier and much cleaner code and it also makes it harder to to have errors and issues all right it's not restricting in the sense that you can't create what you want but only the way that you're going to get there and if you do it the right way it'll most likely be the easiest path possible all right with Express or some other node frameworks you have a ton of freedom as far as structure but you also have enough rope to hang yourself in some cases all right rails has really good database migration functionality they allow us to do things like create and edit tables and columns in our database without having to manually go in and add and change things it also gives you a nice little log or a path that you can follow to see exactly what's been done to the structure of your database now with node there are some packages or modules for migrations such as DB migrate which can work really well but it's not as in-depth and easy-to-use as the rails chord migration system when it comes to prototyping and rapid development there's not too many technologies out there that can beat rails so some basic configuration and a couple scaffolding commands and you have yourself a full functioning crud application and again database migrations add to that speed nodejs and Express is fairly good with fast development if you use third-party tools and modules but rails has all that stuff right out of the box all right now there are some pros and cons to the Ruby language but for the most part it's well respected it's very clean a lot of it actually looks like plain English and that was the intention of UK hero mutt Matsumoto I think it is I don't know if I pronounced that right but he was the creator of the language it's a multi-paradigm language you can do procedural code functional but for the most part its object-oriented all right everything can be looked at as an object all right rubygems is a package manager for Ruby on Rails and it's it's used to extend the core functionality of the framework it's similar to NPM for nodejs which we'll talk about a little bit all rails applications have a gem file where you can specify your gems and then you can run a bundler command to install all of them similar to NPM install with node.js alright so another great thing about Ruby on Rails is that it's been around for a while and it has a very respected and intelligent community the developers that maintain Ruby on Rails are extremely smart and very passionate about the framework there's a ton of resources on the core framework including forums blog posts and documentation to help you out if you get stuck all right however I do often hear complaints about lack of documentation for for a lot of the gems and the real advanced programming alright so those are the advantages of Ruby on Rails let's talk about some of the disadvantages so one of the biggest complaints that I hear about Ruby on Rails is that it's relatively slow nodejs and Express is really fast but it's also really light rails is a big framework with a lot of features in its core so it makes sense that it doesn't perform you know as well as some of the lighter frameworks you also have to factor in the gem and file dependencies of an application now when I say that rails is too simple what I mean is that when a new developer decides to learn rails and they set up a new application there's so much automation and scaffolding that the developer doesn't really learn very much about you know about the Ruby language about the syntax or the structure of their application so for someone that really understands how Rails works this is great because it's it's rapid development but for someone just learning they really have to go the extra mile to really understand certain things Rails is also way more difficult for big projects than small applications and it can have some issues with scaling as well so another disadvantage is that rails is not as popular as nodejs at least at this time note is on the cutting edge of web development and the excitement for Rails has really settled at least in my own opinion if you are looking for a job I would definitely say learn node and and probably Express more companies are hiring JavaScript developers than any other language if this was five years ago rails would be or Ruby would be one of my top three languages to learn but these days it's just not as popular so I briefly mentioned earlier that the core rails framework has some really good documentation and examples learning simple scaffolding commands and database migrations that's all fine however when you're trying to learn more advanced programming and you're trying to learn about specific gems sometimes it feels like looking for a Newton uh needle in a haystack I've experienced this myself and I've also heard other developers complain about it as well alright so some pretty big names have used or do use Ruby on Rails in their platform I don't think you can get much bigger than Twitter although they have moved a lot of their back-end services to Scala and Java due to some scaling issues but they get used rails for a long time and I'm pretty sure they still use it in other aspects of their platform Shopify which is a huge e-commerce solution they use rails back-end services Basecamp which is a project management solution they have said that rails is the heart and soul of the Basecamp project all right the software that runs github was built on Rails in Erlang Blumberg which is a news and political empire they use Ruby on Rails they actually had a recent job opening for rails position let's see SoundCloud Hulu which is a popular streaming service was built on Rails from the beginning Groupon and LivingSocial SlideShare urban dictionary these are all huge names that have used rails and they're in there in the structure of their platforms at least at one point all right so now that we looked at rails let's start to look at nodejs so we'll start with the advantages and one huge plus two no js' is that it's extremely popular it's it's you know basically the new cutting edge technology and web development there's a very high market demand it's extremely popular in startups at least for the moment I know things are always changing there's a flourishing open-source community around node and the Express framework with you know many well developed modules on NPM when it comes to speed and performance node knox rails right out of the water actually it pretty much knocks anything out of the water it runs on the Google v8 JavaScript engine which is lightning fast note is used to build real-time web applications that almost feel like desktop applications so nodejs is also asynchronous which means that when a program sends a request to the server it doesn't have to wait for the reply it can continue to execute it runs on one single thread as opposed to other languages that send the request they wait till that request is done then they send the next one and so on now there's a there's a downside to that which I'll get to soon so note is also very scalable and being on a single thread plays a big part in that something like apache has to have to handle a pool of requests to a set of threads which gives it much more overhead and it slows things down node also works really well with no SQL databases like MongoDB which are much more scalable than traditional relational databases like MySQL all right almost all big companies that I read about that have shifted to no js' they've reported at least at least a decent rise in productivity all right another great advantage to note is that it use javascript which is widely used with many web stacks the language on the front end is different from the back end and that's not the case when using node.js we're using JavaScript on the front and back end there's a ton of client-side frameworks that are dominating the industry react angular view j/s so that's a huge plus to no js' all right now and obviously javascript works well with jason api's which are very popular all right so no js' and let's say Express or happy Jas any of these frameworks they have a really flexible file structure and they let you construct your applications however the hell you want you could Jam everything into a single app j/s file if you wanted to or you could have more of a traditional MVC structure I think there's both good and bad sides to this but for the most part if you know what you're doing and you're a good programmer then flexibility is a good thing all right so like rubygems node also has its own package manager called NPM or node package manager the the biggest difference between NPM and ruby gems or even pip which is the python package manager is the way that dependencies are managed with ruby and pip dependencies are installed globally so we have to use the bundler and you have to kind of manage them on your own when NPM actually takes care of all that for you your modules you know they get put into the node modules folder and then those those modules can also have their own node modules folder with their own dependencies and NPM modules also seem to have better documentation at least in my experience all right so we looked at the positives the pros and advantages of node.js now let's take a look at some of the disadvantages now as good as note is for many crud style applications it absolutely sucks for applications that are CPU intensive the reason for this is that whenever it does something that takes a while such as a CPU operation it'll queue all the incoming requests because it runs on a single thread something like apache which has more available threads it'll divvy up that that CPU time between them and only IO operations are parallel because they're executed asynchronously all right an example of a CPU intensive task is something like 3d rendering video encoding scientific modeling sorting things like that all right another complaint with note is that it can be a little inconsistent some feel that the API keeps changing at frequent intervals and it's it's sometimes not very backward compatible not only that but the structure of an Express application in general is very free and flexible and it can sometimes you know like I said before it can give developers enough enough rope to hang themselves rails is very strict which means that it's harder to write bad code so node and Express our new technologies or new or I shouldn't say new but they're newer than rails and there's not as many developers working with them as you know that have as many years under their belts like you would find a through V on Rails developers but on the other hand since node uses JavaScript most developers learn it really fast because they already know the core language okay from working with JavaScript elsewhere so since node is asynchronous you're going to be dealing with a lot of callback functions and they can often bubble up and get into what's called callback hell now there are solutions to this such as async utilities and using promises and there's a few things that you can do to prevent this this personally doesn't bother me but I know that some developers that aren't used to asynchronous programming have a problem with you know a lot of callbacks all right so frameworks like Express and happy Jas they're very light which of course can be a plus but this also means that any extra functionality needs to come from third-party modules for instance templating you have all kinds of options with node and expressive bug ejs handlebars but you need to install them separately unlike rails which of course you can use you know third-party template engines but it does have embedded Ruby by default expresses and as full-featured is Ruby on Rails which it makes it hard to compare just Express to Ruby on Rails which is why I called this nodejs versus Rails alright so some big names that have used nodejs linkedin which is right up there with Twitter and Facebook they actually switch from Ruby on Rails to node.js quite some time ago and they switched mostly for scaling reasons because node happens to scale better in in most situations all right most of eBay's front-end stack is built on node paypal widely uses nodejs yahoo as far as I know Klout equalist and Storify all use Express they all use node with the Express framework Shutterstock ancestry.com some pretty big names alright so as you can see both of these back-end options have their their you know pros and cons but they're both fantastic technologies and you guys know that I hate saying one thing is better than another overall but if I had to choose I would go with nodejs and something like Express over Ruby on Rails in most situations node stacks are more popular they're highly scalable and they perform much better these are points that really can't be argued with the evidence that that we've seen all right but again everything should always be evaluated on a case-by-case basis rather than just saying one is better than the other in all situations alright guys so that about wraps it up thank you for watching and hopefully this video could help you out in some way or at least give you a little insight don't forget to subscribe and if you liked the video please leave a like also come follow me on Facebook Twitter and LinkedIn okay thanks for watching and I will see you next time
Info
Channel: Traversy Media
Views: 146,450
Rating: undefined out of 5
Keywords: node.js vs rails, node.js vs ruby on rails, node js rails, ruby on rails nodejs
Id: okMVc3-aCKQ
Channel Id: undefined
Length: 19min 28sec (1168 seconds)
Published: Wed May 31 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.