15 ms·
Deno Is Webby
- lvass 5y agoI'm simply unable of not reacting to someone so exhilarantly rejoicing you don't need a third party library for taking user input with cynicism. Am I living in a bubble, or what the hell went wrong here?
- westoncb 5y agoThe input prompts are just one example, it's what it's an example of that's actually exciting.
- dpweb 5y agoEfficiency seems to be a real priority w them. I like the simplicity in Deno Deploy also. You literally get a text box and just type in your cloud function. You don't have to install cli, set up tooling, for a quick try out.
- vlovich123 5y agoShameless plug. Disclaimer. I work for Cloudflare. Have you tried Workers? You can do the same in a playground [1]. You can also do the same by deploying a worker through the dashboard UI (including writing the code). Nothing to link though because you need an account. The playground is limited in what it can do because it’s not deployed. You can also use Pages to point at a repo which lets you build a website and server side code (through Pages Functions which actually runs your code in a worker). [1] https://developers.cloudflare.com/workers/learning/playground/ https://developers.cloudflare.com/workers/learning/playgroun...
- dpweb 5y agoYes big fan of Workers and Cf. The only issue it was confusing tying the domain to the worker, but that was a few years ago - last I tried it a couple months ago seemed easier.
- vlovich123 5y agoYeah, I think the launch of our own registrar service simplified onboarding of custom domains (by default all workers are available on workers.dev domains).
- qbasic_forever 5y agoPlease purchase Deno the company before dismantling their only source of income through deno deploy--deno the tool is too nice to lose!
- vlovich123 5y agoTo be fair, CF workers is much older than Deno by a few years. I don’t see us as dismantling anything - do you blame the wind mill or Don Quixote for tilting at them? This is a very competitive space too. Cloudflare is but one player and I don’t think the ones who do well will focus just on the serverless infrastructure piece. It’s more about having a very complete product story that solves pain points better than anyone else for a price that’s better than anyone else (ie build on a more solid foundation). Since Workers started before Rust was a thing, Deno have a mild advantage on development velocity of the runtime (C++ is more annoying in some ways). They’ve also compounded that velocity by writing most of the runtime in Typescript whereas our runtime is in C++. However, our runtime is far more battle tested at scale which means trickier distributed systems problems solved and more efficiencies of scale (+ c++ has less of a memory hit than TS so it will be interesting to see if they can hit the memory scale needed to support many customers simultaneously). Personally I wish them the best as I think competition is always critical to force you to focus on making a better product.
- searchableguy 5y ago> They’ve also compounded that velocity by writing most of the runtime in Typescript whereas our runtime is in C++ Can you explain more? Deno doesn't use typescript in the runtime. It is rust and pure js (for globals and wrapping bindings). I don't expect their current architecture to be any less efficient from what I know but it may have changed.
- vlovich123 5y agoYes you’re right. I assumed they’d use TS because they’re going through the effort of making it a first class citizen. Doesn’t matter though because it’s the same (the only way to run TS is to transpile to JS) https://github.com/denoland/deno/blob/main/runtime/js/README.md https://github.com/denoland/deno/blob/main/runtime/js/README... A good chunk of the runtime is in JS, snapshotted and loaded into each isolate. This is a greater memory overhead (and probably slower startup time) than having it written directly in Rust because the snapshot needs to be copied into each isolate. I assume Deno Deploy follows a similar model as Workers where you have many many isolates running concurrently within a process where this overhead may start to matter. If Deno Deploy gets some scale, I’m curious how they’ll tackle. Less interesting is if they start inlining a good chunk of that functionality into Rust. It’s much more interesting if they figure out some way to improve v8 to reduce this cost. There’s some ways potentially if you could create a COW clonable isolate in v8 efficiently and it could be interesting to collaborate with them on it. But that’s hard. Maybe they have alternate plans.
- mcintyre1994 5y ago> You can log and style CLI output the same way you do it in the browser’s developer tools: using what you know with console.log > console.log("%cHello World", "color: red"); TIL, neat! If anyone else did too - https://developer.mozilla.org/en-US/docs/Web/API/console#styling_console_output https://developer.mozilla.org/en-US/docs/Web/API/console#sty... looks great Using alert/confirm/prompt for CLI tools is nice too, makes a lot of sense to build that in and use the web APIs for it.
- amenghra 5y agoTake a look at the developer console when visiting www.facebook.com
- thoughtpalette 5y agoconsole.trace looks sweet. Thanks for the link.
- brianzelip 5y agoThat’s great, thanks! I was wondering what that `%c` was.
- binarynate 5y agoOne of the things I love about Deno is that since it implements standard web APIs, many libraries built for the browser just work. For example, I recently made a simple static site generator with Deno to make my blog, and I found that I could use Marked for markdown support simply by importing it like this: import 'https://cdn.jsdelivr.net/npm/marked@3.0.7/marked.min.js'; // now I can use window.marked()
- colejohnson66 5y agoThat just seems worse than what npm/yarn have. Despite Node's flaws, at least those have a hash check on the downloaded package against what's in the lock file. EDIT: I was wrong. See @spoiler's reply.
- spoiler 5y agoSo does Deno: https://deno.land/manual/linking_to_external_code/integrity_checking https://deno.land/manual/linking_to_external_code/integrity_... It's not part of a package manager, because there isn't one, though.
- colejohnson66 5y agoAh. I stand corrected.
- favorited 5y agoOne of the many things about Node that Dahl explicitly wanted to "fix"* when building Deno was that the global namespace should be `window`, because that's what it is in JavaScript's natural habitat. *scare-quotes because the reader might feel strongly opposed to the term, not because I have an agenda
- danbolt 5y ago> that the global namespace should be `window`, because that's what it is in JavaScript's natural habitat. Oh wow, I had no idea. That rules!
- dexwiz 5y agoThis is nice, until its not. I have spent a fair amount of time over the last several years trying to make node act like the browser, or vice versa. It's doubly confusing to juniors who don't understand the difference between a language and a runtime. alert() looks like a standard function and should be specified by the ECMAScript Language Specification. But its actually specified by the HTML standard, because its Window.alert(), and Javascript's scoping rules let you call it simply as alert(). Trying to explain what's JS and what's Web is really difficult, and design decisions like this only muddy the waters.
- mattigames 5y agoThe people that don't understand the difference between a language and a runtime always need to learn it at some point if they keep working as programmers, and context issues exist on all branches of human knowledge, even English itself has this quirk where some words mean the opposite depending on the context (these are known as contronyms).
- cxr 5y ago> I have spent a fair amount of time over the last several years trying to make node act like the browser, or vice versa. And the right thing to resist doing either. It's to think about what "services" your program actually needs to be able to function and then to isolate those parts from the rest of your application by putting it behind a well-defined interface. In other words, the best way to fix the incompatibility problem caused by API mismatches is to never make the mistake of coding directly against the host platform's APIs to begin with. Trying to do it with compatibility shims to make one platform look like the other is a fool's errand. You end up running around trying to achieve parity with a mammoth API surface area (which might never have been especially well-designed to begin with...). Let's say you're implementing a program similar in scope to UNIX's file(1). For our example, though, suppose you're really only concerned with text files and specifically whether a given text file is using DOS-style CRLF line separators or UNIX-style LF terminators. You really only need two capabilities: a `read` operation to get the contents of a file and a `print` operation to show the output to the user. Does your program care whether that `read` is happening with a Web standards-backed FileReader or NodeJS's proprietary `fs` module? There's no reason it should. Design the best "system" layer that makes the most sense for your application's needs. You can see this implementation strategy in the way the TypeScript team wrote the code for the TypeScript compiler itself when it was made public. Even in the early days, it could run on multiple platforms—including NodeJS, JScript/Windows Script Host, and various browsers (old or new)—because it didn't overly concern itself with anything except its real job of lexing, parsing, and type-checking its inputs—wherever they came from—and then writing the output in a platform-agnostic way.
- henning 5y ago> You Might Not Need NPM If it's like every other JavaScript project I've been on since 2016, it's going to actually require thousands of JavaScript packages and doing everything with it is going to be slow as molasses even on high-end developer workstations.
- o_m 5y agoDeno is also creating a standard library, so that too should reduce the amount of external packages you'll need.
- jay_kyburz 5y agoThis is the real power of Deno!
- the_duke 5y agoThe Deno standard library is not bundled, but separately fetched as a dependency for each embedded file.
- qbasic_forever 5y agoThat's a pedantic argument, the deno standard library doesn't depend on any other library except itself and deno's core. You can know if you depend on it that you don't have dozens or hundreds of other dependencies, unlike pulling in a random npm package.
- qbasic_forever 5y agoDeno has a standard library that wants to be 'batteries included' so you don't have nonsense like a third party package for left padding a string (deno supports string padStart natively for this for example).
- yuchi 5y agoSorry but padStart/padEnd are part of EcmaScript 2019 (or near that year). Deno did not implement it. (AFAIK)
- russellbeattie 5y agoI'm sorry but all those examples and Deno's documentation in general should be in JavaScript. I respect the devs right to choose which ever language they want, but Deno seems to want to be the standard bearer for the power of scripting and web standards [1]. If that's the case, then they are causing more harm than good by focusing exclusively on TypeScript, which isn't a language as much as a set of macros on top of JS. TS should remain a niche for those projects that can benefit from type safety, not promoted as some sort of better alternative to JavaScript, because it's really not. 1. https://deno.com/blog/v1 https://deno.com/blog/v1
- gmac 5y agoIt’s essentially a subjective question, but FWIW I disagree. I’ve written quite a bit of JS and quite a bit of TS, and I find TS so much better. I’m more productive, generate fewer bugs, and have more fun when writing it.
- crate_barre 5y agoSome part of me wonders if they wrote some clear optimizations for defined types that translate easily to Rust. I could give two shits about types honestly, but I’m also one of those weirdos that keeps function arity low, and object definitions concise. How did people write semi elegant Ruby or python all these years, why wasn’t there such a massive push for types in those languages? Most likely because backend people chose the backend language of their choice, but on the frontend they detested JavaScript (you have no choice, you must JavaScript you anti authoritarian shit heads) so much they had to drown it with some kind of ketchup to make it edible (Typescript).
- triyambakam 5y agoAfter using typed backend languages like Rust and even Go (which is painful in its own right, in my perspective) I would hate to work again on a big Ruby or Python codebase. They feel just as disgusting, to use your metaphor, as using plain Javascript instead of Typescript. > why wasn’t there such a massive push for types in those languages Are you just choosing to ignore all of the history of type checking Python and Ruby?
- brundolf 5y agoI cannot help but root for Deno whenever it features on here. It offers such a wonderful potential future for JavaScript. It's not fully-baked yet, but man, it solves so many problems in one fell swoop.
- spacemanmatt 5y agoIt's so good I worry about the Betamax effect
- hyperhopper 5y agoWhat betamax effect? Didn't it fail since the cartridge design was worse and also held less tape than vhs?
- spacemanmatt 5y agoNo. It failed because JVC saturated the market with incompatible and inferior VHS before Beta could get there.
- cdmckay 5y agoMy understanding was that Betamax had inferior licensing terms, and that it was Sony’s greed that sunk Betamax.
- deleted 5y ago[deleted]
- spacemanmatt 5y agoSeems likely enough, however nothing could make up for being late to market in this case.
- ByteJockey 5y agoIt failed because the porn companies all went for VHS (for licensing reasons iirc). Porn companies have decided basically every format war (including pioneering streaming).
- wwweston 5y agoWhenever someone has asked me "what would you change about Javascript" for the last 15 years, my answer has usually been "it badly needs a standard library." The standards committees have partly advanced that and Deno is following those leads, but I've got my fingers crossed that Deno will also fill in gaps (and those will make their way back into standards committee considerations). (My other answers have been more ... controversial, like: make [] false-y, add macros, and bring back `with`!)
- __ryan__ 5y agoA couple of questions: “Make [] false-y” Why? “Add macros” Why? How? “Bring back `with`” Why?
- SonOfLilit 5y agoNot GP, but I really like [] being false in ruby and python because I often want to ask "is this variable that should hold a collection holding a collection of things, or is it empty/false?"
- PufPufPuf 5y agoI always found it strange that in Python, stuff doesn't get implicitly cast to string (even Java does that!), but for whatever reason the idiomatic way to check if a collection is empty is to do "if collection:", implicitly casting to bool.
- heavyset_go 5y agoNothing gets casted to a bool in Python if statements.
- djur 5y ago[] is truthy in Ruby. Only false and nil are falsy.
- 5y ago
- rr808 5y agoI love the idea of deno over Node. Is it getting traction though?
- o_m 5y agoNot sure about Deno, but alternative runtimes for javascript on the server is popping up a lot of places now. All of the edge hosts are using the V8 javascript engine with their own wrapper.
- tracker1 5y agoI've started using it for more shell scripting... since it's easier to run without worrying about `npm install` for dependencies. Also using it where I'm not tied to Node by a specific dependency. There's some shimming surface towards getting Deno able to run node packages and vice-versa as well as ES-Module packaging of node repositories for use directly in the browser or deno, to more or less success.
- jokethrowaway 5y agoI agree on the premises, it's nice to have an open standard - in practice the API available on the web is usually a downgrade in developer experience. Think about the old node library request vs fetch, require vs import/import(). I hope deno has Buffers and I won't have to use atob / btoa.
- tracker1 5y agoIIRC Buffer in Node has been a wrapper around Uint8Array for a long while, which is in the box in both, and the browser. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- thylacine222 5y agoAnd Zendaya is Meechee.
- Already__Taken 5y agoJust wish it had some more host-level access to get to web cameras/usb devices and serial ports.
- undefined_void 5y agoYess! Take a look at https://deno.land/x/webusb https://deno.land/x/webusb
- seumars 5y agoDeno is a joy to use server-side. Though as soon as it's used in conjunction with even something simple like minified code, you're forced back to node/npm.
- nllsh 5y agoHow are you using Deno with minified code? Do you mean importing a minified script like https://cdn.jsdelivr.net/npm/react/cjs/react.production.min.js https://cdn.jsdelivr.net/npm/react/cjs/react.production.min.... ?
- seumars 5y agoI meant bundling your code for production.
- tonyedgecombe 5y agoWhy would you need to do that for code running on Deno? It doesn't need to be sent over the wire.
- seumars 5y agoObviously not for server code. Example: serve 'src/app.js' uncompressed during development, and 'assets/app.min.js' during production.
- mark_and_sweep 5y agoYou can use `deno bundle`: https://deno.land/manual@v1.20.1/tools/bundler.md https://deno.land/manual@v1.20.1/tools/bundler.md
- mark_and_sweep 5y agoIf you want to bundle and minify JavaScript code, you can use esbuild: import * as esbuild from "https://deno.land/x/esbuild@v0.14.25/mod.js"; If you want to bundle and minify SCSS, you can use dart-sass: import { useDartSass } from "https://raw.githubusercontent.com/MarkTiedemann/deno-dart-sass/0.1.0/mod.ts";
- deleted 5y ago[deleted]
- panta82 5y agoDeno is webby... But who cares? It's solving a problem no one has. Standard library improvements are always welcome, though.
- antifa 5y agoIs there a solid coffeescript type thing for deno?
- r2b2 5y agoDeno is just a javascript runtime and standard library, so in theory you can already use coffeescript.
- runarberg 5y agoI do wonder about a future where JavaScript gets non-enforced optional type annotation syntax[1] which is and if said syntax will be slightly incompatible with TypeScript. That would be a little awkward for Deno, wouldn’t it. However I hope that if JS gets type annotation syntax that it would be a strict subset of TypeScript—or at the very least future compatible—for this very reason. 1. https://github.com/giltayar/proposal-types-as-comments https://github.com/giltayar/proposal-types-as-comments
- amitport 5y agoWhatever the final syntax will be, if it is part of the JS standard, Typescript will probably adopt it at some point. (And its team will try to push the standard towards being as close to the current Typescript as possible)
- yesbabyyes 5y agoTypeScript `tsc` can already type check JSDoc type annotations, which is very useful: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html https://www.typescriptlang.org/docs/handbook/jsdoc-supported... Edit: I should perhaps listen before I speak -- the proposal linked above talks about JSDoc and why it does not fulfill their needs, which may be the case. I have not run in to these limitations myself.
- staticelf 5y agoOne thing I have never understood about Deno is that how are you supposed to run it on a multicore machine? Since they don't have cluster module like in node there is no way to run one process for each core? If the main thread is busy running some cpu intensive task, it will then block the entire application from answering other requests. I get that in serverless environments like in Deno deploy each instance gets one core etc but if you're running it on a VPS or just on a normal server I would want something like the cluster module like in node.
- croes 5y agoCan Deno now be used with MS SQL?
- Sammi 5y agoNot one that's up to date and maintained, as far as I can google. But there's a proper sqlite driver now using the new ffi api support in deno. This didn't exist last time I tried googling db support in deno. https://github.com/denodrivers/sqlite3 https://github.com/denodrivers/sqlite3
- jimmont 5y agoDeno is the best thing to happen in web middleware, potentially over its entire history. It's like someone solved those problems over many years, took a break, then started from scratch to do it properly.
- ameyv 5y agoI hope deno succeeds in replacing nodejs & npm. I don't want to deal with NPM and all the shenanigans that comes with it.
- peanut_worm 5y agoDeno is excellent I really regret not using for my most recent node project