Hacker News new | ask | show | jobs
by tyingq 1949 days ago
I do find <> helpful. Perhaps if it were more descriptive? <ARGVorSTDIN> or similar?
2 comments

In Ruby it's called ARGF (https://ruby-doc.org/core-2.7.1/ARGF.html) — which, if not perfectly descriptive, is at least evocatively similar to ARGV.

If you're already aware that ARGV exists, you'll guess that ARGF might be used in relation to it, and so when writing a CLI program that uses ARGV, you might wonder if ARGF could simplify your code and look up what it is/does.

Yeah to be clear it's not the functionality that bothers me, it's just the syntax. Ideally since it's not even a proper variable since it changes after reading it should probably look like a function call.

These ultra terse shorthands make some sense in the shell because it's meant for interactive, write-only commands but a scripting language should be a little more verbose and consistent IMO.

I'm a huge fan of preserving knowledge and building on it. Most people, at the time at least, knew what

while (buf = <>)

did. So I didn't want to invent a new syntax, there is way too much of that going on, I like C, I like perl, pull the useful stuff from each and move on.

I freely admit it's not how everyone would do it.

There’s a balance because people really seem to like ? as null coalescing, => for lambdas =~ for regex match, etc..

I think <> as a fancy readline and _ as a default/throwaway variable does really improve readability and lowers the mental load of understanding programs.