Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    Quote Originally Posted by StevenTNorris View Post
    Maybe it's just a thing all its own.
    that's a pretty good description

    Quote Originally Posted by StevenTNorris View Post
    Yeah, it is a strange language to catagorize for sure. I see it as sort of quasi-OO with some lacking functionality, but in this case it seems to be great for the event-driven jobs, hence my thinking it "solid" in that right, if not in others.
    I'd simply categorize is as "event-driven, prototypal, object-oriented language". from the core concepts of OO (as far as I can find) I see nothing missing, but maybe I'm just not considering some functionality important enough (like polymorphism*).

    it seems to me that OO is often too tightly connected to class based languages (for whatever reason) or I'm driving abstraction too far.


    * - for instance PHP. though its OO features do not have the best reputation (and there are certainly languages with a better OO implementation) no-one would deny PHP its OO status. and besides that it uses classes, what features does PHP have that JS hasn't?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  2. #17
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    I'd simply categorize is as "event-driven, prototypal, object-oriented language". from the core concepts of OO (as far as I can find) I see nothing missing, but maybe I'm just not considering some functionality important enough (like polymorphism*).

    it seems to me that OO is often too tightly connected to class based languages (for whatever reason) or I'm driving abstraction too far.

    I can see where you're coming from for sure. I think at it's base it's OO. Maybe it's just not a fully-robust OO language, rather than quasi-OO. Of course PHP and the like aren't quite robust OO either, as you've mentioned. Whereas C# is a pretty robust OO language that can be used as a server-side script.
    I guess, and I know this sounds foolish and amateur, javascript just feels more one-time scripty instead of a robust OO feel. I think a lot of that comes from how it's used though. You could really dig deep and push a fairly nice OO infrastructure in javascript if you worked at it, but most people tend to use it for the quick script onclicks and visual manipulations.

  3. #18
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    Quote Originally Posted by StevenTNorris View Post
    I guess, and I know this sounds foolish and amateur, javascript just feels more one-time scripty instead of a robust OO feel. I think a lot of that comes from how it's used though. You could really dig deep and push a fairly nice OO infrastructure in javascript if you worked at it, but most people tend to use it for the quick script onclicks and visual manipulations.
    I don't think you're wrong with that. JavaScript has one of the largest (in quantity) amount of people coding it as well as the largest amount of devices running it, and certainly most of the coders do not even have the slightest idea what it is capable of (or how it works, otherwise forums like this wouldn't be there).


    "imagine how dumb the average person is, and then imagine that half of them are even more dumb than that."
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  4. #19
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    "imagine how dumb the average person is, and then imagine that half of them are even more dumb than that."
    Ha, I approve. Well played.

  5. #20
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,334
    Thanks
    11
    Thanked 587 Times in 568 Posts
    Quote Originally Posted by StevenTNorris View Post
    node.js should still require a webserver with a compiler in order to run, correct? Or is it a js that runs on a machine with a compiler and it creates the webserver? If so, then it's akin to ASP or PHP rather than the C#, VBScript server-side languages, right? (Still new to node.js so I'm trying to get a handle on where it fits).
    it's not akin to anything out there. well, twisted python, but who uses that?

    in node.js, you create the webserver (if you want one) as a function. the request and response objects which are normally globals are arguments of that server function. since js can see vars in functions around the current one, more that one server instance can be running at once, and they can share variables.

    This makes sharing data between clients dead-pan simple and with amazing performance. Whereas php has to basically dump eveything to sql to pass between users, node.js can use variables in ram.


    Most people use node.js because of performance; in a test, i served half a million unique+dynamic pages in one hour on a $300 4year old windows box that never went above 14mb of ram or 10% cpu...
    the limitation was my network; i was only on a 100baseT, and my responses were coming out at 9.6MB/s (98%+ efficiency on 127.0.0.1).

    i doubt .NET, from everything i've ever seen, will ever be able to turn requests around that fast on a 2.0ghz single core with 1gb ram...


    the other big advantage to node.js is portability. i can host the same webapp (or app app) on my linux box at work, my windows work laptop, and a mac mini in my living room, each one running un-modified code.
    js that has no x-browser headaches and runs faster than a doggy browser environ: bliss. This could be the last time you have to write stuff.

    Oh, and node.js has an awsome and expanding package manager that lets you custom add tools you'll find in php/.net, plus a whole lot more. Anything missing can be added, or will be able to added soon.

    Watch a demo on socket.io and see if you're not curious about node.js. i dare you.
    Last edited by rnd me; 02-09-2012 at 04:43 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  6. #21
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rnd me View Post

    This makes sharing data between clients dead-pan simple and with amazing performance. Whereas php has to basically dump eveything to sql to pass between users, node.js can use variables in ram.


    Most people use node.js because of performance; in a test, i served half a million unique+dynamic pages in one hour on a $300 4year old windows box that never went above 14mb of ram or 10% cpu...
    the limitation was my network; i was only on a 100baseT, and my responses were coming out at 9.6MB/s (98%+ efficiency on 127.0.0.1).
    So easy server to multi-client data sharing, AJAX qualities on the fly, and speed that makes old machine's seem usable? That's impressive. I could see this expanding into the new go-to webapp infrastructure.

  7. #22
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    Quote Originally Posted by rnd me View Post
    in a test, i served half a million unique+dynamic pages in one hour on a $300 4year old windows box that never went above 14mb of ram or 10% cpu...
    the limitation was my network; i was only on a 100baseT, and my responses were coming out at 9.6MB/s (98%+ efficiency on 127.0.0.1).
    out of interest, how do you set up such a test?


    @StevenTNorris: AJAX is not a server technology.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  8. #23
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    @StevenTNorris: AJAX is not a server technology.
    Yes I know. But it sounds like node.js gives an easy way to keep connected with clients, allow event driven (maybe socket listening?) updates that run seemlessly without full page postbacks. It's not AJAX, but it sure sounds like it's brother to me.

  9. #24
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    But it sounds like node.js gives an easy way to keep connected with clients
    no webserver *keeps* connected to a client*, that’s not how HTTP works. it’s just about sending and receiving TCP packages.

    nodejs is a webserver that works like any other (when it comes to HTTP). AJAX is more like a small Browser (User Agent) itself. both are only connected via the stateless HTTP protocol and therefore neither party knows (or even need to know) what the other is. from a server point-of-view it doesn’t matter if the receiving client is a real browser or the AJAX object within it and to AJAX/Browser it doesn’t matter if the server is running nodejs or Apache.


    * - that would end up in a DoS (that’s what’s happening in a SYN-Flooding attack, you forcefully keep connections open (through spoofed SYN packages) until the server runs out of memory)
    Last edited by Dormilich; 02-09-2012 at 08:50 PM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  10. #25
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    no webserver *keeps* connected to a client, that’s not how HTTP works. it’s just about sending and receiving TCP packages.

    nodejs is a webserver that works like any other (when it comes to HTTP). AJAX is more like a small Browser (User Agent) itself. both are only connected via the stateless HTTP protocol and therefore neither party knows (or even need to know) what the other is. from a server point-of-view it doesn’t matter if the receiving client is a real browser or the AJAX object within it and to AJAX/Browser it doesn’t matter if the server is running nodejs or Apache.
    I'm aware of all of this. I was just noting the ease at updating information that node.js provides. It has an AJAX-like feel behind it from what you've both explained. It doesn't function the same, obviously, since it's a webserver, but it has a similar philosophy to it's function I think.

  11. #26
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 342 Times in 338 Posts
    AJAX is JavaScript and node.js is JavaScript. insofar you’re right.

    the difference may be that to me AJAX is nothing special (no special syntax, no unexpected behaviour, even more intuitive than DOM Events), it’s just a regular JavaScript object.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  12. #27
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,334
    Thanks
    11
    Thanked 587 Times in 568 Posts
    Quote Originally Posted by Dormilich View Post
    no webserver *keeps* connected to a client*, that’s not how HTTP works. it’s just about sending and receiving TCP packages.

    * - that would end up in a DoS (that’s what’s happening in a SYN-Flooding attack, you forcefully keep connections open (through spoofed SYN packages) until the server runs out of memory)
    node can handle DoS a LOT better than apache, which uses 2MB of ram to connect each client. Node uses a couple dozen KB per client, no separate processes.

    Node goes beyond http. You might want to read-up on eventSource and web sockets. I would highly recommend using socket.io for now, it makes real-time client-server/server-client communication a one liner using custom events.

    One cool thing i did with this and node's watch file mechanism was to monitor CSS files, and when one changed, have each connected client re-load the stylesheet. I can't tell you how cool it was to change something to "background-color:red;" and watch 5 different pcs/tablets/phone change within ~1/2second! Supposedly, this would work just as fast with thousands of clients. i think the max users is about 18,000
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  13. #28
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,334
    Thanks
    11
    Thanked 587 Times in 568 Posts
    Quote Originally Posted by Dormilich View Post
    out of interest, how do you set up such a test?

    to be fair, it was a simple test. each page echos back something like hello world, with the addition of a date stamp, a hit count, and a random number. It was a basic modification of the demo server that is shown on the nodejs.org homepage...



    to hit the server a lot, i used firebug and chome's developer to run a script like the following:

    Code:
    var ports=Array(11).join(",").split(",").map(Image),
        i=0, 
        mx=ports.length ;
       function ping(u){ return ports[i++ % 10].src="/?"+Math.random().toString().replace(/\W/g,"");}
    
    setInterval(ping, 15);

    after running it in a few tabs each on a few of my PCs (and several on the host machine) for an hour, i checked task manager to get stats.

    peak working set: 13.6m, cpu time: 6:13 (out of 60:00)

    EDIT: oh, and the hit counter was at ~530,000 something (I don't have my notes handy...)


    machine: off-the-shelf compaq presario purchased at best buy in fall 2007 for $299.99 US (w/mon).
    windows vista (yuck), 1gb ddr2, amd 6400+ @ 2.0Ghz.
    Last edited by rnd me; 02-09-2012 at 10:11 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •