7 ms·
I don't understand this at all. UNIX shells suck. Javascript sucks. How could one implement a UNIX shell in Javascript and have it not suck? Does the result suc
by karmabadger 11y ago
I don't understand this at all. UNIX shells suck. Javascript sucks. How could one implement a UNIX shell in Javascript and have it not suck? Does the result suck so bad that it just wraps around becomes good again?
Is the "way forward" recombining and rehashing the terrible technologies everyone is familiar with already, indefinitely?
- cyphar 11y ago> UNIX shells suck. Javascript sucks. How could one implement a UNIX shell in Javascript and have it not suck? What do you mean by "UNIX shells suck"? I'm fairly sure most people would consider UNIX shells to be one of the bigger revolutions in computing.
- viraptor 11y agoSome people would agree with both statements. UNIX shells are amazing and the recent improvements in their UX and environment integration is great. (git repo status, programming environments, intelligent completion, the whole of oh-my-zsh, ...) But as soon as you want to do anything moderately interesting, it's better to grab a real programming language, because UNIX shells suck. Escaping failures, whitespace handling, almost-real-arrays, fail-and-continue by default, and many many other reasons you'll fail by accident one day is why they absolutely suck for almost anything past basics.
- Already__Taken 11y agoIf someone were to make a distro with powershell instead of the unix shell I'd lose my mind.
- wohlben 11y agoi haven't really used PS, but from what i understand you'd also need to rewrite every other program to adhere to its rules. as - if i understood it correctly - the real benefit of powershell is that they all use the same output format. this decreases the trouble of handing output from one command to the next significantly.
- cyphar 11y agoIt should be noted that basically all tools use the same format: text. And badly behaving tools can be cooerced with a single line of awk.
- cbd1984 11y agoHowever, if you want to string programs together and script pre-written code, everything except UNIX shell sucks.
- rodgerd 11y agoThat's why perl never took off, right?
- cbd1984 11y agoPerl is actually more in the "real language" camp, believe it or not: It makes it more verbose to launch other programs than to not launch them, and it doesn't have pipes. In a shell, any bareword is either one of a few built-ins or an external program. Using a bareword which doesn't correspond to anything isn't a syntax error, because the parser can't know what programs you have installed from moment to moment. That is the biggest difference between a shell CLI and a programming language REPL.
- laumars 11y agoThe next step up would then be a REPL shell. As much as I love the idea of us running Lisp machines, at least $SHELL has a moderate enough learning curve that both beginners and experts can exploit many of it's features. Plus while many (most?) of us are programmers, there are quite a number of administrators who don't enjoy coding or even can't code at all. $SHELL is entry level enough that even they can chain a few commands together where a fully featured programming language's REPL shell would just intimidate them away from the command line entirely. This is, in my opinion, the beauty of UNIX shells. They're simply enough to use like DOS but powerful enough to use like a REPL. It's not perfect; far from it. But few other tools support such a wide demographic.
- lispm 11y agoUnix shells are notoriously not user friendly. The commands and their interfaces are full of insonsistencies and often really strange. Reading man pages is horror. The shell languages are not much better. There are some useful concepts, but in general Unix shells are used despite their user unfriendliness. The shells of the various Lisp Machines were quite different. The Symbolics shell, later called Dynamic Lisp Listener was quite nice on the GUI side and the management of commands, completions, defaults, interactive help, etc.. See for example: https://www.youtube.com/watch?v=o4-YnLpLgtk https://www.youtube.com/watch?v=o4-YnLpLgtk The interactive help of that Lisp Machine OS is quite a step up from what any typical shell offers. Though it was mainly developed for single user machines with powerful GUIs. The problems of that approach: it wasn't very sophisticated on the text terminal - actually it was quite bad. The whole UI mostly assumed a GUI. For development one needed an extended Common Lisp (or Zetalisp), which is a bit too complex for many users. See also a video I made long ago about the user interface of Symbolics Genera, the operating system of the Symbolics Lisp Machine line of personal workstations. https://vimeo.com/159946178 https://vimeo.com/159946178
- laumars 11y ago> Unix shells are notoriously not user friendly. The commands and their interfaces are full of insonsistencies and often really strange. Reading man pages is horror. They're not that bad (GNU coreutils is generally pretty good) and you usually remember the edge cases fairly quickly (eg `dd`). Sadly you get inconsistencies in all coding frameworks, whether it's semantic, function names in the core libraries or whatever. UNIX shells do have a lot of hidden gotchya's which can make life "interesting" (read: "oh fuck oh fuck oh fuck" lol). But the power of being able to use reusable blocks of any language through pipelining (and to a lesser extent, exit codes) is genius. It means one can mix and match LISP, Java, Perl, Python, C++, Go all inside one shell script. I do understand the hate towards UNIX shells. There are a lot of faults and a lot of times I I'd be halfway through writing a Bash script and then be wondering if I should have just written it in Perl or Go instead. But no tool is perfect and pragmatically I've found shells to be far more productive than anything I've ever attempted to replace it with. Which is the real crux of why we use these tools. But like anything in IT, this is just my personal preference. Your mileage may vary.
- Sanddancer 11y agoBecause the shell has a lot of room for improvement. Try powershell for a bit. Look at its design, look at the things it can do that the unix shell has problems with. Everything's an object. Instead of passing lines of text, you're passing objects, with properties, types, etc. This becomes important because of Library files are first class citizens. Because the shell is string based, you have to wrap everything up in functions, creating helpers in order to use any sort of function. Powershell makes this trivial, such that you can use functions you wrote elsewhere in your scripts as if they were builtins. Hell, it's trivial to write a webserver that forks multiple processes in powershell. Yes, the unix shell was revolutionary when it was released, but it's been hamstrung by tradition. The shell is long overdue for letting in more interesting abilties.
- viraptor 11y agoAnnoyingly they're "good enough". Default shell will always stay sh-compatible. Scripts will always default to bash. I'd love for something like powershell to take over the unix world (ok, not exactly powershell, it has its problems too), but I don't think that's going to happen for the next 20ish years. Hybrids like ipython shell are quite interesting for personal use though.
- notalaser 11y agoPowershell is a great programming language an not a bad shell in and of itself, but using it in the same manner as a shell is quite painful. I tried to rewrite some of my ksh stuff in Powershell after getting a job at a mostly Windows-only shop. Basically every ten-line function ended up into a fourty-line superthing that's subtly incomprehensible to anyone who doesn't know .net. I get why Powershell is great for sysadmins (and especially on Windows, where so many system-level utils weren't built with the idea that you'd pipe their output in mind), but for me, it's a step back.
- Someone 11y agoI agree that Powershell for a large part doesn't feel like a shell. Yes, it has a CLI, and it has short commands (actually aliases for longer names), but using it feels more like programming, at least to me. Having said that, I can't vouch for your scripts, but my 10 line shell scripts are unlikely to handle 'edge' cases such as spaces, quotes and backticks in file names. Also, "incomprehensible to anyone who doesn't know .net" may be true, but your average shell script that builds on tools such as sort, grep, ls, cut, cat, sed, awk, etc. isn't that particularly comprehensible to people who don't know UNIX, either. Finally, I think it is likely that people who grow up on Powershell feel differently about this.
- pdpi 11y agoPerhaps it's my own shortcoming, but for any given script I write, I find that, say, 20% of all my code is productive, and the remaining 80% is massaging the output of one tool into a shape that's compatible with the input of the next tool. Compare with the exprience of using Windows PowerShell where cmdlets return objects and you can grab precisely the fields you want with minimum ceremony. Things are better now with builtin tests, but god help you if you need to use /bin/[ and you end up with idioms like 'if ["x$foo" = "x$bar"]' so that bad things don't happen if $foo starts with a dash, or either variable is empty. It gets even more fun when you look at the amount of cruft around terminal emulators themselves, and the support for legacy terminals in the command line. Why do modern versions of OSX still ship with /usr/lib/libtermcap.dylib? Don't get me wrong -- UNIX shells are amazingly powerful tools, but they're just stuck in the 70s and we can do much better today.
- manyxcxi 11y agoI think that's the point- they're amazingly powerful. Additionally with POSIX, you can assume that the command you used on one OS behaves or at least outputs the same on another. I feel like the interface for these commands is exactly what you'd want from a collection of executables that do only one thing. As for shell scripting, you don't have to use bash/sh/whatever. You could write your script or executable in any language that will let you call system commands, so it's really a non-issue if you absolutely can't stand the syntax. I write plenty of bash scripts and I do feel your pain, they're not usually very pleasant if you have to go beyond trivial use cases- but it's also (generally) not impossible.
- saulrh 11y agoIf you like PowerShell, try using jq in your Unix shell pipelines. Ingesting data into json is still a bit finicky, but once you know the patterns you need to use with cut and a csv-to-json tool things become much faster.
- pdpi 11y agoI do love jq :) Hadn't thought of chaining that with a csv-to-json workflow, that's a neat idea -- but if that's the easiest way out, that's clearly a symptom of the problem I'm describing, isn't it?
- StreamBright 11y agoWell actually no. I am fluent in several shells (ksh, bash, fish, zsh) but I would not say that UNIX shells are awesome. Most of the CLI tools written for UNIX-like clones are fixing the shortcomings of shells. On the other hand you can do a lot (and I am not even fluent) with PowerShell while not needing a huge "core utils" equivalent on Windows. I used to work for a company that ported PowerShell features to UNIX so we could do lots of things that otherwise would have been impossible or very hard to do only with coreutils + shells. UNIX is old and it has many flaws but it is also wide spread and people think it is "awesome". In fact, if you look to other systems, for example VMS those had better features than UNIX (and clones). Again, I have something like 15+ years on Linux and other UNIX-like clones.
- dietrichepp 11y agoYes, I don't understand it either. "No ugly DLLs" but you have to run everything in Node.js. There are a few technologies that have tried to do something better than Unix shells, like Microsoft's PowerShell. It has a lot of failings, but it gets a lot of things right. I am always stunned when I see Windows folks stumbling around in cmd.exe when PowerShell has been installed standard for a while now. There's still a lot of room for improvement.
- marklgr 11y ago"X sucks" doesn't say much, except you don't like X (for whatever reasons). You need to say what it is supposedly bad for, for whom, in what context, and compared to what.
- callumlocke 11y agoThere's a module available to put each command on your PATH: npm install cash-global -g
- betenoire 11y agoMachine code sucks. For the love, how can we ever get past that?