Live data from Hacker News

ZX – A tool for writing better scripts

github.com

81–90 of 143 posts

Re: ZX – A tool for writing better scripts

#81
post #18

This looks really cool, actually, and I'm surprised I haven't heard of this before. My incorrect gut intuition is that JavaScript devs usually don't do very much in depth terminal level command work, but that's of course false on a Bayesian level. There are far more JavaScript developers in the world than there are even Python developers, to say nothing of the long tail of even less popular languages. If 30% of JS de…

> There are far more JavaScript developers in the world than there are even Python developers I don’t think that’s true. Anecdotally when I was interviewing at a recruiting company (and we let candidates pick any language to be assessed in), Python was by far the most popular choice, chosen by about 60% of candidates or something like that. Java and JavaScript came after, followed by a long tail of languages like C#…

Is it a recruiting company, as it's main business is to recruit candidates ? Or was the core business something else and you were recruiting devs for it ?

I think it's always difficult to get the bigger picture of the dev market through candidates. Many (rightfully) handle their career moves by themselves and will directly apply to companies that fit them, heavily biasing the movement observed from the company or third party recruiters.

Re: ZX – A tool for writing better scripts

#82
post #56

>Write your scripts in a file with an .mjs extension in order to use await at the top level. If you prefer the .js extension, wrap your scripts in something like void async function () {...}(). Shebang scripts shouldn't have a file extension in the first place, so requiring one here is a dealbreaker. And having the file extension be used to switch between two different incompatible source formats is really a terrible…

I think this is a Node.js limitation, not a design choice by ZX.

You could perhaps use a different JS runtime that doesn't have these admittedly esoteric file extension rules.

Re: ZX – A tool for writing better scripts

#83

When my shell scripts get too large, I usually switch to Perl. Still best in class at handling text processing with a few shell commands here and there.

I'm doing that with Ruby, and tgrought the years, it became also true for scripts that are fetching data, iterating over JSON objects, etc.

What makes Ruby great for this is you can specify dependencies inline

  require 'bundler/inline'

  gemfile do
    source 'https://rubygems.org' 
    gem 'json', require: false
    gem 'nap', require: 'rest'
    gem 'cocoapods', '~> 0.34.1'
  end

Re: ZX – A tool for writing better scripts

#85
post #64

Related: Zx 3.0 - https://news.ycombinator.com/item?id=28195580 - Aug 2021 (163 comments) JavaScript for Shell Scripting - https://news.ycombinator.com/item?id=27072515 - May 2021 (181 comments)

And tangential:

Nushell (300-400 comments),

- https://news.ycombinator.com/item?id=20783006

- https://news.ycombinator.com/item?id=27525031

- https://news.ycombinator.com/item?id=33419944

Ask HN: Are alternative (oil, nu, etc.) shells usable as daily drivers? (141 comment)

- https://news.ycombinator.com/item?id=34722208

Re: ZX – A tool for writing better scripts

#86
post #37

"[For writing complex scripts] JavaScript is a perfect choice". Not sold on that. Why should I choose it over Python, PHP or others?

It's asynchronous, which is pretty neat

A script, by its very nature, is synchronous. You run, you get a result. If you want a service, don't use a script.

Re: ZX – A tool for writing better scripts

#87

"Bash is great, but when it comes to writing more complex scripts, many people prefer a more convenient programming language." https://google.github.io/zx/getting-started I read this and think "1. Bash is not great. 2. Why assume that I want to write complex scripts." I like simple scripts. I am embarassed by any complexity. It is the mark of a cluttered mind. As it happens, there have been and still are others that…

In my opinion any bash script longer than a one liner is complex and should be rewritten in another language. Too many footguns.

Re: ZX – A tool for writing better scripts

#88
post #66

Earlier quoted context omitted.

> Shebang scripts shouldn't have Should not have or should not need to have? You can perfectly write a script with a shebang and an extension, stick it in your path, and use it without extension. Therefore, I fail to see how this is a "dealbreaker". Or is it just because "I don't like it!"?

So how am I supposed to put such a script in $PATH? e.g. if I hypothetically want to make a replacement for say 'ls', what am I supposed to do, force people to type 'ls.mjs' rather than 'ls'?

ln is your friend

Re: ZX – A tool for writing better scripts

#89
post #18

This looks really cool, actually, and I'm surprised I haven't heard of this before. My incorrect gut intuition is that JavaScript devs usually don't do very much in depth terminal level command work, but that's of course false on a Bayesian level. There are far more JavaScript developers in the world than there are even Python developers, to say nothing of the long tail of even less popular languages. If 30% of JS de…

> There are far more JavaScript developers in the world than there are even Python developers I don’t think that’s true. Anecdotally when I was interviewing at a recruiting company (and we let candidates pick any language to be assessed in), Python was by far the most popular choice, chosen by about 60% of candidates or something like that. Java and JavaScript came after, followed by a long tail of languages like C#…

Maybe a lot of things start in Python, because so many people know it, and no one wants to change languages after a project starts?

Python also has a very wide range of applications so while there are many languages more popular in a particular area, Python is extremely widely used in aggregate. By contrast it is unusual to write numerical code in PHP or web apps in C.

Post reply on HN