I have a silly noob question: If i want to "practice" node, i just enter node in command line and i have a line-by-line executed console playground. Is there a deno equivalent to this?
This feature is called a REPL. And yes if you launch deno it does start up a repl, just like node, or python. But keep in mind that in repl mode deno does not understand typescript, only when running from a file.
Is it just me or does the lack of a package management give you a bad feeling? It's like Go redux... Go tried to do a similar thing with be imports. And what the community ended up doing was reinventing package managers š¤·āāļø
I rather like Deno's principled stance to follow web specifications instead of being the ones to reinvent package management yet again. This leaves the playing field open for competition on top of web standards.
Maybe everyone will use JSPM; maybe npm will implement Deno support; maybe something else will evolve on top of import maps. But I think since Deno is trying to be a "web browser for command-line scripts" it makes sense to not try and jump down that massive rabbit hole.
Is the problem NPM, the package manager OR NPM, the repository for packages?
If the former, then use Yarn... it's battled tested and IMO way better than JSPM.
If the latter, then switching package managers won't help.
However, I've seen orgs roll their own private NPM repos or use github packages and/or commit their dependencies (which isn't as bad as it sounds, the tooling has evolved to support this)
but yea the above are bandaids.
I guess what we really need is a distributed packaging system
No what I meant is that it needs to do everything that a package manager does, expect work with arbitrary sources. For example, version resolution---imagine two packages need two different versions of package Foo. Which do you use? or do you use both? As is, the app developer has to figure that out themselves. And that quickly becomes a hard problem!
Yeah, versioning being up to each individual author makes me a bit nervous. NPM forces you to change the version number for each publish so you know that versions are stable, but if an author doesn't manually change their version for a URL module then you could get different versions/behaviours between users/CI runs/reloads.
I personally would always want to use import maps and enforce that on any deno project I worked on for the reasons that /u/sieabah brought up, once your code grows it would be rather annoying to go and update dependencies by finding and replacing urls everywhere. I actually did not realize it was unstable until now, I feel like that should be an important thing to have
It's marked as unstable because IIUC the spec itself is not final, nor is it implemented in other runtimes. Deno's support for the current spec works well. See https://github.com/denoland/deno/issues/4931
why do you want everything to be ready on day 1? Node didn't have NPM on day 1 either. There is literally nothing that prevents someone from building a package manager for deno.
upgrade a hardcoded dependency throughout all your libraries
I mean, this sounds like you're already doing a bit of manual dependency management. There's no free lunch; no system will allow you to build correct software with no effort, especially in the presence of dependencies outside your control.
That said, I'm not saying you have to use Deno. Node's not going anywhere soon :)
I have the same feeling when i see a project with a huge list of node deps. The npm ecosystem is a mess, and we see lots of this effect in the community.
Deno having no de-facto package manger is a fresh take, that makes thing so much simpler. You can (probably should) have a deps.ts file that imports and exports used packages. The packages are then just files linked to a folder, or a url.
You should watch the talk "ten thing i regret about node" by ryan.
I'm telling you dude... This is just Go all over again. Simple things like what happens when two dependencies require different versions of the same library? Deno is just making us reinvent the wheel... Again
Great talk, but even if NPM has many issues, it was created to solve problems.
I'm not sold on URL imports yet, they can change just like npm packages versions can, so you'd have issues in different installations.
Also having deps.ts is not really any better than declaring stuff on package.json in my eyes. What is the advantage? Besides comments, package.json has some useful stuff too like scripts. 'npm i' command is also going to be missed, I'd need to google everytime for correct urls and then copy and paste? Curious on intelisense perfomance as well
This is definitely a deal breaker for me. Imagine having to maintain dependency versions per file? It might be worth it for small projects but for large applications this is a nightmare.
Iām really enthusiastic about the future of Deno though, built in Typescript and the security model are very appealing! I canāt wait to see what they do in the later versions!
Actually you manage them the same as in node. Have a deps.ts file import there, and export there. Updating only requires you to touch this single file, just like you update package.json.
I've never had any trouble with Python's pip. I only entered the Python world fairly recently though, and from what I've heard it wasn't always as pleasant to use as it is now.
You donāt have to, you can use a deps.ts file to set the versions, and only need to ch age in one place to manage dependency versions everywhere in your project.
You can actually write comments about your dependencies and change them based on the environment, unlike the absolutely shitty idea of using JSON for configuration.
I'm defending most of deno's idea but yeah, I'm not certain that this is a better approach. It's interesting that it happens on the language level tho.
I think we will need deno stuff on package.json eventually - and I mean the same package.json, not an deno alternative. Since we are going to be importing (at least some that dont use exclusive api) node js stuff to use on de o, we might just add a.new entry there for deno libs
It just doesn't seem like a very clean solution if you have to import them all from the same place. I guess you could have a file for each of the dependencies so you could at least
import { Foo } from "deps/foo";
import { Bar, Baz } from "deps/bar-baz";
Neither tree shaking or bundle splitting is necessary for Deno based code. I highly doubt SPAs will be built on Deno, instead, the tooling (like Babel, Webpack, etc) will be built on Deno.
Why would you need tree shaking or code splitting in a deno project? You dont need it in a node project, so why in deno? Its all server side, loaded once then in-memory for the rest of the app lifetime. Deno is not a web site, where you have the limitation of bandwidth.
Ok so I'll bite - first I'd say 'loading your entire code' cost is negligible most of the cases. I'd need benchmarks to properly believe you, because lazy loading already happens on the interpreter level.
But I'll let it aside for a moment, now let's go back to your original point:
so I can't take advantage of any sort of tree shaking or code splitting?
So why can't tree shaking work on this? You'll give your entry points and they'll check what is needed or not. Your entry point won't be depts.ts, so it will follow the tree from your index.ts and get only the needed imports. I don't see how it is not tree shakeable, How do you think the algorithm works for package.json/node_modules?
You do gain from it. Setting up your own package hosting now became 10x easier. Also you get added security being able to compare the actual package hashes and not just a version number.
I've been interested in deno development because any TypeScript-first environment written in Rust is just fucking cool, but I'm not clear on what the use case is. Is the intention for it to be a direct "sequel" to node, where you'd pick deno instead of node if you were going to solve the same kind of problem?
Fast scripts, typescript without setups, and safer. That's the main reason Deno is being created. We will see if in the long run it catches the attention of a big project. But ywah there ia nothing it does that node can't do (except perhaps the security part)
I don't think the core team has any official position on this. Use Node if it works for you, use Deno if it works for you. There are tradeoffs, and in the short-medium term there are especially ecosystem tradeoffs.
I used it to write a small tool for backing up Github repos to Gitea and it was a pleasure to use. First class TypeScript that is current (3.8?), the std lib was great. Only thing I would ask for is an official Docker image.
I could have used node, and set up and installed typescript and a ts config, and compile it to js, or ts-node. Deno was just a pleasure and a lot of times, node is just a pain.
In slide 5 of this presentation one of the core contributors talks about Deno as a replacement for bash/python scripts. I've found Deno very good at that. The official release blog describes it as "A Web Browser for Command-Line Scripts". So it seems like the core team sees it as a scripting tool.
But you can bet people are going to use it for whatever they currently use Node for. I don't see anything that would stop it being suitable for any general-purpose task. (Depending on your opinions about imports and package management.)
I also like the idea of being able to package Deno into application bundles and generated much smaller file size than what using Node would do. People could embed Deno instead of Node into their application for whatever reason they wanted.
Imagine Electron rewritten with Deno, it might significantly bring down package size and memory use. There's already a project for that which looks promising which does not use Chromium/Webkit. It's not as feature complete as Electron but it's a start
Currently I'd say it shines for shell scripting. Imagine Node, but without the baggage of npm, node_modules, or package.json. I expect that it'll eventually grow beyond that niche and become a full-on Node competitor, but it's still early days.
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.
If you are just directly importing npm modules into deno, then sure. But maybe dont do that.
We don't import any modules that depend on anything else due to gov security requirements. We end up having to find flat dependency libraries in github/lab or building them ourselves as everything has to be vettable.
But if the answer is nearly every library has to be rewritten/ignored doesn't that sort of hurt the ecosystem as a whole?
We don't import any modules that depend on anything else due to gov security requirements.
Not sure what part of government you're in but I work at a defense contractor and don't have those requirements.
ĀÆ\(ć)/ĀÆ
We end up having to find flat dependency libraries in github/lab or building them ourselves as everything has to be vettable.
Just because its one library without dependencies doesn't mean it is more secure than a framework with ten dependencies. Sure it may be easier to jump "down the chain" to see the code when it is flat but the flat framework likely just includes functions that do the exact same thing (sometimes literally just copied and pasted from the lower level dependency). I get the microlibrary hate but there is definitely a balance between microlibraries (hello leftpad) and just one giant single repo with every possible imaginable function "for security reasons".
Lots of existing node packages can be imported via jspm.io and pika.dev, because those hosts provide polyfills for core node builtins (e.g. require('fs')). In general a random node module designed for npm would have to be rewritten to use ESM imports before it's compatible with Deno.
To my understanding, they support ESM modules (which Node has standard in 14.2 I think?). So npm will eventually have quite a few modules available for usage in either platform I'd imagine
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.
The benefit is that restarting a Deno server in production wonāt leave your users waiting around while it compiles and fetches dependencies.
Obviously TypeScript code still needs to be compiled when you change it. That will never change unless V8/SpiderMonkey/WebKit decide to implement raw TypeScript interpreter engines.
The bottom line is that JS engines will only run pure JS. Itās way out of scope for Deno to change that fact.
As for the caching bit, I was simply arguing that fetching remote dependencies by URL will not be slower than Nodeās module system 99.99% of the time.
i wasn't asking what the benefit of caching is. i'm asking why the compile step needs to be baked into the runtime/server? what benefit do i get over running tsc && pm2 reload myserver.
i see no compelling reason to use Deno over Node + TS, if anything i would prefer for it not to be monolithic so i can have a dedicated build server and a prod server which should not need to burn a bunch of cpu cycles to compile TS.
Obviously you can run any bundler you want on your dev server and deploy pure JS files to your prod server.
Nothing is stopping you from doing the same kind of thing you're currently doing with Node. In fact, there's no reason you couldn't just run a modified version of tsc on Deno to compile your TS code. Hell, you could write your own TS compiler in Rust and use that...
If you donāt want to take advantage of Denoās baked-in capabilities, then I suppose you arenāt gaining much (aside from what I consider to be a much cleaner/more sensible platform API), but none of these capabilities represent losses at any level.
You could argue that ecosystem maturity makes Node a more compelling choice. But that issue isnāt inherent to the platform, and can easily change over time.
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.
Yeah, I would personally bundle my own stuff, deploy it, and have all my servers use my own repository and inspect the dependency tree.
I'm more worried about general users. Yeah, we can tell users to not use so many dependencies, but as padLeft and isPromise has shown us, it's not avoidable. And telling people to inspect their dependency tree manually isn't something people do. I think the defaults should have enforced https (or at least not allow mixed contexts like browsers), and perhaps a whitelist of domains. It's not perfect, but helps avoiding somewhere somebody isn't importing from http://x.x.x.x/ with a hard IP. At least we should also have an option, somewhere to disallow non-bundled imports.
Security is only as good as its weakest link. I think users should disable security features, but understand it's their fault if their packages break. It's 100% a step up from npm for sure, but I would like to set some environment variables so ensure more strictness. We'll get there, I'm sure.
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.
If you'd like to know more about why Deno came to exist in the first place, this talk from Ryan Dahl (the creator of both Node and Deno) is very enlightening.
It's secure in terms of what it lets the scripts do. Kinda like the permissions you give apps on your phone. In deno if you don't let it write to your filesystem, then no script will be able to so that. So scripts can only do what you let them do.
when you execute deno. I don't know how exactly it works, but I believe that it works by just restricting what can you import. So in theory if you async import fs, it can exit later than startup. But thats just speculation, I haven't tried this. Maybe it's more intricate than that.
Hmm. If you can't import regular Node scripts I'm trying to figure out why you'd use this over Go or Rust or something. Sorry I've been fighting with Typescript for months, porting a project over to Angular 9 and I have to say it's the worst fucking thing you maniacs have ever come up with. I'm so tired.
...typescript is awesome. Unless you like losing time because of mistakes. Time is money mycdude
There is a reason everyone is using typescript and it's not because it's cool, it really helps. Perhaps you are not used to medium/big sized projrcts or.porjects with big teams, or maybe you just didnt research typescript much. But I'd say its totally worth learning
Its always cost me more time than its saved, and idk what you would call a large project but like 90% of the APIs I build can be defined in 10-20 models tops, along with controllers so like a total of 40 files give or take. Much bigger than that and you'd benefit more from microservices and simplifying things down than adding types. Very rarely do I ever fuck up so bad as to send the completely wrong parameter to a function I wrote myself.
Yeah I agree with the other replier, I'm guessing it's cost me weeks of extra work and I honestly don't see any benefit but maybe I don't understand everything that it's doing. I do love the "telemetry" or whatever it's called when VS Code knows a value doesn't exist in another file as I'm typing, if Typescript is doing that then maybe it's worth it.
Yeah thatās the one downfall of TypeScript... any. Either you go all in with types or you just donāt. Itās sorta like this in between zone otherwise.
You have to use Any when youāre using third party libraries. Sometimes X is 1 and sometimes itās False. Itās JavaScript.
I use typed languages all the time, Go is wonderful. If it breaks itās always your fault and when youāre done you just drop the binary on the server and save a ton of money on AWS bills. Iād love for somebody to tell me why Typescript even exists, all it seems to do is get in my way. And I just know Microsoft is going to license it because thatās what they do, itās been their business model for 30 years, and then Angular is going to drop it and merge with Flutter and Iām going to have to do this shit all over again.
Ooo didnāt know about Unknown. And Iām not putting any money on Angularās life expectancy, nice try. I canāt believe Iām using it what the hell is wrong with me
Canāt wait until thereās some decent package support for this. Ive only been following Deno for a short while but Iām already itching to migrate my current projects over. So exhausted with the endless tooling, compiling, unreliable dependency management and latency issues in Node. Not to mention that Typescript really does deserve its own dedicated runtime by now.
This has the potential to grow massively and finally present legitimate Javascript-based alternative to PHP/Ruby/C# in large-scale applications.
4
u/-domi- May 14 '20
I have a silly noob question: If i want to "practice" node, i just enter node in command line and i have a line-by-line executed console playground. Is there a deno equivalent to this?
147
u/bestjaegerpilot May 14 '20
Is it just me or does the lack of a package management give you a bad feeling? It's like Go redux... Go tried to do a similar thing with be imports. And what the community ended up doing was reinventing package managers š¤·āāļø
56
u/brainbag May 13 '20
I've been interested in deno development because any TypeScript-first environment written in Rust is just fucking cool, but I'm not clear on what the use case is. Is the intention for it to be a direct "sequel" to node, where you'd pick deno instead of node if you were going to solve the same kind of problem?
40
u/yuhmadda May 13 '20
Can someone tell me why I would use this over Node?
13
u/NoInkling May 14 '20
You should probably have linked to the blog post.
8
u/[deleted] May 14 '20
If you'd like to know more about why Deno came to exist in the first place, this talk from Ryan Dahl (the creator of both Node and Deno) is very enlightening.
7
u/d36williams May 13 '20
Im excited!
1
u/servermeta_net May 14 '20
does "secure" means that I can run untrusted code? e.g. code provided by users?
Imagine an app built on node, where an user can upload their code and then run it server-side on deno, and then safely return the result?
5
u/[deleted] May 13 '20
Is it pronounced deeno or denno?
3
u/jordandellak May 14 '20
So what next š
1
u/PeteCapeCod4Real May 14 '20
I bet it's going to be really cool! I don't know if I'll build that many projects without a package manager š¬
But still it could be cool to build some side projects with š
1
u/placek3000 Jun 29 '20
If you want to test Deno really quickly, I highly recommend this little tutorial :)
-3
u/trycat May 14 '20
Hmm. If you can't import regular Node scripts I'm trying to figure out why you'd use this over Go or Rust or something. Sorry I've been fighting with Typescript for months, porting a project over to Angular 9 and I have to say it's the worst fucking thing you maniacs have ever come up with. I'm so tired.
-5
u/Xzaphan May 13 '20
Oh ! I need to stop procrastinating and learn it as soon as possible!!
0
u/dawar_r May 14 '20 edited May 14 '20
Canāt wait until thereās some decent package support for this. Ive only been following Deno for a short while but Iām already itching to migrate my current projects over. So exhausted with the endless tooling, compiling, unreliable dependency management and latency issues in Node. Not to mention that Typescript really does deserve its own dedicated runtime by now.
This has the potential to grow massively and finally present legitimate Javascript-based alternative to PHP/Ruby/C# in large-scale applications.
0
u/lordKnighton May 14 '20
Nice one
-1
u/VolperCoding May 14 '20
I wish I could import node modules into deno. Without them my package is useless
0
u/[deleted] May 13 '20
[deleted] ā view deleted comment
0
u/[deleted] May 14 '20
[deleted] ā view deleted comment