There are a plethora of web frameworks to choose from and even more options when you combine them. I want to take a look at comparing two frameworks, Node.js and Laravel, that, in my opinion, are the most advanced web frameworks. And, I want to make one single point: do not compare Laravel and Node.js as though one is better than the other, rather, compare them against which is the best tool set for the job or problem you are trying to solve.
Similarities Between Node.js and Laravel
Second, I want to explore the ways in which Node.js and Laravel are similar:
- package manager
- RESTful routing
- non-blocking / event based
- this is inherent in Node.js
- Reactphp for Laravel
- web sockets
- database drivers: MongoDB, MySQL, etc
- they are both very comparable; just search for a driver for the database of your choice
- dependency injection
- data typing
Strengths Weaknesses Opportunities and Threats (SWOT)
Third, I want to give a quick Strengths Weaknesses Opportunities and Threats (SWOT) analysis of each.
- vibrant and engaging community
- changing fast, so you can be an influence
- modular from its beginning
- non-blocking / very fast
- the community tends to be biased in support of non-relational databases such as MongoDB
- not good with computation heavy apps (reference)
- not as mature as "alternatives" (though, to be fair, there are no alternatives)
- event-based programming can be difficult to work with: debugging, promises, etc; it takes a lot of training / experience to do it well
- maturity: simply needs time, since they have the community involvement
- develop comprehensive frameworks (like a "Laravel" for Node.js) so you don't have to build your own framework from scratch (see this large list of prospects)
- I see no threats provided the status quo continues; in other words, they are on the right track. A very low probability threat would be something like a resurgence / revolution in Ruby or Python development, or if PHP's current revolution wins over the Node.js crowd.
- It has everything I loved about CodeIgniter combined with everything I wished it had from PHP 5.3 / best software practices
- structure: with MVC and PSR-0 you have terminology to talk about where things should go and every line of code has an expected place
- there is a large community in PHP that advocates unit tests, and PHP supports interfaces; two things that help ensure consistency in your application
- it provides patterns to help you use current best practices in programming: dependency injection, facades, unit tests, interfaces, PSR-0 (there are a few great Laravel books on these)
- PHP has a large and well established community
- the community tends to be biased in support of relational databases, such as MySQL
- not inherently non-blocking
- PHP has enormous baggage from PHP4 and earlier: just look up anything about "PHP is the worst language ever"
- there isn't a large community around Laravel, specifically, and the community isn't pushing for support / acceptance
- PHP has a very active community and with PSR-0 it will be easy for Laravel to adapt and adopt from the large pool of PHP code, i.e. out-of-box support of non-blocking, multi-threading, etc
- Laravel is a beautiful framework which should make it easy to push adoption, especially among the CodeIgniter and CakePHP crowds, and even more so among PHP crowds looking at Node.js or Ruby on Rails
- Pretty much everything is a threat to Laravel because it is written in PHP. Other frameworks in other languages, such as Ruby on Rails, have had support for the things Laravel is doing (and planning to do) for much longer and are, therefore, much more mature. However, PHP isn't going anywhere anytime soon and other PHP frameworks are still catching up on implementing the current best practices.
Node.js and Laravel are brilliant frameworks. They both hold enormous promise for the future and have some of the best features available of any framework. But, they have their biases. If you have an application with low computation and high availability requirements and are going to use a BASE or non-relational database, Node.js is favorable. If you have an application that is very complex and you need the highest level of consistency and organization, and if you are working with ACID / relational data, then Laravel is favorable. As a final thought, consider Linus Torvald's thought process surrounding his decision to develop Git for Linux as seen in his "Tech Talk: Git" presentation at Google.
- Release the Kraken: How PayPal is Being Revolutionized By Node.js and Lean-UX (nearForm)
- How to decide when to use NodeJS? (StackOverflow)
- Laravel 4 Real Time Chat (Medium)
- Laravel is Awesome (Phil Sturgeon)
- PHP vs. Node.js