logoalt Hacker News

klibertptoday at 5:30 PM2 repliesview on HN

Not sure why it wouldn't be usable for that:

    -▶ ./red-cli-066
    --== Red 0.6.6 ==--
    Type HELP for starting information.

    >> call/console "echo 123"
    123
    == 0
    >> call/console "pwd"
    /home/cji/portless
    == 0
`call` has a bunch of refinements (toggles or switches appended to the function name with a slash; I'm using /console to redirect output to the parent's stdout), but it's a pretty low-level interface. You definitely could define a few simple helpers and get to a usable Unix-like shell pretty quickly. You'd get native AOT compilation for all your shell scripts for free.

The problem is that you could write those helpers in just about any language, and while Red has an edge over many due to the regular and simple syntax, it's by no means unique in that regard (TCL is an obvious alternative, Lisp-likes are also strong, and even Smalltalk could join the chat if you don't care too much about startup time). And 32-bit-only thing doesn't look good, even if it's not an actual problem in most cases.

In short: it can, but why would you? (Don't get me wrong: I like Red! But with so many other interesting languages (if you're willing to look past TIOBE Top 20), it's hard to justify investing more time into learning Red in particular.)


Replies

em-beetoday at 8:26 PM

that was kind of a rhetoric question. i was already pretty sure it would work. so the real question is what is actually needed.

i found the call documentation. that's a good start, but that is pretty much what every other language also provides. what is still needed is a wrapper that allows me to write

    somestr: some command --with arguments
and have that string be populated with the "some" command output. but then we also need to capture stderr and the exit value, so we actually need to capture three return values. next, support for pipes in some form would also be needed.

i have worked with lisp and smalltalk and also TCL so i am aware of course.

with so many other interesting languages, it's hard to justify investing more time into learning Red in particular

i actually find red in particular one of the more interesting languages. alongside lisp and smalltalk. haskell, erlang and ocaml are also interesting, but for shell use i am specifically looking at languages that use whitespace as an argument and value separator and which allow complex expressions to be written on one line, since that happens often in shell commands. that reduces the list of interesting languages quite a lot. if you know any others that you think are worth learning, please share.

btw, your website seems to be down.

show 1 reply
ulbutoday at 5:51 PM

I think they mean red as a shell scripting/command line language.

show 1 reply