Deno 1.33: Deno 2 is coming
deno.com
deno.com
That being said, was wondering whether you can take advantage of this without using deno deploy, or if you'd be locked in by using deno kv. Also, wondering how many bugs will only show up when deployed due to the different backbends.
So it's backed by SQLite on the OS local version.
I'm intrigued if there will be a way to swap out the backend for other cloud providers.
Is having a database that happens to be a product you sell as part of your runtime good, or are you creating some mixed incentives here?
Are you a database vendor now?
If not, don’t build a database.
If this is a mature product that someone else is looking after, and it’s good and free and we’ll maintained like redis or SQLite, sure.
…but it seems like building cloud databases is not the core competency of a group building a javascript runtime.
Once money is involved, it’ll either be a distraction from their core mission, or become their core mission.
A KV db you can use for quick hacks? Sure. Awesome!
A scalable production database you’re selling to people? O_o why are you doing that?
If Deno were nothing but "Deno CLI" (the equivalent of the 'node' executable, that runs as a typical server process on a Unix box) then you would be right. But there are two separate Deno runtimes (CLI and Deploy).
Deno Inc. has enough expertise in running a global service that two other companies rely on their work to offer edge functions to their customers (Netlify and Supabase). Adding a database to the service makes sense. And to be clear, they don’t develop a brand new database. They build atop of SQLite and FoundationDB.
Sure.
> But they want the friction reduced to a simple `await Deno.openKv()`.
Do “they”?
If so, who’s using it to solve that problem? …because it seems the big uses of deno deploy are not using it, fine with that and it’s pretty unclear who the “they” is in this circumstance.
Still, if it’s a thin layer over foundation db or some other established database product and this is just part of the lock-in for their cloud offering, fair enough.
It’s not like others (eg firebase) don’t do the same thing.
The messaging “we’re building a database” and “we’re offering a hosted database service based on existing mature reliable technology” are different things though.
The latter all cloud vendors do.
The former is ridiculous, and it really really wasn’t clear that wasn’t what was happening.
Not saying this is for everything and everyone, but there's so much competition on this space that I can understand why somebody would like to try something different.
Deno is not and has never been an "alternative runtime" to node.
Watch as the same happens with Bun.
In this relationship of 3 years and counting, they are the positive contributor because they give you something useful for free and you presumably haven't given them anything.
The KV store has two backbends: local sqlite and distributed deno cloud.
If you choose the deno cloud backend you're signing up for a closed source cloud service from the start. There's no trickery.
So first of all, _you_ can use whatever ORM or database solution you like in general so _you_ specifically choose which technology you want to invest in. If you want to hand craft your kubernetes cluster for your database nodes and put them on GCP or Azure, then go for it. You want redis? Go for it. If you want to use supabase, firebase, planetscale or whatever, use that. If you want to choose a KV store that's built into your runtime then that's great. Believe it or not but people use lowdb in production and their database is literally a json file. I would argue whichever you choose, switching from one hosting provider, database solution, managed or unmanaged platform to another will always incur cost and how high that is will depend on your depth of integration and familiarity with it. I am most likely going to use this feature and I am happy it exists. Also let's not ignore that there is a large breadth of different needs that developers have. Would I build a massive modular corporate CRM system with BI features with it? Probably not. Am I going to build my next D&D game tool, habit tracker or Tinder for sneaker trading for it? Maybe!
I sincerely wonder what specifically you loose from this feature simply existing.
Database providers, cloud application platforms should be agnostic of the language their users are using. There are many such decisions deno is making where they want to be the end-to-end service. That is not a good sign. It creates perverse incentives for the company to devise lock-in mechanisms at each stage and discourage compatibility with the rest of the programming ecosystem, perhaps even undermine the rest of the ecosystem. I would stay away for this reason.
The API is extremely simple. It's little more than a hash map. That's hardly opinionated.
> All the good programming advice will tell you such a coupling is a bad idea.
That advice is outdated. Virtually any modern application will want a database, and this API can serve as a foundation for it – a foundation that conveniently already has many of the features (esp. global replication and consistency) that you will want and that are incredibly difficult to get right if you build them yourself. Think of this as the application's "file system". PaaS today usually doesn't provide direct disk access, so this is the low-level abstraction for persistent storage that is available. An abstraction that, in many cases, will in fact be all your application ever needs.
If you do deploy to deno cloud it's trivial to migrate because there are many competing offerings of kv stores.
I'm not that familiar with either technology, but as an example, deno kv claims strong consistency as the default; while dynamodb requires you to explicitly ask for strong consistency in queries and does not support strongly consistent reads on secondary indexes.
In that case, why does Deno have to provide this? Can't users simply create their own hashmap?
How often does that happen?
* The Erlang runtime has Mnesia and ETS built in. Batteries included. It's awesome.
* Python has a built-in persistent key-value store, dbm.
* Ruby has one as well, pstore.
Now, you can always decide to use something else! 99% of the time m not going to use dbm, or pstore, but they are nice to haves. (Mnesia and ETS rocks though, and I use those all the time.)
Yeah maybe you'd prefer to do that with an agnostic solution like Redis (which afaik is possible in Deno) but everything has pros and cons. An e2e solution is coupled but otoh it has many objective advantages. And it's not like Deno will force you to use their cloud service after all.
I think fast searchable file backed data structures should be primitives of any computer language and runtime.
For that application at least no changes to the runtime would be necessary
Isn't it part of the standard library rather than the language? Anyways, Erlang has mnesia [0] and ETS [1]. ETS is practically a KV store, which can also be persisted to disk.
[0] https://www.erlang.org/doc/man/mnesia.html [1] https://www.erlang.org/doc/man/ets.html
Also, local KV obviously won't work for compute lambdas, as the KV isn't shared across instances.
It started as "better node.js", with better security and modern tooling. Better security was not achieved imo, it's not flexible enough but painful enough that you want to allow everything straight away. The module system suffers the same issues as of npm, and since everything is loaded from the same domain its hard to tell what is official or not.
They have a builtin server, linter, testing, benchmarking, a hosting platform, now a kv store.
I feel like they are getting away from being a language and heading toward being a framework. Why not, but will probably not help adoption imo.
1.) it was never a language
2.) indisputably better security any time you take advantage of any of the features to disable reading of environment variables, using network, reading files, etc.
A build tool, that reads input files and writes output files, and nothing else.
A CLI that interacts with the bug tracker, and needs to read the environment and do networking, but doesn't need to read the filesystem, launch subprocesses, etc.
A serverless function that doesn't need anything but networking.
Even when you need to allow whatever you're building to read the filesystem, just specifying which files/folders can be read is in an of itself a huge win.
Thinking on it a little more, I wonder what kind of gigantic monolith use cases are there that need to read/write completely arbitrary filesystem locations, and need to spawn subprocesses that can't be known ahead of time, and need to do networking, and need to read arbitrary environment variables that can't be specified ahead of time, and also need to load dynamic libraries, and also need that other permission I'm forgetting?
I mean, I am sure there are some, but that certainly isn't the default I'd choose.
If it wants to upload artefacts to a CDN it will also require network access.
> A CLI that interacts with the bug tracker, and needs to read the environment variables and do networking, but doesn't need to read the filesystem, launch subprocesses, etc.
Chances are the CLI needs to read ENV variables to authenticate or a configuration file and maybe even subprocesses to setup parallel processing.
> A serverless function that doesn't need anything but networking.
A serverless function will probably read environment variables as well or access a package.json file to read some context about the name of the package and it's version.
My point is that most programs will require all access enabled.
Even with your own theoretical additions to what the programs above need, none of the programs above actually need "all" access enabled.
And even when you do need to allow environment variables, subprocesses, and filesystem access, you can specify which ones. E.g. this program can read this specific package.json file and no other files. Or these three specific environment variables, and no others.
Which is still significantly different than "all".
Tough to interpret this since NPM isn't a module system, but:
- Requiring the standards-compliant ES module system and getting rid of CommonJS is definitely a huge improvement for the future of the ecosystem
- If by "the same issues as npm" you mean "makes adding dependencies so easy that a lot of them get added", then sure I guess, though I'd argue that isn't an issue
> since everything is loaded from the same domain
It's not though; Deno can import from any URL. Personally I like to import directly from github for a lot of things. But anyone can set up their own repository or CDN if they'd like to, because all you need is an HTTP URL
> its hard to tell what is official or not
The official standard library is under deno.land/std/
> I feel like they are getting away from being a language and heading toward being a framework
Well they were never a language because the language part is (almost) identical to what was already out there. Whether or not they're a "framework" (or attempting to be one) is debatable, though they definitely take an "all the things most people need have official solutions (which work together smoothly)" approach, which is one of my favorite things about Deno. Also, a major usecase (their core business) is serverless scripts, so having all the important stuff included is even more beneficial there
I've stopped using Node for any non-UI projects. Deno has been a godsend for me
The security model works well for this use case also. If your shell script is only supposed to read a few environment variables and not make network calls, you are covered.
I mean, why would one ever need to change standard module names or demo.json structure?
Maybe it looks a bit better, but I’m sure it invokes a lot more pain for all developers, who need to watch out carefully with every release.
I consider this a JavaScript curse to be honest. Every webpack version breaks apis in random ways, react native is notoriously hard to upgrade because of this etc
Why isn’t it considered a problem in the community?
You can't get things 100% right all the times so you have to decide what to do when you realize there is a better way. You have a few choices:
a. You don't improve the interface and instead you offset the issue by adding more documentation, helper scripts, templates/examples etc.
b. You improve the interface, possibly in a backwards compatible way.
So, (b) presents some maintenance costs, but (a) too has some costs! Some organizations tend to prefer (a) because it's easier to just make it somebody else's problem (e.g. some other team will do documentation, some other team will do the developer advocacy).
So it's a locally optimal solution and hence it's often chosen despite (b) being a globally optimal solution, since the product will be easier to use.
As far as I know, Deno 1.x runtime upgrades are always backwards-compatible
As the blog post touches on, upgrading Deno itself does not force you onto the latest version of the stdlib. You will need to change the import URLs to get it.
I love Deno for system scripting but the friction with the rest of the JS ecosystem has prevented me from adopting it further.
I like Typescript quite well, but if I'm told I'm going to throw away my nodejs/ts code base and start from scratch, then they are many alternative with better (for many definitions of "better") langages to consider, which at least will actually be different from what I have just thrown away.
This is why my money is on Bun, just like a safe bet in Carbon. Both are designed to be drop-in-capable in large codebases where the bean counters aren't going to budget a total rewrite that redelivers the same functionality.
For deno that would be fresh (the framework). And the speed of development is just not there, compared to the competitors (but everything has trouble keeping up with next right now)
I really think this has a strong future in enterprise as dedicated frontend, backend and devops roles all merge into one. Everyone just learns and uses typescript for everything. Everyone is a 'full stack' engineer now. I hate to say it but it's almost like the dream of java all over, except the language and tooling isn't painful.
I do not know who downvoted my comment: it is not a healthy behavior.
Using a fallback to .ts files when importing .js files is a minor and straightforward addition to file resolution. And this is a big gain in terms of interoperability with others tools.
Most frustrating is that (last I checked) there isn’t even an agreed upon plan to resolve the inconsistency, at least for libraries (import maps, though tedious, at least can solve the problem for non-library code).
For a long time I was annoyed by the similar problem of Deno's requirement for fully-specified import paths like 'foo/bar.ts' making our Deno code not easily interoperable with our "plain-ass TypeScript" code.
We have an Nx monorepo with a large amount of "library" code, which is really just TypeScript code that uses standard TypeScript path aliases[1]. This code is used by various teams for various things, like Node programs, Svelte/Angular/FrameworkOfTheWeek apps, local utilities and built tooling, etc).
However, until recently, none of these libs worked with Deno, because internally they had to import things like 'foo/bar' and not 'foo/bar.ts'. Changing the imports to 'foo/bar.ts' would make them work in Deno, but break them for everything else.
But TypeScript 5 really changed that with the addition of a new config option (discussed here recently[2]):
"compilerOptions": {
"allowImportingTsExtensions": true,
This lets me take a plain-ass TypeScript Nx monorepo library, and add it to my import_map.json, and use it from Deno code as well. (Nx recently released a new plugin to help with this.)It's still not ideal, because you have to convert all the files to start importing and exporting using the ".ts" extension, and there are probably edge cases where it breaks something. However, I have been using it since the TypeScript 5 betas and I have not hit any problems yet. (Would be very curious to hear any problems other people have had, though.)
[1]: the entries in the "paths" section of tsconfig.json, which let you map your own import names to filesystem locations, so you can
import { Hoge } from '@acme/hoge';
instead of: import { Hoge } from '../../../../libs/util/hoge/src/index.ts';
[2]: Previous discussion: https://news.ycombinator.com/item?id=35185069#35186448> Improvements to npm and Node compatibility
Every little improvements to npm compatibility actually unblock a very wide range of npm packages to now 'just work'^tm. I would have been interested to get numbers of incompatible library but `npm:crypto` has been the biggest blocker for our users.
But nothings stopping Node devs from prioritizing the cold boot time, or for other upstarts like Bun with more of a focus on maintaining Node compat, or going with V8 Isolates instead, to give Deno a solid run for its money.
Snapshots having landed in Node (https://nodejs.org/en/blog/release/v18.8.0), is Deno still superior here?
Seems like it would just clutter the std/* "namespace" and cause churn in dependencies?
I think it’s a cool idea generally, but let’s not mistake deno for replacing a generalized runtime. Deno, bun, etc. are proprietary infrastructure in a box that are being designed to integrate tightly with the rest of their deployment platforms
For work I would need a good interface for SQL. In pet projects I am using sqlx for Rust and sqlc for Python. In both you can write SQL directly and get query validation and parsing into struct / PyDantic for free. Is there something like this for Deno?
[0]: https://docs.sqlc.dev/en/latest/reference/language-support.h...
is it planned for v2?
My impression of Fresh is that it's neat technology but basically a barebones MVP at this stage. They haven't done much development on it since v1 last year, presumably because the team has been busy with other stuff like what's described in the article.
I disliked the fact that this script constantly eats few percent of CPU despite being idle 99.999% of the time. Not a big deal but a sign of bad engineering.
I know you specified _without dependencies_, but I don't know that it's a fair comparison. The standard library for PHP and JS seem fairly similar to me; I work with both languages daily. Using NPM packages are much easier imo for greenfield projects.
PHP before Composer still had a ton of 3rd party script usage, but with explicit imports instead of autoloading.
Really? And why did he switch to vscode to get autocompletions for deno kv?