11 ms·
Can someone explain like I'm five what Deno is and what it's for? Is it for the desktop or web applications? What practical things can you / should you do with
by skyfaller 6y ago
Can someone explain like I'm five what Deno is and what it's for? Is it for the desktop or web applications? What practical things can you / should you do with it? I just can't get my head around what it does.
- aaomidi 6y agoIt's an alternative to nodejs. What you do in nodejs is generally possible in deno.
- TheDong 6y agodeno is 'node' shifted by two letters. What do you use nodejs for? That's what you use deno for. It exists in the same space. So in short, deno is a javascript interpreter suitable for local scripting, server/services, etc. Just like node. You can probably use it for desktop applications, but it more closely targets server code, again like node. So how does deno differ from node? It has a different module system and stdlib (better, more modern). It has first-class typescript support. It has much better security controls so that it's possible to use it to interpret untrusted code (this is not security advice). The 'untrusted code' bit means deno's also gunning a little for the niche lua and other embedded scripting languages occupy, but I don't think it has much of a foothold there yet.
- otabdeveloper4 6y agoAs someone who has done lots of embedded Lua, I can confidently say that embedding V8 is definitely not what I want. I want an embedded statically-typed language that compiles directly to something that is memory layout compatible with C++. We have 1001 languages now, but it looks like I'd still have to write my own to get what I want...
- oblio 6y agoI'm not a low level dev, but I've read quite a bit about this over the years. I have a question: > I want an embedded statically-typed language that compiles directly to something that is memory layout compatible with C++. Isn't this asking for ABI compatibility with C++? I thought C++'s ABI is unstable so nothing can be compatible with it.
- otabdeveloper4 6y agoNo, it isn't. I'm okay with recompiling every time my compiler changes, it's not a big deal and we have sources for everything we run.
- crocodiletears 6y agoAny experience embedding deno in a c++ application? I absolutely lovehow seamlessly lua integrates into my code, but I just find the language itself absolutely unpleasant to work with.
- vinkelhake 6y agoDeno uses V8. If you want to embed a JS runtime in C++ then just use V8 directly. Deno is mostly written in rust.
- crocodiletears 6y agoAh, I hadn't realized that. For some reason I fell under the impression that it was its own JS engine.
- yesbabyyes 6y agoIf it's the syntax that troubles you, you could have a look at MoonScript, a little language that compiles to Lua, inspired by CoffeeScript and bringing with it some niceties.
- jitl 6y agoI think QuickJS is the best option for embedding a JS interpreter. It’s a bit on the heavy side, but it supports a lot of modern ES2020 stuff. https://bellard.org/quickjs/quickjs.html https://bellard.org/quickjs/quickjs.html
- tomcam 6y agoOK that is like the best explanation ever. Thank you.
- Datsundere 6y agowould this mean you can't build electron apps with deno?
- nitsky 6y agoIt's a lot like Node.js, a js runtime built on v8 w/ bindings to the filesystem, network, etc. However, it is redesigned around recent changes to js. It eliminates commonjs and package.json in favor of es modules, and eliminates callbacks in favor of promises. It also gives scripts zero permissions by default, so you can give each script you run access only to what it needs.
- deleted 6y ago[deleted]
- e12e 6y agoWell, nodejs was kinda: lol, what happens if you put v8 js engine inside a c++ event loop? Now, some years later, deno is more like: ok, we know what happened. But now browser js have some new apis we could (should) re-use (modules, fetching resources) - and this typescript thing looks good. So what if we put typescript inside a rust event loop, and surfaced some of the sandboxing ideas that browsers use (eg: no file system access by default)?
- kilroy123 6y agoIt doesn't sound unreasonable when you put it that way.
- e12e 6y agoSee also - post on original nodejs presentation: https://web.archive.org/web/20120205214227/http://blog.redfin.com/devblog/2010/07/ryan_dahl_introduces_nodejs.html https://web.archive.org/web/20120205214227/http://blog.redfi... (was a surprisingly large number of dead links on hn regarding this one). I believe this is a copy of the video: https://www.youtube.com/watch?v=ztspvPYybIY https://www.youtube.com/watch?v=ztspvPYybIY
- mattlondon 6y agoLargely the same as node (server-side JavaScript), but typescript first and no npm/node_modules nonsense.
- mekster 6y agoWhat's nonsense about npm? Please link to you better alternative.
- didibus 6y agoIf you hadn't realized, JS is a scripting language, which does not have an official runtime. What that means is... How is JS code executed? You need some other program to interpret (and possibly JIT compile) the JavaScript and actually execute it. Normally that "other program" is a web browser like Chrome, FireFox, Safari, Opera, etc. But those programs run JavaScript in a restricted way. That is, they only execute JavaScript attached to a web page that they loaded and within the context of that page, and they limit what the JavaScript can do to the operating system. Like can it delete files on your disk? Can it listen to an open port? Etc. Also, those programs don't let you run JavaScript conveniently outside the context of a webpage. You can't just do at the command line: `chrome myscript.js` Thus if you wanted to use JavaScript to write command line applications or desktop applications, using a web browser wouldn't work. So we need another program that lets you run JavaScript from the command line, or as an executable, and we need that program to provide more facilities to the JavaScript code which allows it to do more things to the OS, such as deleting files from the disk, listening to a port, connecting to arbitrary remote servers, etc. The first such program to appear was NodeJS. And some people don't like it. They don't like the way it runs JavaScript and the way it has exposed to JavaScript those additional OS facilities. Thus they decided to create another one called Deno. Most languages have one defacto run-time, for example for Python it's CPython, for Ruby it is MRI, for Java it is OpenJDK, etc. And if they have alternative ones, like Ruby also has JRuby for example. They normally copy the same language APIs, so that code for one works on the other. In the case of Deno this is not the case. Deno decided that the NodeJS exposed JavaScript APIs arn't great, so it has a different set of language APIs. That means JavaScript code written for NodeJS will not work for Deno and vice versa. It's really rare to see such a split in mainstream established languages, because the cost of breaking compatibility with established "in-production" code is normally too high. For example, Microsoft has build .NET core, as a new run-time for C#, but it tried really hard to provide all of the old .NET framework APIs, yet not all of them, so it did break se backwards compatibility. I believe Deno will break much more. I've only seen this happen in the past for less popular languages, like Smalltalk has a bunch of slightly incompatible runtimes: Squeak, VisualWorks, Pharo, Cuis, etc. And when that happens, sometimes people even consider it a whole new language, like a dialect. So in some ways, you could almost consider NodeJS and Deno to be dialects of JavaScript, since their code isn't compatible and their APIs and some of their features will differ. Similarly, their code will not always run in a browser either without rewrite, because again, the capabilities and APIs differ. Hope this helps, I know it's kind of complicated, but at the same time it's simple. You need a runtime to run JavaScript. Each runtime can expose different APIs to the JavaScript to use, and each runtime can choose to support custom extensions of JavaScript or choose to not support certain features of JavaScript, etc. Deno and NodeJS are two such runtimes for JavaScript that are both making different choices.