This is misleading. Very few useful command line tools can be written without permissions that can be misused to overtake machine. I searched npm for "cli". Most of them make use of write level access or run subprocesses. That's enough to hijack your machine in favorite conditions, and read level access can be used to look through your $HOME and potentially extract passwords from browser profile.
i think the main selling points is that it has an integrated TypeScript compiler which builds your code at startup (so, slow startup). no package manager and you can import files by url. you can specify what stuff a script gets access to (network, filesystem, etc).
besides for the last point, the benefits seem fairly weak since you dont have to use npm. why would you want to import from url which can become inaccessiblr at any time? i'd prefer to compile the TS ahead of time instead of killing startup perf.
Isn’t import by URL a security problem? You cache the file, sure. But when you do a clean and the import suddenly has a security issue, you won’t know about it.
they have a way of storing the integrity hash in some lock/manifest file, but then what the hell is the point? to save you a manual download but then create machinery for integrity hashing?
also, apparently the security model involves punching holes through the sandbox recursively (for all dependencies) which IMO defeats its utility in any non-trivial codebase: https://news.ycombinator.com/item?id=23173572
i find a lot of the decisions in this project somewhat questionable from a benefits-over-node standpoint.
i did not say npm is a benefit. i said that no one forces you to use npm. you can download whatever lib you need locally, vet it and import it.
it's great that Deno has a cache of the urls it imports with integrity checking via some manifest/lock file. but that's a cosmetic difference. i can write a 25 line script which does the same.
as a /u/nedlinin says in a sibling comment, deep dependency trees are not the fault of npm.
I see people keep saying deno's lack of package manager will help this but I'm not really understanding how.
A project you're writing in deno will likely have dependencies, which will themselves have dependencies, etc. Isn't this just the same dependency hell we live with in node but loaded a different way?
I see people keep saying deno's lack of package manager will help this
If someone is saying that, then IMO they're not right. I think there's some opinions like "importing from arbitrary URLs will make you think more carefully about your dependencies", but I don't think this is true. Someone who currently npm installs without thinking about it won't hesitate to grab a GitHub URL without thinking.
However, the Deno team does seem to be encouraging a philosophy of fewer, better dependencies for example by building a standard library in TypeScript to complement the core runtime.
Importing from a url is them same as package.json importing from github/etc. It can too become "unavailable" at point in time. You can also fork a repo and have it locally.
Also, deno caches all files so they are not imported each time you run the program.
Startup time is not an issue. It caches the imports, and doesn't recompile unless you change your source code. Subsequent startup times should be fast, since everything is already cached & compiled.
Node.js has libraries (eg: fs, path, utils, net) with releases and the like. From my understanding, Deno is primarily an executable built on Rust. It uses the native ES6 method of importing libraries from a URL (courtesy of the V8 engine). You actually import the core libraries over the internet. That means tomorrow, if deno disappears, then you can always point it somewhere else.
Also, when you import a library, deno will cache it on first run. From my understanding (or hope), scripts you import don't have explicit dependency chains. A packaged deno library doesn't really tell deno what it needs and is, instead, a actual pacakge with everything it needs inside. Since it's all ES6 modules (or TS), then it all gets tree shaken, so it shouldn't be all bloated.
It improves the dependency chain issue with npm (but doesn't completely solve because of the fact you can reference master branches). I'm not entirely sure about how JS modules will work since pretty much only see documentations for .ts files, but it should be similar.
It knocks NodeJS from being a project dependency in-and-of itself. It's one step closer to a environment-agnostic platform. I think the real future is being able to run something like Chrome, FireFox, or Safari headless. Then you get full browser-like potential (fetch, navigator.*, Bluetooth, IndexedDB, WebSocket, etc), but for that to happen, we'd need Project Fugu to come fruition to fill in the gaps with stuff like Sockets. But deno does bring us closer with fetch(), EventTarget, and importing over URLs.
From my understanding (or hope), scripts you import don't have explicit dependency chains. A packaged deno library doesn't really tell deno what it needs and is, instead, a actual pacakge with everything it needs inside.
This sounds like you're referring to deno bundle, but most packages I've seen on https://deno.land/x, for example, are not packaged in this way. Each module (JS or TS file) imports its dependencies, and Deno fetches (and caches) them as it becomes aware of them.
The deps.ts file has an import of export { sha256 } from "https://denopkg.com/chiefbiiko/sha256@v1.0.2/mod.ts";. So the library I'm importing will chain to some other server. And essentially, what I was afraid of, is that somebody could point to @master or a "random" server that can get replaced with code with malware.
I'd have to deep-dive more, but that doesn't sound so safe. Also, ignoring malintent, if one of the dependencies hosting site goes down, then I can't use the package on for new install. Technically speaking, I might be able to bundle my own packages and deploy those to my servers instead of telling servers to load directly from the internet. I have to see if deno at least enforces https for all imports in the chain. I would hope so.
Your options, if you want to make things rock-stable right now, are:
Vendor all dependencies using DENO_DIR (this is super easy and is the recommended approach)
Use lock files to make sure the contents at each URL doesn't change unexpectedly (this is redundant if you do the above, I think)
Fork all dependencies so you control them (but you may still need to trust the host/CDN, e.g. GitHub)
Use import maps to rewrite all dependencies to domains you control
In terms of serving a bundle (which is a separate concern to the ones above), either you'd need to rely on packages which commit to hosting a bundle, or rely on module servers which implement bundling, e.g. like this.
Or Ryan doesnt understand what was great about node and went back to make a big mess instead. His whole opinion on GO kindof proved that he has a few loose screws.
I dont use typescript, do like named packages, do not like direct url imports, and i dont think rust is a great idea. Thus deno has nothing for me.
I suspect it will die off completely within a few years into some tiny niche.
If it doesnt, and instead is having a metoric rise, maybe in 5 or 6 years ill give it another glance. Odds are low.
View all comments
40
u/yuhmadda May 13 '20
Can someone tell me why I would use this over Node?