5 ms·
Honest although tangentially related question: why node.js? I honestly really don't get why someone want to use js serverside, and I say that as someone who di
by reitanqild 11y ago
Honest although tangentially related question: why node.js?
I honestly really don't get why someone want to use js serverside, and I say that as someone who did create cool things with js client side and wants to know why I should spend time on this new cool stuff.
Edit: automatic upvotes for serious answers as long as I see them before going offline :-)
- vkjv 11y agoThere are many reasons, but I think the simplest is that using a language in house has a very real and non-trivial cost. Expertise, coding standards, library vetting, etc. By using Node.js in a Web shop, you can eliminate one language. Other benefits include re-use of client side code, async everywhere, and popularity.
- jsjohnst 11y agoOne of the promises of node.js (that I've not seen pan out really in practice since) that got me interested 4-5 years is the ability to render a web page on server or on browser using same codebase. Take as an example a heavy codebase like Yahoo! Mail or Gmail. Notice how slow Gmail especially is from login to "ready state"? Now imagine if the first page of your inbox was rendered server side and sent as normal HTML markup. If it was designed well, the JS would progressively load after that and if for example I click compose before that JS was loaded yet, the click would be treated as a normal click and it'd round trip to the server and then render the compose view and send me back the new page. If the JS had loaded, it'd just be rendered in browser like normal. Doing tricks like this can massively increase the perceived responsiveness of web apps. I've seen prototypes of Yahoo! Mail built like this and man they are so fast, but sadly doing this is well is very complicated and node.js never actually helped as much as it promised too. Don't get me wrong, what I described above I've seen done in production code, it's just it was a very manual and slow process and node.js never did that much to help, IMHO.
- b0p1x 11y agoYou might be interested in what is going on in Drupal 8 with regard to pre-caching and a newer (now in core I think) module called BigPipe. It does some of what you describe in PHP in a fairly generic way. AFAIK, you just enable this module and ensure caching is enabled. From that point on, slower assets load when ready so the rest of the site is already visible... like Facebook.
- jsjohnst 11y agoI'm more talking about fast start SPA, not partial content loading strategies. There's a number of utilities that does what Drupal is doing. Turbolinks has been doing what you describe for years (if memory serves) with Rails.
- matthijs_ 11y agoEmber FastBoot? And React also published something similar recently.
- jsjohnst 11y agoI've seen many attempts, but nothing has really taken hold as its really difficult to do right. Rather than pointing at libraries that can "help", I ask you to instead point at any places it's being done well in production, especially at scale.
- bottled_poe 11y agoWhy JS? Because most developers are JS developers. [1] To business decision makers, that looks like a better strategic decision - Now my web app devs can do server side! Obviously this is totally wrong, any decent developer can learn a new language/framework. The architectural concepts are totally different on server side, which is what HR should be hiring against. But hey, what do I know. 1. http://stackoverflow.com/research/developer-survey-2015 http://stackoverflow.com/research/developer-survey-2015
- cubano 11y agoMost IT-based business hire based on the lowest cost option and what tech stack the founders are comfortable with. Probably not as true in SV and SF, but the rest of the country it is.
- fla 11y agoNode.js is event oriented I/O. It lets you design some server tasks in a way that is non-blocking and thus more efficient. (Some other languages let you do that too)
- regularfry 11y agoPretty much all general purpose languages let you do that. Only Node makes you.
- fla 11y agoPHP doesn't
- tyingq 11y agohttps://docs.hhvm.com/hack/async/introduction https://docs.hhvm.com/hack/async/introduction
- fla 11y agoYeah OK :) HHVM is not the usual PHP runtime one expects to build the average web service upon. Anyway, my point was that Node.js main core value was to let people script evented I/O over a lightweight runtime. When Node came out, it was something new.
- tyingq 11y agoSure. I just happen to agree with the notion that node.js is mostly unique only in that it pushes you down that path. Java has a fairly rich NIO path that you can choose to take or not, and predates node.js. I believe the Tornado package for Python predates it as well. Certainly, there's some advantage there...fewer surprises with 3rd party libraries that aren't non-blocking. But, there's downsides as well.
- hookshot 11y agohttps://github.com/elazar/asynchronous-php https://github.com/elazar/asynchronous-php
- bitwize 11y agoWhy did Java take over in 2000? Because starting in the mid-late 90s, B- and C-rank universities began adopting Java over C++ or Pascal as a teaching language, producing a glut of graduates who knew Java. As IT needs grew because of the internet boom, companies built their systems with the language that the available programmers knew. These days, more and more "teach kids to code" initiatives are starting with JavaScript because it's easy to get started with, existing in every browser known to man. With IT infrastructure in for another period of growth/change, especially in startups, it makes sense to build out in JavaScript because it's what incoming fresh programmers know. It doesn't make much sense to me, but that is how they do in the corporate world.