Live data from Hacker News

Deno 1.14

deno.com

81–90 of 111 posts

Re: Deno 1.14

#81
post #8
post #2

Only tangentially related, but what's the point of a static class block? What problem does it solve that's not covered by either the class constructor or a static const? Doesn't it introduce a weird (stateful!) computation that's hard to reason about? There's probably a use-case I'm missing, because intuitively I'd automatically classify it as bad a practice.

> Doesn't it introduce a weird (stateful!) computation that's hard to reason about? Yes and no. For example, maybe you want to initialise a temporary directory on the filesystem for writing files to, for some caching mechanism. The pointer to the cache directory (maybe a const x = {}) can exist anywhere, but spinning up the directory itself in the static class block ensures that it's set up once and only once for all…

That's a pretty terrible example. No way do you want temporary directories to be created just by loading a class. That violates all sorts of best practices.

There's a better example here: https://v8.dev/features/class-static-initializer-blocks

You could also use it for initialising generated constants.

Re: Deno 1.14

#82

How many runtimes are there for JS? They seem to pop up once a week...

Practically, number of browsers + 2 (Node and Deno, and Deno is stretching the definition of practical at this early stage).

Edit: + Electron + the JS runtime used for Windows ecosystem based on Chakra (not sure if that's still alive though?) + a few other similar ones in that vein for desktop or mobile OS'.

+ whatever is available for embedded & similar devices, (I guess there will be a few but I know little about that area).

+ various [highly] specialised business/academic/hobby/PoC/etc runtimes, but they're not realistically things that many people care about.

Re: Deno 1.14

#83

How many runtimes are there for JS? They seem to pop up once a week...

follow up question: how many different incompatible ways to require(), import … are there?

Two (import + require, which, as import didn't exist, was necessary). Most current tooling is built to handle both (Deno draws a line under it by disallowing the older one)

Re: Deno 1.14

#84
post #58

Earlier quoted context omitted.

Node is from the days before ES6 and uses a different API. Should just kill it and start fresh. Deno conforms to modern JS standards and is much more pleasant to use in pretty much every way.

I agree that that's the direction of the future. I wouldn't start a new, important project with Deno just yet. It's still the early days.

Yeah, things like Oracle drivers might be nice.

Re: Deno 1.14

#85
post #44

Does anyone know if Deno has undergone a security audit yet? I'm interested in using it as a sandbox to run user-submitted JS, and I know its permission model is powerful, but I don't know if it is formally certified (if that's even a thing) and if you can prove that there can't be some exploit that can be used to break out of the sandbox.

If you’re thinking of V8 isolates, I believe Cloudflare was running their edge compute product using that.

Re: Deno 1.14

#86

One of the most exciting opportunities IMO that Deno opens up, compared to most traditional server-side frameworks, is the possibility for simple url-based live-reload workflows in production. I'd love to be able to develop backend services by pushing source code to some url as I develop, and then have the production instances of the service notified of the changes and reload themselves immediately for a super-tight…

This is a really old concept with interpreted languages, Capistrano in Ruby came out in 2006 for this sort of workflow: https://en.wikipedia.org/wiki/Capistrano_(software) 10 year old gist for this exact thing: https://gist.github.com/rchampourlier/1281506/a22148264c457ebb69259261f117548569be6bef Same exists in Node, using PM2 process monitor via rsync/ssh: https://pm2.keymetrics.io/docs/usage/deployment/ Run a comma…

Arguably, this is the model of CGI, which is about a decade older. Every time you hit a page on a CGI-powered service, it starts up a new process that runs your script. So you just edit a shell/Perl/PHP/Python/etc. file in place (or edit it locally, and FTP/SCP/etc. it to the remote host) and immediately on the next page load you see the impact of your change.

It was kind of the original "serverless" - you'd often host it on a shared (multitenant) server with other users, with someone operating the web server for you and providing you with storage space. And it was a great development experience for small sites, especially for people new to web programming, and I miss it a lot.

For performance reasons people built "FastCGI" where you have a long-running process that handles multiple requests, and for software engineering scaling reasons people moved away from the model of one file on disk per URL (and URLs mostly mapping to file paths on disk), and then eventually we got the setup we have now.

Re: Deno 1.14

#87
post #8

Earlier quoted context omitted.

> Doesn't it introduce a weird (stateful!) computation that's hard to reason about? Yes and no. For example, maybe you want to initialise a temporary directory on the filesystem for writing files to, for some caching mechanism. The pointer to the cache directory (maybe a const x = {}) can exist anywhere, but spinning up the directory itself in the static class block ensures that it's set up once and only once for all…

That's a pretty terrible example. No way do you want temporary directories to be created just by loading a class. That violates all sorts of best practices. There's a better example here: https://v8.dev/features/class-static-initializer-blocks You could also use it for initialising generated constants.

What’s the difference from declaring the entropy pool in the example outside the class, in the module scope? Still private, still a single shared value.

Re: Deno 1.14

#88

Deno is awesome, and it's great to see the WebCrypto additions! My current top feature request is that I wish Deno would have the same permission model for the repl. I highly recommend listening to this recent podcast with Ryan Dahl: https://changelog.com/podcast/443

That would make REPL difficult to use, since you would need to know in advance what you want to do to pass the right permission flags. REPL is particularly useful when trying out things "live" as they come into your mind.

A common use case for a repl is to copy and paste code into it, or to give code to someone and have them run it. It's nice to not have to think about what the code could do to the system before running it.

Re: Deno 1.14

#89
post #78

Earlier quoted context omitted.

If you happen to be on mac, there's an app called finicky that does this. It can also pattern match on source application which is pretty handy.

I'm not, but that's nice. Pattern matching on the source application is actually what I would have preferred (and what I kept looking to see if anything on Windows could provide), but never found anything. Matching on the URL actually works well enough though, which I know because my prior workflow was just a work container tab in Firefox with the Container Proxy extension to proxy only those tabs in that container,…

barely related:

https://github.com/da2x/EdgeDeflector

https://gist.github.com/GeeLaw/782d1ff3cf4f990c61ba1cc20ddf4...

Re: Deno 1.14

#90
post #78

Earlier quoted context omitted.

I'm not, but that's nice. Pattern matching on the source application is actually what I would have preferred (and what I kept looking to see if anything on Windows could provide), but never found anything. Matching on the URL actually works well enough though, which I know because my prior workflow was just a work container tab in Firefox with the Container Proxy extension to proxy only those tabs in that container,…

barely related: https://github.com/da2x/EdgeDeflector https://gist.github.com/GeeLaw/782d1ff3cf4f990c61ba1cc20ddf4...

Much appreciated! The first looks to be an example of how to register the handler through an installer, instead of the registry hack I'm doing (since MS only wants things actually installed and visible in Add/Remove programs to be protocol handlers, for obvious reasons, even if annoying), and the second isn't barely related, it's looks to be essentially the same thing but in C. Here's mine for comparison: https://github.com/kbenson/urlswitcher-deno
Post reply on HN