9 ms·
Deno 1.35: A fast and convenient way to build web servers
- danpalmer 3y agoThe thing I don't quite get yet about Deno (and maybe some other similar things), is that do so much that they need to be perfect to be worth using. Deno is effectively a language and runtime, webserver, package ecosystem, and arguably infrastructure and database. When choosing the technology to use for something that feels like a lot of eggs to put in one basket. Sure there are benefits to bundling like this, but the downside is that you're more exposed to bits of that bundle being insufficient. Maybe this criticism doesn't play out in practice, but Deno and some other things trying to re-invent Javascript again, seem to be trying to do too much at once, and are risking ending up too far away from the original ecosystem to be able to return. Now maybe the only way to re-invent JS in a convincing way is to do these wholesale rewrites making big divergences, but then again, perhaps that just indicates that JS is not the foundation that it needs to be for some kinds of development. Note, I've said JS as a grouping of the JS/TS ecosystem and existing packages. I don't think TS changes things that much as it's still the same ecosystem of tooling for the most part.
- jitl 3y agoThe status quo comes from tools that do just one thing or that compose a lot of other tools. And I don’t think too many people are excited about the status quo. Deno’s pitch to me is to take everything that makes Golang work so well, and apply it to JS/Typescript. I can’t switch yet but I sure would like to!
- G4BB3R 3y agoThey are doing too much at once, but I think it's possible, since they are a company, and last year raised $21M. https://deno.com/blog/series-a https://deno.com/blog/series-a
- sondr3 3y agoI like Deno for many of the same reasons I like Rust and Go, the tooling comes bundled with the runtime. No fussing about with ESLint/prettier/tsconfig/bundling and all that jazz, Deno includes it all. The dependency story was a little rough for a while but with import maps now it’s really quite nice. With the npm ecosystem integrations it’s starting to be a very nice developer experience.
- danpalmer 3y agoI guess this is part of my criticism. It's nice to have all that stuff bundled, but it's banking a lot on the decisions being the right ones for your project. When it's just the language, linter, formatter, that might be fine. Adding the package manager is often ok as well, but even Rust/Cargo aren't fully coupled. But then adding a package ecosystem (that isn't fully compatible), a server, infrastructure, database.... it's a lot of decisions that all need to be good enough.
- ravenstine 3y agoNo one's forcing anyone to use those things, though. I think the benefit of having those wrapped into Deno is that they'll presumably be performance optimized, but it's just as easy to use JS instead of TS, use ESLint instead of `deno lint`, Prettier instead of `deno fmt`, or whatever. Those are kind of evergreen toolchain concepts that I think benefit from being standard to Deno, even if their implementations are minimalistic.
- pjmlp 3y agoI think similarly, note my usual comments about guest languages. Typescript gets the pass, because it basically a JavaScript linter, with an easier way to get modern JavaScript features, without wrestling with babel and friends. Projects dictate language toolchains, not the other way around, and so far I haven't seen any project or product SDK placing Deno on the tooling requirements.
- skybrian 3y agoMaybe this doesn’t count, but Deno Deploy dictates Deno. I’m finding it pretty nice so far. It will be more compelling when the FoundationDB-based KV store is finished. At that point there will be enough to write full web apps without any external API’s, so I can use it to build the simple hobby websites that I used to use AppEngine for. (For now I’m trying it out using Neon for Postgres.) It’s still for developers rather than nontechnical users, but this may be simple enough to deal with that it does some of what Sandstorm promised to do for things like blogging. Or maybe a personal Fediverse server? It would be nice to have a second source for Deno-based hosting, but in a pinch I could put Deno and my apps in a Docker container and run it anywhere, though probably not for free.
- user6723 3y agoDeno was created by the guy who created NodeJS, so it might be good for JS projects.
- brundolf 3y ago> a language and runtime, webserver, package ecosystem, and arguably infrastructure and database Some gentle pushbacks: Runtime and webserver yes (though not web framework), language sorta, though Node is already just as much all of these things Package ecosystem also sorta. Any Deno module that doesn't use the Deno APIs is isomorphically runnable in the browser and most other JS contexts. This is actually more true than with Node, because idiomatic Node code uses CommonJS imports which are incompatible with the browser without transpilation Infrastructure I don't think is really true; obviously there's Deno Deploy, but I don't use that for any of my Deno projects. If anything, the fact that it's so self-contained makes it more flexible to different kinds of infrastructure. All you need installed is the runtime, and then you run a single command and you're off to the races (with dependencies downloaded automatically as needed) I think it strikes a great balance between batteries-included and compatibility. It's become my favorite default way to write a CLI or a web server
- steve_adams_86 3y agoI had similar hang ups about deno but my experience aligns with what you’re saying. I hit far fewer snags than I thought I would (none I suppose), and the tooling off the shelf was excellent. I was off and running within 30m or so. I got a little confused about importing packages properly but it might be down to how my IDE handles stuff and not really deno-specific. I also love it for CLI work. I was using Go pretty much exclusively for years, but I’ve used Deno twice for real work and a bit for experimentation. Go offers some features I prefer, but Deno offers TypeScript which — for better or worse — is where I think best in code. I like to maintain it more, which means a lot for something I have to deal with next year.
- j1elo 3y agoWait, Node or Deno for CLI tools? I was reading this and thinking "Go would make a much better tool for that job", so after seeing that you have actually used it in the past, I cannot but ask about some more info or comments your might have about it. A language that is designed from the ground up to compile into standalone binaries seems so much more apt for CLI tools... Deno/Node, on the other side of the spectrum, requires a whole environment and runtime, which seems like a hassle. I know of vercel/pkg but that's not a first-class citizen of the ecosystem and has its shortcomings.
- IshKebab 3y agoDecades of experience has taught us that when you don't integrate the language, runtime, packaging and infrastructure properly you get a total mess, like Python or C++.
- chromakode 3y agoI trialed Deno for an HTTP+WS side project [1] and have been loving it. The simplicity of having Typescript built-in, the nice async APIs, and the sandbox permission system all make it a great choice for green field projects. I don't mind the url-based dependency system as much as I thought I would; with the language server DX it's easy enough to maintain. Deno feels like Node from 10 years ago, in both good and bad ways: every Deno native community library I've pulled in (redis, S3) has had significant bugs. Fixing them has been fun but distracting. Looking under the covers, I've found the code to be really clean as a result of Deno's abstractions. The improving npm support helps to make mature libraries accessible, but the Deno native libs also have a bright future. [1] https://github.com/chromakode/coalesce/tree/main/project-server https://github.com/chromakode/coalesce/tree/main/project-ser...
- dunham 3y agoI tried deno a while ago (over a year) and could not find a way to get deno and typescript to accept the same files. They disagreed about filename extensions in import statements, and I couldn't find a format that was accepted by both.
- AgentME 3y agoAre you trying to use Typescript separately from Deno instead of Deno's builtin support for Typescript? Are you using VSCode without the Deno extension? I think you're overcomplicating something if you're running into this issue.
- dunham 3y agoThat would be yes on both points. I was unaware that deno needed a separate vscode extension and did not know that deno ran the typechecking itself. I may give it a try on some personal projects now that I know this.
- chromakode 3y agoThe repo I linked to has an example of shared files between Deno and Vite. I'm using import maps to have a consistent `@shared/types` module between both (as well as consistent names for the requisite imports)
- datadeft 3y agoI am not sure if either fast or convenient applies here. Maybe I have different definitions.
- kamranjon 3y agoI think they mention fast because the built-in Deno webserver is now faster than node:http. I've been following Deno for a while, and even deployed a service with it, and it's awesome that it has finally surpassed node performance. I think if you've used Deno before convenient definitely fits, you can build quite a bit without needing external libraries, typescript by default, you kinda just start working on your problem - just a much cleaner version of what node could have been in my experience.
- porsager 3y agoJust use uWebSockets.js[1] in node, and you'll leave Deno in the dust again. (uws is also what's under the hood in bun) https://github.com/uNetworking/uWebSockets.js https://github.com/uNetworking/uWebSockets.js
- mmastrac 3y agoThe fastwebsockets library one of our team developed gives uWebSockets a run for its money under a lot of circumstances (though we trade performance improvements and the top spot back and forth). We're constantly working on improving the performance of Deno from top to bottom and it's a marathon. We don't want to be fastest at the expense of security or maintainability and the results from the last couple of months have been pretty awesome. I can't necessarily speak for priorities at any point in time, but I can say that performance is very important and literally what I'm working on most of the time.
- spiralpolitik 3y agoDeno is great. I put together a website using Lume super quickly and it was a refreshing change from using Node etc. Some annoyances, mostly around the Deno Deploy side of things, but otherwise I'm a huge fan.
- lemper 3y agogood thing I am not in position of power to choose the stack in my company. if I were, I don't think I'd pick deno over plain old docker container somewhere in someone else's computer. on docker, at the very least I know how to move my project somewhere else in case the data center is on fire.
- qbasic_forever 3y agoWhy wouldn't that be the case with deno too? Just move the deno executable, that's all you need to run it (and your code obviously) You can even just build and use a deno-based docker image like node or any other language image.
- triyambakam 3y agoDeno and Docker are orthogonal
- benatkin 3y agoIt's referring to the permissions system which sort of resembles container isolation. Only a bit, though. Something that resembles it a lot more is WebAssembly. There's a plugin system that has been shared by its creators around here a couple times: https://github.com/extism/extism https://github.com/extism/extism
- galaxyLogic 3y agoCan Deno output WebAssembly?
- ushakov 3y agoJIT is not possible in WASM. So, the answer is no
- benatkin 3y agoI used to think the sandboxing feature was going to be a really big deal but I don't any more. I think WASM is eating their lunch in sandboxing. I'm keeping a close eye on Fermyon and Dapr.
- qbasic_forever 3y agoDeno runs WASM code just fine and IMHO will probably be the pre-eminent way to use server side WASM (because you likely also need some JS/TS bootstrapping or glue code too for setting up a basic API or other endpoints): https://deno.land/manual@v1.10.0/getting_started/webassembly https://deno.land/manual@v1.10.0/getting_started/webassembly
- benatkin 3y agoIf you're writing your server side code in JavaScript, yeah. I don't think it will be pre-eminent. I think it could be popular but much less popular than Node. There are server side WASM runtimes for other languages, though. Including ones that let you write endpoints entirely with WASM (and its languages like Rust and Go*), like Fermyon and Dapr. * https://github.com/appcypher/awesome-wasm-langs https://github.com/appcypher/awesome-wasm-langs
- pjmlp 3y agoWASM is just application servers being talked by those that didn't lived through Java and .NET application servers. Now served with tons of YAML configuration files instead of XML, and being told to configure our own Kubernetes infrastructure on top of it.
- bilekas 3y agoThe axios redis And pupeteer support added is actually really important and only mentioned as a side note really. Super cool work going in. I'm new to the deno world but will be testing it out this week. I'm curious though the decision not to have a dedicated package manager on the first place? Maybe someone knows the reasons for this?
- lloydatkinson 3y agoWhat do you need axios for compared to fetch?
- bilekas 3y agoNothing that I can think of but that's not the point, the transition is easier without having to rewrite in deno native as i understand.
- mmastrac 3y agoAs part of my first couple of months of work at Deno, I wrote the new Deno.serve implementation that's being stabilized here. It's based on a thread-local slab that is wired into Hyper 1.0 (which is an amazing Rust webserver and nearing release). This gave us solid support for HTTP/2 in Deno itself -- you can start a full webserver on a TLS socket and start talking fully-compliant HTTP/2 in just a couple of lines. It's an interesting challenge to get this to cooperate with V8 in a performance way and we're continuing to work on it while keeping the code as maintainable as possible. The implementation will continue to evolve as we design better and faster interfaces between Rust and V8. The cool thing is that this is all going into open-source projects, either in Deno itself, rusty_v8 or V8 itself. Happy to answer any questions.
- galaxyLogic 3y agoSo how do I get the SSL certificate in there, does it come with it?
- tomxor 3y agoI found this: https://deno.land/manual@v1.35.0/runtime/http_server_apis#https-support https://deno.land/manual@v1.35.0/runtime/http_server_apis#ht...
- mmastrac 3y agoI would personally use letsencrypt and then pass the cert/key into the Deno.serve call, though I am curious now if there is a more integrated solution and I'm going to dig into it a bit.
- vbezhenar 3y agoUse Caddy.
- Aerbil313 3y agoYes, I too am too lazy to learn nginx, certbot or whatever those things are as well. Edit: I really am. Why downvote?
- tharos47 3y agoJust in case someone at deno is monitoring HN comments there is a typo in the third link resulting in a 404 : https://deno.com/manualruntime/web_platform_apis https://deno.com/manualruntime/web_platform_apis should probably be https://deno.com/manual/runtime/web_platform_apis https://deno.com/manual/runtime/web_platform_apis
- ravenstine 3y agoI use Deno for all my personal projects. It's not perfect, but the fact that it's so much closer to working in a browser environment really helps a lot in terms of mental modeling. Lately, I've had no reason to revert to using Node given the current level of support for NPM packages.
- JediPig 3y ago[flagged]
- deleted 3y ago[deleted]
- cdelsolar 3y agook what's the alternative
- msie 3y agoYou can use any other language on the server side. What would be good is if wasm had full access to the DOM instead of through some JS layer. Or maybe a new browser is created that did away with JS altogether. It's always been my dream.
- jweir 3y agoThere is no _the_ alternative. But there are alternatives. I would reach for Go. I’m not great at it but good enough that I know I can code up a server. And I know it will be be stable and simple to deploy - upload the binary and run it via systemd.
- msie 3y agoYes! I was inspired by levelsio's use of PHP but I don't want to use PHP. I was once enamoured by Python but it still hasn't fixed it's dependency management problems. Go occupies a nice place with the simplicity of Python but with static typing and better tooling.
- AtNightWeCode 3y agoCloudflare workers if you want JS/TS.
- msie 3y agoIf only Google had the courage to put Dart into Chrome...
- ushakov 3y agoI’m wondering how you implement Deno.serve on Deno Deploy? With CF Workers and Lambda you have to export a function
- mmastrac 3y agoThe same code works in both places - the deploy architecture seamlessly integrates Deno.serve with the deploy architecture that lives in front so it "just works".
- rs_rs_rs_rs_rs 3y agoAnyone knows if something similar to `deno compile` is planned for node in the future?
- okhuman 3y agoNodejs support for "single executable applications" is getting there - this issue below is preventing wider adoption at the moment: "The single executable application feature currently only supports running a single embedded script using the CommonJS module system." https://nodejs.org/api/single-executable-applications.html https://nodejs.org/api/single-executable-applications.html Should be an awesome game changer for node.js when the feature gets rounded out. Also check out vercel's `pkg`: https://github.com/vercel/pkg/issues/1291 https://github.com/vercel/pkg/issues/1291
- AtNightWeCode 3y agoLike over a year ago Deno raised $21M in investments and this is the current state...
- okhuman 3y agoA general hypothesis I have is that the Deno team is just taking on too much to make the investment work in terms of, well everything really: version compatibility to reduce breaking 3rd party libs, one-by-one certification of npm module compatibility, deno core module re-writes, a hosting company, maintaining developer tooling/ecosystem - to name a few.
- new_user_final 3y agohttp benchmark are mostly useless. Most of the benchmark re-uses connections. You will get around 14k requests/second if you close the connection for each request.
- joshstrange 3y agoI'm not using Deno yet (I'm about as bleeding edge I want to be with my serverless services built on TS) but I love these updates and look forward to the day that I feel like I can start to use it.
- jamal-kumar 3y agoWith all the hype around server-side webasm I decided recently I'd try to implement a project in this. Cool but just in case anyone else figures the same just keep in mind that webasm is still 32-bit and as such if you need more than 4GB ram in whatever you're doing, well, that's your ceiling for now until they figure that out come next year or so. The Deno ecosystem itself needs some work for sure. I think alot of other comments already said everything better regarding that but it's still nice to know that we have something to write typescript in that doesn't just target nodejs.
- andrewstuart 3y agoI tried to switch my nodejs project to deno and discovered it “just doesn’t work that way”. Deno is not a drop in replacement for nodejs, which is a pity.
- mkeedlinger 3y agoI don't think so. I don't want another nodejs. If I'm getting the same tradeoffs as nodejs, why not just use that? I like Deno specifically because of how different it is from node.
- bartlomieju 3y agoBartek from the Deno team here. Sorry to hear that - we made great progress in making Deno drop-in replacement this year, but we certainly are not yet there 100%. I'd love to hear what problems did you hit and look into solving them.
- andrewstuart 3y agoI don't recall but it felt like a distant goal at best. Is there a written guide for how to convert a nodejs project to Deno? I'd really prefer to be using deno instead of node. If it was a seamless experience I would definitely drop nodejs.
- bartlomieju 3y agoA couple months back we added an ability for Deno to run projects authored for Node.js directly. Eg. if you have a Vite app (or any other app really) with "package.json" and some "scripts" defined there, just try running "deno task <script_name>". Deno will automatically pick up "package.json" and try its best to run the that script. It's not fully done, but in our testing we got a lot of non-trivial projects running that way. If something doesn't work in your case, I would greatly appreciate a bug report to help us fix this. As for the written guide - there's not a single one at the moment - it's something we'll be looking into in the coming months.
- 3y ago
- vbezhenar 3y agoCan someone enlighten me about one thing. I kind of like deno when it came to its package management. I hate npm and I liked that deno tried to disrupt ecosystem. Now when deno bent over and accepted npm reality, is it possible that few years later they'll just switch over to it entirely and abandon their old ways of packaging? I understand that it's easier to sell deno to developers when they can import npm package. And deno wants to make money, so taking a hard stance is a bad financial option in the short term. Still I'd love to take a bet on deno. But if deno is just another npm... Well, setting up node + typescript + eslint + prettier sucks, but not so much.
- vbezhenar 3y agoAlso there's one feature that deno could make possible given their tight integration: Allow JSON.parse to use typescript types. So I can parse JSON with supplied type and engine would validate JSON against that type. Simple as that. Also might be useful for JSON.serialize to have an output control (because TypeScript could be abused and actual value might differ from its type). This simple feature would bring tremendous value to application stability IMO.
- emadda 3y agoI have been using zod to create validation functions. The validation functions give the TS compiler hints about the types that are output after validation. I think you either: (1) start with the runtime code and derive the types (what TS does by default). or (2) start with the types and derive the runtime code (like "macros" in some languages). Does anyone have any suggestions for the best way to do this in a Node runtime?
- StefanWestfal 3y agoCan I easily integrate Rust crates into my Deno app like a smaller extension for number crunching or at one point even something like Polars?
- ushakov 3y agoYou could compile them to WASM and call them from Deno