News for hackers. Stuff that matters.
Re:The Beauty of Unix Pipelines by ianai on Thursday June 04, 2020 @04:59PM (#23421707)
How’s it uncool? Just not “ mobile”?
Re:The Beauty of Unix Pipelines by gorgoiler on Thursday June 04, 2020 @05:07PM (#23421810)
Exactly.

“Linux, ew!”

A big part of teaching computer science to children is breaking this obsession with approaching a computer from the top down — the old ICT ways, and the love of apps — and learning that it is a machine under your own control the understanding of which is entirely tractable from the bottom up.

Unlike the natural sciences, computer science (like math) is entirely man made, to its advantage. No microscopes, test tubes, rock hammers, or magnets required to investigate its phenomena. Just a keyboard.

Re:The Beauty of Unix Pipelines by carlmr on Thursday June 04, 2020 @05:19PM (#23421948)
>No microscopes, test tubes, rock hammers, or magnets required to investigate its phenomena.

They're full of magnets, and with electron microscope you can analyze what's going on in the hardware.

Re:The Beauty of Unix Pipelines by yjftsjthsd-h on Thursday June 04, 2020 @10:22PM (#23424380)
Yeah, but it's not required for a lot of investigation.
Re:The Beauty of Unix Pipelines by jtbayly on Thursday June 04, 2020 @06:07PM (#23422546)
Until stuff goes wrong with the hardware...
Re:The Beauty of Unix Pipelines by shrimp_emoji on Thursday June 04, 2020 @06:29PM (#23422758)
My sense is that people do think Linux is "cool" (it's certainly distinguished in being free, logical, and powerful), but its age definitely shows. My biggest pain points are:

- Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion)

- C/C++ are awful

- Various crusty bits of Linux that haven't aged well besides the above items (/usr/bin AND /usr/local/bin? multiple users on one computer?? user groups??? entering sudo password all the time????)

- The design blunder of assuming that people will read insanely dense man pages (the amount of StackOverflow questions[0][1][2] that exist for anything that can be located in documentation are a testament to this)

- And of course no bideo gambes and other things (although hopefully webapps will liberate us from OS dependence soon[3][4])

0: https://stackoverflow.com/questions/3689838/whats-the-differ...

1: https://stackoverflow.com/questions/3528245/whats-the-differ...

2: https://stackoverflow.com/questions/3639342/whats-the-differ...

3: https://discord.com/

4: http://wasm.continuation-labs.com/d3demo/

Re:The Beauty of Unix Pipelines by anthk on Thursday June 04, 2020 @06:48PM (#23422894)
- Python as a shell would be the worst crapware ever. Whitespace syntax, no proper file autocompletion, no good pipes, no nothing. Even Tclsh with readline would be better than a Python shell.

- By mixing C and C++ you look like a clueless youngster.

- /usr/local is to handle non-base/non-packages stuff so you don't trash your system. Under OpenBSD, /usr/local is for packages, everything else should be under /opt or maybe ~/src.

- OpenBSD's man pages slap hard any outdated StackOverflow crap. Have fun with a 3 yo unusable answer. Anything NON-docummented on -release- gets wrong fast. Have a look on Linux HOWTO's. That's the future of the StackOverflow usefulness over the years. Near none. Because half of the answers will not apply.

Re:The Beauty of Unix Pipelines by viraptor on Thursday June 04, 2020 @07:59PM (#23423489)
You took that python shell too literally. Ipython included a shell profile (you can still use it yourself) and https://xon.sh/ works just fine.
Re:The Beauty of Unix Pipelines by pjmlp on Friday June 05, 2020 @02:20AM (#23425597)
The ISO C and C++ papers are full of C/C++ references, are the ISO masters clueless youngsters?

Or for that matter the likes from Apple, Google and Microsoft?

Re:The Beauty of Unix Pipelines by anthk on Friday June 05, 2020 @09:39AM (#23428370)
EVen C99 has nothing to do with bastard childs such as C++.

The last is convoluted crap, full of redundant functions.

Further C standards do exist, but C99 and heck, even ANSI C can be good enough for daily uses.

Perl, Ruby and PHP look close to each other, being the first the source of inspiration.

But don't try to write PHP/Ruby code as if it was something close to Perl. The same with C++.

Re:The Beauty of Unix Pipelines by blacksqr on Thursday June 04, 2020 @07:53PM (#23423442)
> Even Tclsh with readline would be better than a Python shell

In fact, I think Tcl would make an excellent sh replacement.

Re:The Beauty of Unix Pipelines by yjftsjthsd-h on Thursday June 04, 2020 @10:22PM (#23424385)
So, wish(1)?
Re:The Beauty of Unix Pipelines by anthk on Friday June 05, 2020 @08:06AM (#23427537)
There were attempts in order to create an interactive shell from the TCL interpreter, but the syntax was a bit off (upvar and a REPL can drive you mad), but if you avoided that you could use it practically as a normal shell. Heck, you can run nethack just fine under tclsh.
Re:The Beauty of Unix Pipelines by catalogia on Friday June 05, 2020 @01:31AM (#23425364)
> multiple users on one computer??

Last I checked this is something all the mainstream desktop operating systems support, so for you to call this out as a linux weirdness is baffling.

Re:The Beauty of Unix Pipelines by yjftsjthsd-h on Thursday June 04, 2020 @10:37PM (#23424460)
- Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion)

It has its pain points, but the things that (ba)sh is good at, it's really good at and python, in my experience, doesn't compete. Dumb example: `tar czf shorttexts.tar.gz $(find . -type f | grep ^./...\.txt) && rsync shorttexts.tar.gz laptop:`. I could probably make a python script that did the equivalent, but it would not be a one-liner, and my feeling is that it would be a lot uglier.

- Various crusty bits of Linux that haven't aged well besides the above items (/usr/bin AND /usr/local/bin? multiple users on one computer?? user groups??? entering sudo password all the time????)

In order: /usr/bin is for packaged software; /usr/local is the sysadmin's local builds. Our servers at work have a great many users, and we're quite happy with it. I... have no idea why you would object to groups. If you're entering your sudo password all the time, you're probably doing something wrong, but you're welcome to tell it to not require a password or increase the time before reprompting.

- The design blunder of assuming that people will read insanely dense man pages (the amount of StackOverflow questions[0][1][2] that exist for anything that can be located in documentation are a testament to this)

I'll concede that many GNU/Linux manpages are a bit on the long side (hence bro and tldr pages), but having an actual manual, and having it locally (works offline) is quite nice. Besides which, you can usually just search through it and find what you want.

- And of course no bideo gambes and other things (although hopefully webapps will liberate us from OS dependence soon[3][4])

Webapps have certainly helped the application situation, but Steam and such have also gotten way better; it's moved from "barely any video games on Linux" to "a middling amount of games on Linux".

Re:The Beauty of Unix Pipelines by lsofzz on Friday June 05, 2020 @04:41AM (#23426338)
> - Bash is awful (should be replaced with Python, and there are so many Python-based shells now that reify that opinion)

You know that no one uses Bash these days right?

Fish shell, Zsh are the much newer and friendlier shells these days. All my shells run on Fish these days.

I have to tell you that my shell ergonomics has improved a lot after I started using fish shell.

But to your point, _why_ is Bash awful?

Re:The Beauty of Unix Pipelines by darkwater on Friday June 05, 2020 @04:59AM (#23426436)
> You know that no one uses Bash these days right?

I strongly disagree although, just like you, I have no evidence to support my claim

Re:The Beauty of Unix Pipelines by lsofzz on Friday June 05, 2020 @05:02AM (#23426460)
> I strongly disagree although, just like you, I have no evidence to support my claim

Haha. Fair enough!

Re:The Beauty of Unix Pipelines by gitgud on Friday June 05, 2020 @01:09AM (#23425273)
I don't get this. Linux is just the kernel, there's a variety of OS distributions which allow you to customise them infinitely to be what ever you want.
Re:The Beauty of Unix Pipelines by ma2rten on Thursday June 04, 2020 @07:10PM (#23423072)
I was also skeptical of that statement. I did a google trends search and indeed there seems to be a slow decline in command-line related searches:

https://trends.google.com/trends/explore?date=all&q=bash,awk...

Re:The Beauty of Unix Pipelines by remexre on Thursday June 04, 2020 @05:47PM (#23422297)
My complaints with unix (as someone running linux on every device, starting to dip my toe into freebsd on a vps); apologies for lack of editing:

> everything is text

I'd often like to send something structured between processes without needing both sides to have to roll their own de/serialization of the domain types; in practice I end up using sockets + some thrown-together HTTP+JSON or TCP+JSON thing instead of pipes for any data that's not CSV-friendly

> everything (ish) is a file

> including pipes and fds

To my mind, this is much less elegant when most of these things don't support seeking, and fnctls have to exist.

It'd be nicer if there were something to declare interfaces like Varlink [0, 1], and a shell that allowed composing pipelines out of them nicely.

> every piece of software is accessible as a file, invoked at the command line

> ...with local arguments

> ...and persistent global in the environment

Sure, mostly fine; serialization still a wart for arguments + env vars, but one I run into much less

> and common signalling facility

As in Unix signals? tbh those seem ugly too; sigwinch, sighup, etc ought to be connected to stdin in some way; it'd be nice if there were a more general way to send arbitrary data to processes as an event

> also nice if some files have magic properties like /dev/random or /proc or /dev/null

userspace programs can't really extend these though, unless they expose FUSE filesystems, which sounds terrible and nobody does

also, this results in things like [2]...

> every program starts with 3 streams, stdin/stdout for work and stderr for out of band errors

iow, things get trickier once I need more than one input one one output. :)

I also prefer something like syslog over stderr, but again this is an argument for more structured things.

[0]: https://varlink.org/

[1]: ideally with sum type support though, and maybe full dependent types like https://dhall-lang.org/

[2]: https://www.phoronix.com/scan.php?page=news_item&px=UEFI-rm-...

Re:The Beauty of Unix Pipelines by shakna on Thursday June 04, 2020 @08:43PM (#23423803)
> As in Unix signals? tbh those seem ugly too; sigwinch, sighup, etc ought to be connected to stdin in some way; it'd be nice if there were a more general way to send arbitrary data to processes as an event

Well, as the process can arbitrarily change which stdin it is connected to, as stdin is a file, you need some way to still issue directions to that process.

However, for the general case, your terminal probably supports sending sigint via ctrl + c, siquit via ctrl + backslash, and the suspend/unsuspend signals via ctrl + z or y. Some terminals may allow you to extend those to the various other signals you'd like to send. (But these signals are being handled by the shell - not by stdin).

Re:The Beauty of Unix Pipelines by remexre on Friday June 05, 2020 @03:21AM (#23425908)
Sure, I mean more like there'd be some interface ByteStream, and probably another interface TerminalInput extends ByteStream; TerminalInput would then contain the especially terminal-related signals (e.g. sigwinch). If a program doesn't declare that it wants a full TerminalInput for stdin, the sigwinches would be dropped. If it declares it wants one but the environment can't provide one (e.g. stdin is closed, stdin is a file, etc.) it would be an error from execve().

Other signals would be provided by other resources, ofc; e.g. sigint should probably be present in all programs.

---

In general, my ideal OS would have look something like [0], but with isolation between the objects (since they're now processes), provisions for state changes (so probably interfaces would look more like session types), and with a type system that supports algebraic data types.

[0]: https://www.tedinski.com/2018/02/20/an-oo-language-without-i...

Re:The Beauty of Unix Pipelines by Bystroushaak on Wednesday June 17, 2020 @08:19PM (#23558412)
I have written something on this topic previously: http://blog.rfox.eu/en/Programmers_critique_of_missing_struc...
Re:The Beauty of Unix Pipelines by blibble on Thursday June 04, 2020 @08:40PM (#23423781)
> iow, things get trickier once I need more than one input one one output. :)

you can pass as many FDs to a child as you want, 0/1/2 is just a convention

Re:The Beauty of Unix Pipelines by remexre on Friday June 05, 2020 @03:02AM (#23425827)
At that point you're writing something for /usr/libexec, not /usr/bin though. (i.e., at that point it becomes sufficiently inconvenient to use from the shell that no user-facing program would do so.)
Re:The Beauty of Unix Pipelines by JdeBP on Friday June 05, 2020 @04:37AM (#23426315)
That's pretty much false on every point.

* https://unix.stackexchange.com/a/331104/5132