by soapdog · 6y ago · 0 comments
We had a need to extract records from a database into a textual format to be processed by other tools later. This is the typical task for a throwaway script which can be written in basically any scripting language. There is nothing in the task that called out for deno but I wanted to try it out and so I did.
I basically worked on the script iteratively, doing small changes, running it, checking the output, fixing things and running again. No bundler, no complex NPM tasks. Just a simple spaghetti JS and a single binary engine to run it. It was a very refreshing experience. Using URL imports was pretty nice, I really like working like that since my preferred JS environment is not NodeJS but the browser. I can see myself transitioning all those small tools and throwaway scripts I'd do in NodeJS to Deno.
People relying on NodeJS for servers and tooling for their client-side webapps might need to wait a bit longer, but for doing small tasks and scripts, I think it is quite ready and better than NodeJS IMHO. These are also good projects to give you a feel for the new runtime.
Standard install, nothing to configure, instant hot reload + modern code and tooling yet no perceivable latency for anything.
It felt like suddenly I could enjoy front end dev.
So I get the appeal of Deno.
But I know this ability to put arbitrary URLs as dependancies in the code are going to be terribly missused and abused.
I can see all the tutorials that will start including them, the bad architecture decisions that will spread them accross all files, the interns that will use localhost there, the typo and domain squatting or black SEO, the rise of people just telling you to put an URL from their site (the same that tell you to curl that bash script), the split from npm, the hardship of scanning/mapping/updating dependancies, the mismatch betwen running and installing bitting you, the undebuggable tickets because of proxies/antivirus/firewalls, the cloud hosting potential for failures, some twisted scenario leading to a DoS...
I know it will cause horrible technical debt down the road.
My spider dev sense is tickling and I'm not going to touch this tech for 5 years, until I either see my prediction unfold, and be completly disproved by its success (but I doubt it, I've been really good in the last 10 years at spotting bad technical choices).
There is a reason we have been using separation of concerns since the down of time. Declaring dependencies, installing them and importing them are 3 different concerns. They should not mix.
I’ve done some Go development, but not enough to really call myself a Go developer so I don’t think I’m qualified to comment one way or the other.
For what it’s worth, I stuck to a policy of only importing from GitHub and forking a repo if I really wanted be sure it would never disappear. If I were doing it today I’d probably expand my list acceptable import sources to include GitLab and Bitbucket as well.
Should not Deno to force the same behaviour to ensure there is less attack surface thru dependencies? I see Deno is taking security seriously.
All the other ones remain.
I can't wait for Stackoverflow spamming to get the scammers answer with a legit solution + url + hash at the top of Google search when typing the name of the package.
Before that, you'd install from npm.
But now, any URL is fair game.
I'll get the pop corn.
Why would someone want to use a new language and a new runtime in production scripts is beyond my understanding.
Just write Python for those. Even Perl, awk or sh would be better options, and that is saying something...
For python, you would need pip. Can you install any script from arbitrary urls using pip?
I am not sure but I don't think you can. You also have to declare your deps for pip to figure out.
With deno, it's just deno run -A url to script since dependencies are declared in the code with their respective url or file location.
You don't need to. Download any module or packgage, put it next to your code, and you can import it. There is nothing to do. There is not even need for metadata.
But yes, pip can install packages from arbitrary URLS, including git repos, if they contains the right metadata.
What's more, with something like shiv (https://github.com/linkedin/shiv), you can actually bundle those dependancies into one zipapp (an official python feature, see https://docs.python.org/fr/3/library/zipapp.html), which is basically a zip containing your entire project that you can just execute like if it were one py file.
A production "script" requiring downloads of third-party code from external servers is already a red flag, by the way.
In principle, there's no reason why the same supply-chain security mitigations npm and other package managers / repositories have put in place could not also be applied in this case: you just apply them at download time, same as before, except now it might result in a runtime error instead of an npm install failure. (No idea if deno does this in its current state, tbh.)
Agree, however, that blindly executing third-party code without somehow vetting it is a security risk.
Also, re: Python - there's a reason why libraries like requests exist; while the Python Standard Library is pretty comprehensive, the APIs it exposes are not always the most intuitive. You might be surprised at how often people pull in helper libraries to work around some of its warts - now, one could argue that maybe they shouldn't do that and should just know the built-in modules better, just as one could argue that functionality is useless unless combined with usability.
And I wasn't implying that production scripts shouldn't be self contained. Just placing my 2 cents on why.
1) Your distribution vendor most likely supports both and allows you to install both at the same time.
2) Your company has probably a policy for that.
3) Small Python scripts are trivial to make compatible with both major versions.
4) Python 2 is deprecated but supported. Just write Python 3 for new code.