Live data from Hacker News

CoreUtils implemented in pure JavaScript

github.com

21–30 of 128 posts

Re: CoreUtils implemented in pure JavaScript

#21
post #18

Earlier quoted context omitted.

Powershell 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 sys…

I 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…

> 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.

Absolutely. The point is, "you can use familiar .NET functions and everything is an object" is not something that makes the whole thing easier if you're not familiar with .NET and don't want objects in your shell scripts :-).

Powershell and Unix shell have vastly different descents, and it shows. It's more or less a historical accident that we're conflating them nowadays.

Re: CoreUtils implemented in pure JavaScript

#22
post #7

Earlier quoted context omitted.

> 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.

Because 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…

In my experience Powershell requires a lot of .NET concepts to understand outside of C# syntax from what I recall, and the amount of typing was far greater than typical Linux shells.

If I'm spending twice the time typing on average, even more advanced features won't win me over when I get to use them occasionally (while, again, typing way more on average). It should be saving you time, in the end.

Re: CoreUtils implemented in pure JavaScript

#23
post #19
post #15

Earlier quoted context omitted.

However, if you want to string programs together and script pre-written code, everything except UNIX shell sucks.

That's why perl never took off, right?

Perl 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.

Re: CoreUtils implemented in pure JavaScript

#25
>Huh? Okay - think Cygwin, except:

Oh boy, another one of these. Cygwin is useful because it provides a POSIX C API on Windows. It is not useful because of its shell and coreutils. And saying it uses "pure ES6" is stretching it - it's using the plain ES5 Node.js require/export patterns instead of ES6 modules.

>1/15th of the size [of Cygwin]

Haha, and 1/100th the functionality

Re: CoreUtils implemented in pure JavaScript

#27

I hope the goals are - short-term : POSIX compliant - long-term : runs *nix binary / programs p/s: love anything CLI, so I may be biased

How would they run *nix binaries in a node.js environment if they call it "Cross-platform Linux without the suck"? You are talking about Cygwin here which is what these guys hate for some reason.

Re: CoreUtils implemented in pure JavaScript

#29
post #5

As far as I can see, what's been implemented is a shell in JavaScript, which emulates a bunch of coreutils by treating them as built-in keywords. It's kinda cool I guess (I don't use Windows), I just don't get why the tagline is "Cross-platform Linux without the suck". Apart from the phrase "cross-platform Linux" not making sense in this context, I don't see why other implementations inherently "suck".

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?

"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.

Re: CoreUtils implemented in pure JavaScript

#30
post #7

Earlier quoted context omitted.

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?

> 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.

Perhaps 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.

Post reply on HN