Skip to content

Comment on Deno 1.14

Comments

I tried out Deno last weekend for a fun little hack project (syncing a local Markdown file to a formatted Google Doc), and it was awesome.

Writing TypeScript code for Deno feels a lot like writing Go (which is a very good thing to me):

- opinionated build/fmt/deps

- well-designed stdlib

- no need for scaffolding files (.eslintrc, babel.config.js, jest.config.js, mocha.opts, etc.)

If that sounds good to you, try Deno!

I also tried it out recently, because I wanted to make a small utility for myself and liked the idea of it providing a single executable (and bypassing the node/NPM ecosystem for learning a JS/TS based system appealed to me). It delivered on that beautifully, as all I did is switch from running "deno run" as I was for testing to "deno compile" and it delivered to me exactly what I was looking for. A bit large at 57 MB but that's not too bad for a fully bundled JS runtime and no library dependencies except glibc that I could see.

As someone that's barely touched node for dev and always been put off by NPM and how that works (and the heavy build chain for some stuff), I find it much more palatable.

That's interesting.

57mb is big, but not an issue when it's for personal use.

Somewhat related, I haven't used rust, but I read that it can produce an executable including the run time for edge that is less than 1mb,. I couldn't find the source, but this article shares how an extension was reduced from 12mb to 4.5mb.

57mb is big

Honestly, I think most the time you're looking at 10MB+ for interpreted languages that are turned into executables (through a bundling of the runtime and scripts, that is, not through compiling to something else which is likely much smaller if offered).

The complexity and size of the runtime is going to necessarily influence that size. V8 is fairly complex compared to most runtimes I think, with the JVM and maybe Mono being notable exceptions, and if you were to bundle the JVM with an app instead of just expecting them to have it installed, I imagine that would be quite large as well.

Somewhat related, I haven't used rust, but I read that it can produce an executable including

That's actually the other thing I wanted to do with the project I built in Deno. Since it was very simple, but actually useful for me, I was also going to implement it in Rust. I've played with it a few times over the years, but never really had anything real that needed to be built in it, so this seemed like a good chance to build something real in it.

In case anyone is wondering because I mentioned it twice, the project is just reading an ini file which defines browsers, pattern matches to apply to URLs to determine which browser to load based on the URL, and a default browser. The idea being that I can send work URLs to the browser I dedicate to work that's proxied through a SOCKS connection, and other URLs get handled automatically by the browser I use for personal stuff, and I can just make the application my default URL handler. Dead simple, but very useful for my current workflow.

If you happen to be on mac, there's an app called finicky that does this. It can also pattern match on source application which is pretty handy.

I'm not, but that's nice. Pattern matching on the source application is actually what I would have preferred (and what I kept looking to see if anything on Windows could provide), but never found anything. Matching on the URL actually works well enough though, which I know because my prior workflow was just a work container tab in Firefox with the Container Proxy extension to proxy only those tabs in that container, and work URLs were set to prefer that Firefox container.

I was actually fairly happy with that, but it's nice to just be able to close the chrome instance with all the work tabs at the end of the day and have them all reopen when I start it up the next day, and all my work tabs are self contained and proxied through work. The only downside is I can't just click to open in Teams or Outlook, and need to copy the link and manually open it in Chrome, which is what I was aiming to fix.

Much appreciated! The first looks to be an example of how to register the handler through an installer, instead of the registry hack I'm doing (since MS only wants things actually installed and visible in Add/Remove programs to be protocol handlers, for obvious reasons, even if annoying), and the second isn't barely related, it's looks to be essentially the same thing but in C. Here's mine for comparison: https://github.com/kbenson/urlswitcher-deno

Does the fact that you didn't need Npm mean that Deno has a suffciently large built-in library that a thing like Npm is in most cases not needed?

Honestly, I'm not sure. My needs were very minimal, one Deno stdlib import, and one third party module import (for ini file parsing). https://deno.land/x/ has their third party module ecosystem, but it's all just JS in the end, so I think think there's anything making it so you couldn't use the NPM ecosystem.

I found this article[1] which seems to indicate if the node packages use ES modules you can use import them as is, or if not it says JSPM can help with that.

1: https://medium.com/samsung-internet-dev/using-node-modules-i...

It's also great for scaffolding CRUD sites. I used it a while ago on a MERN stack project in order to loop over a directory of game files -- Stepmania simfiles if anyone's wondering -- cleaning them up, parsing their metadata, and then POSTing it to my Express server. While I didn't avail myself of its CSV/YAML/etc parsing (JSON was a builtin and is now a third-party library), the stdlib's walk function made this generally painless.

And to top it off there's yet another bonus to this approach: having Fetch included out of the box enabled me to mock out what eventually became my frontend requests, by running them headlessly and worrying about the form logic later.

I haven't actually gotten to using TypeScript with it personally (it's among a few things built into Deno that I've been meaning to try now that I can run them with zero config), but when writing JS I've found myself reaching for it in some of the same scenarios I (anecdotally) see people point to for Python -- bulk file manipulation, scraping, programmatic requests, etc.

Checking Deno out for my next project. I'm a recent typescript convert after working on a full JS team.

The types feel soooooo good.

Is it fast to start up? I have been using node with ts-node, and it takes a couple of seconds before it can start executing the actual code.

Yeah - it is very fast. You can specify a --no-check flag which makes it even faster.

you got me at no need for scaffolding files babel.config.js reply

mind sharing that project? I have a similar need.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.