Scripting Bits
Published in

Scripting Bits

Just Importing Code From The Internet

After taking a look at how Deno allows directly running or importing code via arbitrary URLs, I got to thinking: that’s a pretty nice way of handling dependencies. It allows me to get up and running without even needing to deal with a package manager; after all, it generally costs me on the order of a minute to run npm install.

When it comes to installing packages though, there are multiple ways to go about it. We can install copies of packages per project. We can install copies of packages per computer and reference them in different projects.

And on that train of thought, whatever method happens to be the one in use, developers are always coming up with creative ways to make it more usable: running a proxy package repository locally or making symlinks from already-installed local copies of packages. I’m also always reminded of using process pools to avoid the startup cost of bloated frameworks.

I’m visualizing a line graph relating project size to amount of effort I’m willing to commit. If I’m a consultant on an existing project, I might be willing to put up with any amount of legacy code and ideas. If I’m building my own small website, I might want to try out cutting-edge super productive and expressive frameworks. And, if I’m just doing a one off automation thing on the command line, I might just want to get the job done as quickly and conveniently as possible.

I might want to start up a simple HTTP server:

python -m http.server

And, I might want to be able to control the Cache-Control headers by directory. That would require me to either write a bunch of code or find an npm package that’s easily configured:

npx serve {
"headers": [
"source": "web_modules/**/*",
"headers": [{ "key": "Cache-Control", value: "immutable" }]

As my usecase becomes more complex, and I can’t avoid writing code, I might look for frameworks with a bunch of community-contributed plugins that I can plug-in to my code. I’m thinking of things like Express with its many middlewares, ESLint with its many plugins, or any of the many component libraries for all of the popular UI frameworks.

Just musing about different ways folks reuse code.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store