Live data from Hacker News

Node.js Fundamentals: Web Server Without Dependencies

blog.bloomca.me

11–20 of 44 posts

Re: Node.js Fundamentals: Web Server Without Dependencies

#13
IMHO articles like this played a major role in Node's initial success. After years of working with ever-growing frameworks with huge learning curves, it was so refreshing to get your first thing running in few seconds. Felt like basic in the 1980s or PHP in the late 1990s.

Re: Node.js Fundamentals: Web Server Without Dependencies

#14
There are a lot of gotcha's when rolling your own web server based on the http and https packages and I think the conclusion of the article could have gone further in addressing what they are and in what context they might matter. I recently wrote a little zero-dependency NodeJs http/s server[1] with an equally dumb router for some dev tools which could benefit from a simple, promise based api, for most other use cases I'd just pull in express or something more mature.

[1]https://github.com/8eecf0d2/decade

Re: Node.js Fundamentals: Web Server Without Dependencies

#15

IMHO articles like this played a major role in Node's initial success. After years of working with ever-growing frameworks with huge learning curves, it was so refreshing to get your first thing running in few seconds. Felt like basic in the 1980s or PHP in the late 1990s.

IIRC before nodejs+express the req/resp/next paradigm and middleware paradigm had never been so accessible. Other frameworks had it of course, but it was often hidden behind layers of abstraction or little quibbly bits. Express gave you just what you needed for both middleware and handlers:

    app.get('/', function(req, res, next) {
      res.send('hello world');
    })
For comparison, flask:

    @app.route("/", method='GET')
    def hello():
        return "Hello World!"
It's really close, but I find the NodeJS approach even simpler and easier to understand. Need to access the request? use `req`. Need to access the response to set headers or something? use `res`. Is your function actually a middleware? use `next`. It doesn't get much simpler, assuming you understand node's semantics well (as in "return"ing a value doesn't mean it gets sent).

Django/Rails required whole project scaffolds and usually a separate routes and handlers files and knowing a whole bunch of stuff. I'm not even going to get into what frameworks like Spring/Struts required.

NodeJS made it dead simple to get a HTTP server up and running in something like People shit on JS and NodeJS every chance they get, but innovations like the amazing standard library (and express), along with npm's ease of use really pushed the field forward IMO. While I'm praising node I might as well say that node got decent bolt-on (gradual) type system support way faster than the other popular dynamic languages as well, but they got there through transpiling which also looked (is?) ridiculous the first time it became well-known. I find Typescript much more approachable than typed python[0]. Is typed ruby even a thing[1]? I don't keep up with ruby so I'm not sure.

[0]: https://docs.python.org/3/library/typing.html

[1]: https://bugs.ruby-lang.org/issues/9999

Re: Node.js Fundamentals: Web Server Without Dependencies

#17

Earlier quoted context omitted.

This is really pretty sad. A standard library is paramount to a stable and easy to develop ecosystem.

It may be, but this is a weird thread to bring that up since Javascript has padStart, and TFA is about building a web server with only the standard library.

the OP was referring to this incident https://github.com/stevemao/left-pad/issues/4

where a very basic package everyone depended on was yanked from npmjs.

azer's original post: https://news.ycombinator.com/item?id=11340510

Re: Node.js Fundamentals: Web Server Without Dependencies

#19

IMHO articles like this played a major role in Node's initial success. After years of working with ever-growing frameworks with huge learning curves, it was so refreshing to get your first thing running in few seconds. Felt like basic in the 1980s or PHP in the late 1990s.

IIRC before nodejs+express the req/resp/next paradigm and middleware paradigm had never been so accessible. Other frameworks had it of course, but it was often hidden behind layers of abstraction or little quibbly bits. Express gave you just what you needed for both middleware and handlers: app.get('/', function(req, res, next) { res.send('hello world'); }) For comparison, flask: @app.route("/", method='GET') def hel…

I agree for the most part, except comparing node/express to Rails: node's equivalent in the Ruby world would the Sinatra, which is about as succinct than node.
Post reply on HN