Live data from Hacker News

Zx 3.0

github.com

71–80 of 169 posts

Re: Zx 3.0

#71
post #64

Somewhat related, if you are looking to do scripts in Python you should take a look at `sh`: import sh print(sh.ifconfig("eth0")) https://amoffat.github.io/sh/

Is this the ergonomic `subprocess.Popen` alternative?

Yes this wraps subprocess.Popen in a nice API.

Re: Zx 3.0

#72
As annoying as having to write "await" in front of everything is (probably should have a variant of $ that's synchronous), the ability to effortlessly implement parallelism is something that all other common scripting (and many "full") languages seem to lack.

Even Go, that prides itself on the good support for parallelism, fails once you actually want go get results back.

If this were paired with some way to also display the status/output of multiple commands in parallel, this would be the ultimate toolkit to write scripts.

If you look at apt, for example: Does it really have to wait for the last package to be downloaded before installing the first? Is there a good reason, on modern SSD-based computers, to not parallelize the installation of multiple packages that don't depend on each other?

Re: Zx 3.0

#73
Shameless plug:

If you want the exact opposite of this (that is, to use JS from the shell), try https://bashojs.org

For example:

  curl 'https://api.openweathermap.org/data/2.5/weather?q=Bangalore&appid=2a125de83c277f4ce0ace5ed482f22b9' | basho --json -j 'x.weather[0].description + ", feels like: " + Math.round(10 * (x.main.feels_like - 273.15))/10 + "°C"'

Re: Zx 3.0

#74

Earlier quoted context omitted.

Many companies make claims over their employees' intellectual property. How much of a claim they actually have legally is a different question, which depends on the country (and sometimes state) where the employee works, and companies routinely attempt to claim more than they legally can. Compare e.g. https://thebusinessprofessor.com/en_US/property-law/californ... I bet Google lacks the copyright for many of the proj…

Maybe true, but I am unwilling to try my luck. I mean, the process I mentioned above takes 30 minutes [1] if it's clear you aren't competing with Google and so I don't see a major issue about playing it safe and have written consent to develop your idea/project. [1] you fill a form with the general idea description, you explain succinctly why it doesn't compete to any Google product, and you acknowledge you won't use…

It takes maybe 30 minutes to fill out, but the O(days) approval latency is what absolutely killed me. No way to do impromptu commits to random non-Google-license-approved projects, no way to hack together something with friends over a beer, no way to quickly bash together a proof of concept and release it the same evening.

It might work for people who chisel away at their own long-term one-person pet projects, but breaks down if you're used to quickly hacking away collaboratively in various groups. Especially if you're an active member of a hackerspace.

Re: Zx 3.0

#75

In my first job I gave a try at using Python for scripts. It was a terrible idea, as I now had 3 problems instead of 1: 1 - Writing scripts, plus: 2 - Installing Python in every host that needed to run those scripts 3 - Maintaining Python and the necessary dependencies up to date in each host / container. (2) and (3) are trivial when done just once in your own computer, but end up being a huge time sink for larger he…

Luckily today you can side step many of these issues. You can compile a copy of python + modules + pex into a single file with some open source tooling and get a flat file you just need to copy to your hosts.

Re: Zx 3.0

#76

Earlier quoted context omitted.

Not true. You need explicit permission (there is a process for obtaining it, and it is very lightweight as I've done it myself). The general idea is that you get permission without much hassle if you develop something that doesn't compete with Google. You need to argue your case otherwise. Source: I'm a Googler that went through the process before. Edit #1 for all Googlers reading this: search "IARC" internally and y…

Many companies make claims over their employees' intellectual property. How much of a claim they actually have legally is a different question, which depends on the country (and sometimes state) where the employee works, and companies routinely attempt to claim more than they legally can. Compare e.g. https://thebusinessprofessor.com/en_US/property-law/californ... I bet Google lacks the copyright for many of the proj…

Many countries have a "formula" (legal definition) for a "contract", which include fair exchange of something for something else, e.g. time and labor for money. If Google forces their developers to work for free (labor for nothing), then it fails to meet legal definition of the contract.

IMHO, such "forced labor for free" is a form of slavery. Slavery is forbidden by law.

If a developer want to publish his project under Google brand, then exchange may be considered as fair (project code for Google branding).

Re: Zx 3.0

#77

Earlier quoted context omitted.

It's like UX but for developers...

Which makes no sense if the developers are the users... But in the spirit of "there are only two business models - bundling and unbundling", I guess there are only two marketing tricks: use an old term for a new thing, and introduce a new term for an old thing...

Or more charitably, while the UX/DX distinction isn't very meaningful for this project, there are lots of products (e.g., payments) that target both (non-developer) end users and developers. It helps to be able to separate the personas.

Re: Zx 3.0

#78
post #57

I personally find Ruby's built-in shell features more ergonomic: `cat package.json | grep name` branch = `git branch --show-current` `dep deploy --branch=#{branch}` if $?.success? [ "sleep 1; echo 1", "sleep 2; echo 2", "sleep 3; echo 3", ].map { |cmd| Thread.new { %x(cmd) } }.each(&:join) name = 'foo bar' `mkdir /tmp/#{name}` if $?.success?

What I don’t like about backticks in Ruby is that they “ignore” errors in commands you run. It’s up to the program author to remember to check $? for the last executed command’s exit status. And guess how many times the average Ruby script using this feature implements error handling? Usually it’s totally forgotten. To be safe, abstractions that make it easy to shell out must also: - escape all variable interpolation…

I agree that people often don't treat the exit code the way they should when using the backticks. However there's better options in the ruby stdlib too, like `system` and `spawn` and `popen`. Using the other methods allows you to also sidestep the shell if you know the arguments you want to pass.

Re: Zx 3.0

#79

Earlier quoted context omitted.

Maybe but Python is sloooow and its type annotation situation is pretty poor. I would recommend using Deno. It has the following advantages: * Uses Typescript which gives you a great static typing system. * Runs via V8 so it's about a million times faster than Python. * Single statically linked binary with no project setup files required (package.json/dependencies.txt) makes it about a million times easier to deploy…

I’ve found Python is just fine performance-wise for CLI tools. What bad experiences have you had with it? I’ve mostly used click.

Startup time is very slow. I just tested on my system and cold startup was 1 second (!) and hot 180ms. Vs 80ms and 64ms for Node.

Also it obviously depends what your CLI tool is doing. Just because something is a CLI tool doesn't mean it doesn't do much stuff and therefore performance doesn't matter.

For example Scons is a CLI tool. It's a build system written in Python. Everybody abandoned it because it was dog slow.

Mercurial is a CLI tool. It's a VCS written in Python. Most people have abandoned it partly because it is slow (and partly because Github exists).

You can read about Mercurial's troubles with Python performance here:

https://www.mercurial-scm.org/wiki/OxidationPlan

> Performance is a significant pain point with Python. There are multiple facets to the performance problem:

> * Startup overhead

> * General performance overhead compared to native code

> * GIL interfering with parallel execution

> It takes several dozen milliseconds to start a Python interpreter and load the Mercurial Python modules. If you have many extensions loaded, it could take well over 100ms just to effectively get to a Mercurial command's main function. Reports of over 250ms are known. While the command itself may complete in mere milliseconds, Python overhead has already made hg seem non-instantaneous to end-users.

Re: Zx 3.0

#80
post #38
post #28

Earlier quoted context omitted.

The copyright of the thing Googlers build on their oswn time are usually owned by Google and so it ends up on the Google org if they want it on GitHub. They usually have a disclaimer like "this is not a official Google product..."

This isn't correct: if a Googler writes some code from scratch, which is unrelated to their work, on their personal time, and using their personal laptop... then it's definitely not owned by Google. There could be gray areas where code ownership could be disputed, but in general your employer owns only the intellectual property it paid for. Source: I'm a Googler (until next month).

Double-check your employment contract. The offer I received (and declined, primarily for other reasons but this was on the list) in 2017 clearly stated that it had to be unrelated to any of Google's work as a whole, and in fact to Google's actual or anticipated work - not just to the employee's assigned work.
Post reply on HN