Live data from Hacker News

A 7KB AWS lambda Node.js library with zero runtime dependencies

npmjs.com

21–30 of 63 posts

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#21
post #11

Earlier quoted context omitted.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/... https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Excellent source; thanks! It’s probably worth clarifying that Node is ⅓ the speed of Java in some of these cases and that the Node implementations use both fixed size typed arrays as well as worker threads, features that aren’t common practice in most Node programs.

I wanted to illustrate the fairly "wide dynamic range" available. A lot of typed, GCed languages require significant effort to write highly optimized code anyway, and the optimized code rarely looks like the idiomatic one.

But even with idiomatic code the performance is quite good - the JITs are very high quality.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#22
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

It's a Turing-complete, general-purpose programming language. What should stop you using it for anything?

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#23
It wasn't obvious so I checked: zero runtime since it typescript and the @types/aws-lambda stuff is not needed in resulting compiled JS. Still I'm not sure what this does beyond until functions for events you receive in Lambda and have to parse raw yourself?

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#24
post #12

Earlier quoted context omitted.

> The performance is also quite comparable to statically typed GCed languages. (For example, you can probably get to 50%-90% of Java performance on most single-threaded workloads) Citation needed, please. I disagree with this. I recently was able to achieve a massive speedup in a Node application through writing a native C++ module... and implementing Garbage Collection is required for N-API.

For those situations where the GC becomes a performance (or more likely memory usage) problem, it seems reasonable that the built-in WASM support of most engines will be able to provide an adequate performance (its already getting quite close): https://www.usenix.org/conference/atc19/presentation/jangda

Anything CPU-bound is a very bad fit for node. But most web services are IO-bound, and Node is excellent for them.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#25
post #23

It wasn't obvious so I checked: zero runtime since it typescript and the @types/aws-lambda stuff is not needed in resulting compiled JS. Still I'm not sure what this does beyond until functions for events you receive in Lambda and have to parse raw yourself?

I meant util functions. Silly mobile HN clients, bah!

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#26
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

Friction is less when I write node.js application. This language and runtime keep evolving.

Sometimes I can remove dependencies and code because they are replaced by the new feature of the runtime, thus the maintenance becomes easier.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#27
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

With respect to AWS Lambda specifically, a real consideration is how fast the context loads. In the absence of warming schemes, any performance gains you get using Java for example, might be out weighed by the the cost of loading a much larger (in size) context. In general, the zip for the Lambda implemented in Nodejs is going to be considerably smaller than the zip implmented in Java.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#28
post #8
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

Main strengths: * The ecosystem is pretty strong and constantly evolving. Lots of companies and individuals are putting a serious amount of work into making high-quality tooling and libraries. (Although with that also comes a lot of lower quality stuff and its sometimes hard to tell) * The language isn't owned by any single company and is well specified * TypeScript provides a powerful and flexible type system with a…

> (mainly TypeScript) - Insufficient reflection capabilities

You can always use the compiler api to extract type information. Sure, a bit tricky but doable.

The compiler api exposes a lot of awesome things, I'm suprised there aren't that many tools that use it.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#29
post #20
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

Node is especially good at handling async stuff. It’s in the JavaScript DNA. Whether through callbacks, Promises or async/await. As many backend apps are basically tying together 3rd party and 1st APIs it’s actually a very logical choice.

Kind of silly in a lambda though, as lambdas do not run concurrently. A bash script would suffice.

Re: A 7KB AWS lambda Node.js library with zero runtime dependencies

#30
post #2

Not knowing this myself, could someone explain the attraction in using a web scripting framework for stuff like this? I get that this particular example makes the whole thing seem fairly straightforward, but have never really heard why people like adapting Node.js and similar to non-web environments beyond "you can". Is there anything more to it than that?

With respect to AWS Lambda specifically, a real consideration is how fast the context loads. In the absence of warming schemes, any performance gains you get using Java for example, might be out weighed by the the cost of loading a much larger (in size) context. In general, the zip for the Lambda implemented in Nodejs is going to be considerably smaller than the zip implmented in Java.

NodeJs, in particular, out performs all language run-times in terms of AWS Lambda cold-start time (https://levelup.gitconnected.com/aws-lambda-cold-start-langu...
Post reply on HN