Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Mba3gar I'm just looking for answer like you mate. did that to receive notifs about comments
-
No hesitation before jumping to that conclusion, haha ๐ I don't know though (something something non-blocking IO and simplicity?). There's always pros and cons.
-
Mb3leb21495yVery weird, i just need a clear answer why would someone build his Rest api on nodejs express taking into consideration it's single thread
-
but I think it's all about asynchronous operations. If you make a synchronous call which is CPU intensive it will block the thread. Therefore you use an asynchronous function. This function will be triggered and the thread goes right to the next request while the CPU intensive function is executed without blocking.
----
random comment from the internet -
Mb3leb21495yFor those who pinned this rant for news check the following link but still not convinced too
https://geeksforgeeks.org/php-vs-no... -
myss44505y@Mba3gar i wasn't looking for first result on Google nodejs vs php, rather a concrete firsthand example from devrant member ๐
-
Minion4445yThere could be several reasons for that decision:
1. ecosystem
2. performance doesn't matter everytime
3. you can write better js than PHP - so you are building your app way fast er
4. node doesn't scale so Bad through the nio
5. node can also make use of multiple cores - making it somewhat multithreaded -
Personally I love javascript, so developing with a MEAN stack makes development quick for me.
But let's say that I really need to have a fast api, maybe I'd go with Laravel, but then I'd have to learn PHP. Why not learn C# and go with dotnet core? That's even faster than Laravel.
Personally I think it's one of those for most people. Either the love for JS, or not wanting to learn to PHP. -
john-doe9365yIn JS only the event loop is single threaded.
That means, don't write blocking code, or cpu intensive code in the main thread.
The node execution model is a bit different than the rest of the languages.
Javascript is a language designed to be the ugly kid of lisp (expressive and powerful) and C (familiar).
So, it's powerful, yet familiar.
Javascript supports continuation passing style (aka callbacks) and higher order functions.
Which are just killer features that allows one to write more powerful and readable abstractions.
Yes, it has its drawbacks, but if you are diligent in learning the language you get to be a better programmer.
It's way more than just hype, as someone said. That's just the 10 second answer to appear smarter than the rest.
If you are really interested in knowing the power of node, I'd recommend you start by reading about the event loop. You'll realize that JS is a very powerfull concurrent language, which php isn't. -
mowgli3385ySwoole it's the next evolution for PHP/Laravel, just look how you can write async code on it.
https://www.swoole.co.uk/
P.S and it performs better than node on concurrency as much as 2X -
Mb3leb21495y@mowgli share with us more your knowledge about it am really interested to know more.
-
mowgli3385y@Mba3gar Sure thing, i'm working with swoole right now and it performs amazing, we have to create a TCP client and a TCP proxy on the same project and I could make it super easy with swoole, sure, you need to change a little bit how you write code in PHP, but it's awesome how it handles the concurrent users, i have made a stress test with like 5000 threads and it just take 1.3% of ram and 5% of CPU, if you have made it with php-fpm it will take as much as 16GB of ram and all the cores working at 100%, you can add it to laravel/lumen too -> https://github.com/swooletw/...
-
mowgli3385ythis is a http benchmark, you can't use https on swoole, but you can, however have a proxy behind it (I prefer haproxy ) to act as the SSL terminator, some benchmarking -> https://github.com/swoole/...
-
i started using node this week because it was a new project, i didn't know what to use and i had npm installed. performance isn't important to me since it's a small task, and while i'm familiar with both js and php, i only heard about laravel now
Related Rants
As per knowledge everyone here knows that nodejs express is single thread compared to laravel which is multithreaded.
So definitely laravel is better than NodeJS
Then why would someone choose nodejs over laravel?
rant
random
nodejsvslaravel
question
wondering