Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 19 submissions in the queue.
posted by martyb on Sunday June 21 2015, @08:17AM   Printer-friendly
from the two-nodes-back-into-one dept.

Node.js is the software that allows you to run Javascript to create powerful server-side applications by using Google's V8 Javascript Engine. As a Node developer myself, I have always felt frustrated by seeing that Joyent, the company behind Node.s, was extremely conservative in terms of upgrading node to use the latest V8 version; the project was also struggling to get developers to actually contribute to code. This is why Fedor Indutny did the unthinkable: forked node and created IO.js. Today, the two projects are uniting possibly offering developers the best of both worlds


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by fleg on Sunday June 21 2015, @10:07AM

    by fleg (128) Subscriber Badge on Sunday June 21 2015, @10:07AM (#199009)

    i have written code in a few languages, javascript is the only one i really loathed. as a result i dont keep up to date with it. its been about 5 years since i did any, has it got any better?

    havent used node.js, the idea of writing non-trivial server side stuff in javascript blows my mind, anyone out there done it and care to share their experiences? whats node.js good for?

    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (Score: 3, Informative) by NCommander on Sunday June 21 2015, @10:20AM

    by NCommander (2) Subscriber Badge <michael@casadevall.pro> on Sunday June 21 2015, @10:20AM (#199011) Homepage Journal

    My understanding its event processing done in JavaScript, which integrates nicely with AJAX frontend code. I'm not familiar with node.js itself, but flipping through the docs briefly, its the JS version of twistd from python. In short, a frontend server looks for an event (vs loading a specific script like in traditional CGI), and that event causes server-code to go; an ideal circumstance for AJAX queries, and the like.

    --
    Still always moving
  • (Score: 0) by Anonymous Coward on Sunday June 21 2015, @11:25AM

    by Anonymous Coward on Sunday June 21 2015, @11:25AM (#199030)

    Well, normally you would have your apache.ini file which had to be edited, you would have your mysql server that would need to be setup, you'd have an SMTP server setup for mail, and the list goes on and on.

    NodeJs takes all of that and crushes it down into a full webserver with all of that included 3/4 of a single page of script.

    It is a vast improvement, and simplification of the entire process.

  • (Score: 0) by Anonymous Coward on Sunday June 21 2015, @11:28AM

    by Anonymous Coward on Sunday June 21 2015, @11:28AM (#199032)

    If you want to see what the entire nodeJS index.js file (which runs everything) looks like you can head over to https://darrencaldwellwebdesign.ca/ [darrencaldwellwebdesign.ca] and check under articles. I wrote one there about nodejs and how to setup your first server (it takes about 10 minutes maybe, which is again a really big improvement).

  • (Score: 5, Informative) by deimios on Sunday June 21 2015, @11:59AM

    by deimios (201) Subscriber Badge on Sunday June 21 2015, @11:59AM (#199038) Journal

    I have a bit of experience with node.js and when it works it's the perfect fast prototyping platform for sites. Though coming from a JavaEE background I guess a dead turtle in superglue is faster at prototyping than JSF.

    From my (arguably limited) point of view:

    Pros:
    You can get from 0 to functional webapp in minutes
    The package manager is pretty good when it works, there are packages for almost everything
    The async/ callback based coding style is interesting
    Being JS based it works nicely with MongoDB and other JSON style NOSQL DBs
    The community is HUGE and still growing
    Extremely simple to configure some very complex stuff. Since you're on the same level as the webserver you can tweak pretty much anything.

    Cons:
    Singlethreading can mess up multiuser sites in interesting ways. Especially coupled with the "cluster" module which makes it multithreaded.
    It's rapidly evolving, sometimes breaking modules or their dependencies. Lack of a "standard" way of doing things, since modules implement features first then the core catches up with an incompatible implementation.
    Callback hell (it's so bad it has its own site: callbackhell.com)
    Since you're working on the same level as the webserver you will need the boilerplate to actually fire up listeners on port 80 and all the other misc stuff.

    • (Score: 2) by fleg on Monday June 22 2015, @02:32AM

      by fleg (128) Subscriber Badge on Monday June 22 2015, @02:32AM (#199260)

      interesting, thanks.

      i'm now wondering if node.js would be a good fit for something i may have to do.

      i have a java command line which takes some images (3 or 4), does some processing on the images (takes upto 5minutes) and spits out a result image. at some point in the future we may want to put that command line behind/in a server and have people send the images they want and receive the result back.

      i had been thinking i would have to go the route of ejbs and some sort of app server like say jboss (which i have used before), but it feels like overkill, so i'd been considering just writing a simple server which just sits on a socket waiting for requests. but now i'm thinking maybe node.js is worth investigating.

      • (Score: 2) by deimios on Monday June 22 2015, @04:05AM

        by deimios (201) Subscriber Badge on Monday June 22 2015, @04:05AM (#199282) Journal

        If your image processing algorithm is non-blocking or can be rewritten to be non-blocking then go for it.

        Just beware: node.js runs in a single thread so if you do any synchronous heavy processing, it will hang the main thread's event loop which will pretty much hang the whole stack. This means: no pages served, no logs written until the processing is done.

        Take a look here: https://github.com/glenjamin/node-fib/blob/master/app.js [github.com] to see an example of node.js style heavy processing. It calculates the Fibonacci tree in a non-blocking way. (not my code)

        • (Score: 2) by fleg on Monday June 22 2015, @05:08AM

          by fleg (128) Subscriber Badge on Monday June 22 2015, @05:08AM (#199292)

          understood, thanks.

  • (Score: 2) by mtrycz on Sunday June 21 2015, @12:21PM

    by mtrycz (60) on Sunday June 21 2015, @12:21PM (#199045)

    ECMAScript6 - the attempt to repay the technological dept of JavaScript - is due to come out this year. I don't expect it to "fix" Javascript, but thet's the best people are able to come up with, other than WebAssembly (precompiled blobs that run in your browser).

    node is good for i/o intensive work, because of its asynchronous i/o model, but since it's singlethreaded, cpu-intesnive loads will hog up all interactions.

    It's good for some quick web-related stuff, it's easy to pickup and fast to prototype in - for small projects where a bigger language or framework would be overkill. For bigger projects: with js it's way to easy to shoot yourself in the foot.

    --
    In capitalist America, ads view YOU!
    • (Score: 2) by mtrycz on Sunday June 21 2015, @12:24PM

      by mtrycz (60) on Sunday June 21 2015, @12:24PM (#199046)

      Oh, and the hate node.js is getting, is because of it's userbase - fervent hipsters that just can't understand that people have other use-cases than their webdev stuff.

      --
      In capitalist America, ads view YOU!
      • (Score: 2) by mtrycz on Sunday June 21 2015, @12:28PM

        by mtrycz (60) on Sunday June 21 2015, @12:28PM (#199047)

        Also, "cloud" companies tend to offer bandwidth for much cheaper than storage, cpu and ram. A small 1 core / 512 ram vps instance goes for as little as 5$ a month. If the application is actually i/o bound with small cpu overhead, then with asynchronous io you'll get better performance than with traditional (threaded) webservers.

        Sorry, I just can't think clearly right now.

        --
        In capitalist America, ads view YOU!
        • (Score: 1) by Pino P on Sunday June 21 2015, @03:41PM

          by Pino P (4721) on Sunday June 21 2015, @03:41PM (#199100) Journal

          A small 1 core / 512 ram vps instance goes for as little as 5$ a month.

          Is that with its own IPv4 address, or is it behind a NAT?

          • (Score: 2) by mtrycz on Sunday June 21 2015, @04:15PM

            by mtrycz (60) on Sunday June 21 2015, @04:15PM (#199107)

            Digitalocean, which I am not affiliated with, but ofen use, gives you a public ipv4 (or ipv6 in some regions), and optional "private networking". Also, it's the most flexible I know (haven't tried most of the new ones like Heroku, tho), giving you the option to create and destroy "droplets" on the fly, and even programmatically with an API. The cheapest "doplet" is 5$ a month with hourly billing, and you can dispose of your "droplet" when you're done.

            I think it wasn't actually invented for stable hosting, but dynamic prototyping and such, but the prices are good even as hosting goes, for the small instances. For VPS at least. I don't know how does it compare for big instances, since I have never used those... all my projects are small/low traffic.

            --
            In capitalist America, ads view YOU!
    • (Score: 1) by Pino P on Sunday June 21 2015, @02:54PM

      by Pino P (4721) on Sunday June 21 2015, @02:54PM (#199083) Journal

      ECMAScript6 - the attempt to repay the technological dept of JavaScript - is due to come out this year.

      ECMAScript 6 is already "out" in the sense that it's been approved by Ecma [sdtimes.com].

  • (Score: 2) by arslan on Sunday June 21 2015, @11:55PM

    by arslan (3462) on Sunday June 21 2015, @11:55PM (#199223)

    Yes, it has improved. The latest version ES6 coming out will hopefully make you not have to touch prototypes at all as it will support classes and modules natively. Although to be fair depending on what you do you can pretty much avoid it today already with ES5 - traditional OO developers just get caught up too much by it when most of the time you don't really need it. Even the quirkiness with "this" has some enhancements in ES6 to lessen its quirkiness.

    As for Nodejs, the whole point of it is to make "complicated" server side development simple. Like any other language, as the supporting libraries and frameworks increases, it can only get simpler to build functionality by cobbling together 3rd party libraries. However, given it is based on javascript there is some adjustment to get used to. For example, most IO by _default_ happens asynchronously but CPU compute does not, so concepts like promises (and the upcoming generators) play a bigger role than in languages like Java where execution are by default serial. Because of this fundamental nature of javascript, developing apps that are IO bound most of the time and can handle lots of concurrent request is pretty straightforward. So if you're developing a typical web app where you require a RESTful interface to bridge to a Database with some minor processing in between (typical web app) then it is pretty simple/straightforward to build and the performance is quite good

    On the UI side (browser), I can honestly say it is much better than developing in Swing or even JavaFX (I've done quite a few years in the former). The tooling is excellent just with the Chrome browser alone. The upcoming Web Components will also alleviate some of the "workarounds".