[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Why in the name of god do people keep using node.js for web servers?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 44
Thread images: 2

File: shit.png (14KB, 600x300px) Image search: [Google]
shit.png
14KB, 600x300px
Why in the name of god do people keep using node.js for web servers? Serious question.
>>
>>55064004
For the same reason people use MongoDB as database: They are retards.
>>
It's the hip thing to do
>>
>>55064219
"Because they are stupid" or "Because it is better" is the average 4channer's answer to everything.

Not helpful, Anon.
>>
node.js is (so far) the worst decision of the 21st century.
>>
>>55064241
Absolutely not. Just wait for the sandnigger bombings that are about to come
>>
>>55064233

usually they have no fuckin clue one way or the other but like to seem smart. It's a youthful thing.
>>
socket.io/websockets is the only legit reason I can think of.

Although those can be done with php etc nowadays too so...
>>
>>55064241
I use node.js for all my general purpose scripting needs. Is there a better way to do it, there's just a library for everything.
>>
>>55064285
Why not PHP, Python, Go, etc? I understand the arguments for the advantages node.js offers in terms of concurrent connections and polling and so on but why would you use it instead of something better and faster?
>>
>>55064004
Webservers are mainly IO intensive (not cpu), so cpu performance isn't that important, and Node has great IO facilities.

I've had a toy project in it. Got unwieldy soon because I'm not good at Javascript, and it bit me in the ass. I have a problem with non typed languages.
It has fast code-to-live cycle, even tho maintenance is hell.

It's as good as anything else for CRUD apps, IO heavy apps, and a random microservice.

It has had the merit of pushing non-blocking IO to the mainstream, which, while not being the panacea, it's nice to have in any language.
>>
>>55064004
>>55064328
Because true web artisans need to go through monthly interations of "The Wheel: Reinvented With a Cooler Logo" to stay hip.
>>
>>55064328
PHP's alright I guess, but Node's package management is way better. Not a huge fan of Python's whitespace as formatting. Looked into Go a bit, but JS is approachable and has a larger package base.
>>
>>55064328

folks going for scripting don't tend to chase after speed. Node.js doesn't noticeably faster or slower in this case.

If you're mostly interfacing with web stuff (ie doing api requests) having the data come back as json makes life much easier than dealing with some of the pain points converting to dictionaries in python.

Concurrent stuff is rather relevant for the above.

function pointers are nice way to do some things and make code unreadable.

node.js really sucks for anything sequential and then you end up wasting time finding those bugs.

Node is really nice for doing prototype REST apis. Stick it behind a NGINX proxy and it's not bad. No clue how that scales with thousands of hits per minute - apparently pretty good though.

Nodes weak point is ORM's and sequential stuff. Unless you're working with mongodb (which is really hard to do right and easy to do very wrong) there isn't any real /good/ mature ORM's

PHP is just gross and I don't know Go so I can't really speak on that.
>>
>>55064493
Rails is good, it's ORM, Active Record, is the best ORM I've ever seen, that thing is genius
>>
>>55064414

you will get used to Python and its whitespace after your first project probably
>>
because it's fuck simple to prototype a rest API for proof of concepts, once you get the cash then build it in a real language.
>>
>>55064004
It allows companies to Jew their front end devs into also writing backend code for the same wage.
>>
>>55064414
This.

Not just NPM either but the way that packages are loaded. It makes it much easier to work with different versions of a package if you need to.

Also Node is asynchronous and has a lot of people working on it trying to figure out the "best" way to do things (note that promises are no longer part of node because other ways are all around better).

Node also makes it easier to do stuff like running multiple servers.

That said, just because you use Node doesn't mean you aren't allowed to use other languages. Some languages are better than others for different things. I'm currently working on a project that uses
>an nginx reverse proxy
>an apache server + mysql + php (LAMP)
>node servers + mongoDB
Different parts of the project are handled by different pieces of software.
>>
>>55064493
>node.js really sucks for anything sequential and then you end up wasting time finding those bugs.

I'm gonna assume that for that bullet-point, NodeJS is a synonym for JavaScript.

What makes JavaScript bad for sequential code?
>>
>>55064620
yeah but I'm already used to and prefer C-style, so it's like why bother. Plus python is still on that 2.7 / 3 schism.
>>
Could be easy to manage after initial development. I prefer rails
>>
It's faster than php or ruby but faster to prototype with than Java or C#. I can also show a front end dev some server code so they can understand what is actually going on.
>>
>>55064666
JavaScript and Node are single-threaded, meaning that you literally can't block in a function without halting your whole webserver.
Since it's so costly to block, you use asynchronous IO methods with callbacks. Callbacks yield some ugly, unwieldy and unmaintanable code that's difficult to reason about (at least to this humble JS novice).
>>
>>55064493
> PHP is just gross
Not a PHP advocate, but as far as dynamic languages go, I'd much rather use one with sane scoping rules, proper encapsulation and type hinting than one without those things.

>>55064596
ORM is a meme. Tables of a properly designed, normalized database almost never translate directly to domain objects. Real men write their own data mappers.
>>
>>55064828
I assume that everybody is familiar with the slang, sorry.

"to block" means to use an IO method which halts execution until the IO call has returned. It's not a problem in a traditional threaded model, but JS/Node is single-threaded.
>>
>>55064845
99% of applications aren't performance-critical.

Why ship in a six months, when you can ship in two?

But yeah, move along, real men passing though
>>
>>55064666

Basically it never waits.

var output = null;
$.ajax('/something', function(result){ output = result });
console.log(output);

----

console.log(output) will run before the ajax call finishes. (usually, sometimes when you're doing local development these issues don't show up because the latency is so low - not a fun bug to track down...)

So you end up doing stuff like promises, passing in callbacks, and a whole lot of other stuff.
>>
I guess it's good if your backend has actually some stuff to process and you're too retarded to write decent multithreaded Java or C#.
>>
>>55064666
I'm not that guy, but

>NodeJS is a synonym for JavaScript.

Node.js is an implementation of JavaScript that can be run stand-alone (without a browser). It has a REPL and a number of 'core modules' that add the functionality of a normal scripting language (stuff like file system stuff, network IO, timers, operating system stuff, loading C/C++ code, etc..) as well as more specific functionality like stream editing and creating web servers (part of network IO).

There is also a package manager for Node packaged modules called NPM. Said packages aren't strictly javascript code (you can have stuff like linters and stuff as well) and they aren't strictly meant for use in Node (stuff can run browser side). The main thing of interest is that the community is ridiculously active and the package manager has git integration.

tl;dr: Node.js = JavaScript + a bunch of libraries + a runtime environment

>What makes JavaScript bad for sequential code?
I'm not sure if it's a big deal for JavaScript but Node is specifically designed to be asynchronous (many built-in functions are asynchronous and some, but not all, have a synchronous version as well). Often times synchronous operation is kind of an afterthought in many modules. This can be difficult for people who aren't used to asynchronous code or to using functions as first class citizens. I come from a Haskell background so it's actually fairly natural to pass around callback functions.
>>
>>55064845
>>>55064596
>ORM is a meme. Tables of a properly designed, normalized database almost never translate directly to domain objects. Real men write their own data mappers.

Real men don't waste time writing data mappers because time is money.
>>
>>55064890
I still don't see how that's a JS-only thing.

If you use a callback like that, isn't the code running concurrently, being executed in two different places at the same time?

How is that fundamentally different from another language just creating a green-thread or an OS thread and executing heavy stuff in them?

Or is it because there's no way to wait() on a deferred function in JS?
>>
>>55064897
>I guess it's good if your backend has actually some stuff to process and you're too retarded to write decent multithreaded Java or C#.
>decent multithreaded Java or C#.
>multithreaded Java or C#.
>decent
>Java or C#.
>decent
fucking lol

Node.js uses libuv. That's way faster and better than any garbage you could ever write in those shit languages.
https://github.com/libuv/libuv
>>
>>55064967
Javascript is single-threaded but uses a queuing method for asynchronous callbacks.
>>
>>55064967
Cenceptually there's little diffrence.

In practice, in other languages you need to go an extra lenght to make an async IO call, while in JS IO calls are async by default (often with no alternative to make it sync, since you'll be blocking the whole app).

It's a big gotcha for someone having a bite of JS
>>
>>55064414
>whitespace as formatting
Whitespace is literally formatting in every language, anon. Python is one of the only languages in which whitespace isn't just formatting.
>>
File: 1453836963855.jpg (272KB, 1394x1056px) Image search: [Google]
1453836963855.jpg
272KB, 1394x1056px
Node.js is much more scalable than the apache webserver, in the sense that it can deal a lot better with a large number of concurrent connections.
Node.js isn't a webserver though, people should use nginx instead. Node.js is mostly handy if you need a custom way of handling things, or something that can deal with websockets properly.
>>
>>55065038

This all seems insane and I don't think I can feel bad for not even wanting to attempt to understand it.
>>
>>55064004
because is good enough for most things.
>>
>>55064328
node itself is written in C++, the javascript functions you call in node are actually wrappers of C++ functions
>>
>>55064219
AHAH OMG EPIC LULZ! UPVOTE UPVOTE GOLD 4 U
>>
>>55064493
>Nodes weak point is ORM's and sequential stuff.
ORMs are only needed when working with relational databases, node works better with nosql databases so it doenst need ORMs as nosql usually uses key/value pairs like what JSON provides
>>
>>55067781
Yeah, the no-ORM is a weaksauce argument. Node doesn't even drivers for SQL databases anyway, because the devs only use NoSQL and NoIntegrity databases.
>>
>>55067798
>>55067781
npm has some pretty solid ORM libraries though, doesn't it?

like i agree that you're kind of doing it wrong if you're using node js with sql, but if you really want you can do it, and you're hardly up shit creek.
Thread posts: 44
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.