Live data from Hacker News

Closh – Bash-like shell based on Clojure

github.com

121–130 of 138 posts

Re: Closh – Bash-like shell based on Clojure

#121

Earlier quoted context omitted.

It's a highly performant platform, based on a rapidly evolving language that's easy to understand. As such it's largely democratised server/shell programming to millions of users and web developers who could have been turned off by more advanced syntaxes and programming concepts. These people have created millions of open source packages which now dwarf most other communities, and the platform has unlocked an incredi…

Millions of open source packages. Right.

When you can have a package to wrap one line of code its easy to have lots of packages.

Re: Closh – Bash-like shell based on Clojure

#122
post #102

Earlier quoted context omitted.

> I'm not sure how this would work with Python or JS. .method().method()?

Exactly what yoavm said. The pipelining that shell languages do allows for more complex and more arbitrary data transformations. I feel that doing this in Python would be difficult, but I'm not very familiar with it. In scheme you can do something like this: (define (pipe . exprs) (if (null? (cdr exprs)) (car exprs) (apply pipe (cons ((cadr expr) (car expr)) (cddr expr))))) (pipe '(3 4 5) (lambda (x) (map 1+ x))) ;;…

Wrote something similar in Python, even called it the same!

    def pipe(init_val, *funcs):
        """Apply `init_val` to the composition of `funcs`
    pipe(init, func1, func2, ..., funcn) -> funcn(...(func2(func1(init_val))))
    """
        return functools.reduce(lambda val, func: func(val), funcs, init_val)

Check out clojure's threading macros[1] which extends that to taking forms, where the current value is spliced in as the first or last argument. e.g., with ->> (thread-last):

    (->> '(3 4 5) (map 1+) (reduce +)) ;; 15
Fits the bill for short functions, and you can still have lambdas for when you really need them.

[1] https://clojure.org/guides/threading_macros

Re: Closh – Bash-like shell based on Clojure

#123
post #117

Earlier quoted context omitted.

>node is a pretty good platform to build on. Lol.

Yeah. I have the feeling people like Node because they know JS, and Node gives them JS. That's it.

They worship Node because it gives them an earning opportunity while not having to put in any real effort in learning and thinking in my opinion. If C# was made mandatory for example I imagine this lets kode trend would die pretty quickly.

Re: Closh – Bash-like shell based on Clojure

#124
post #71

Earlier quoted context omitted.

Ideally, we want a Symbolics Clojure Machine.

I suspect that a hardware JVM implementation would get you halfway there.

There are still a few chipset companies selling CPUs with support for JVM bytecode.

As alternative, if one is feeling bored, why not create an FPGA for it? :)

Re: Closh – Bash-like shell based on Clojure

#125
post #4

> Why try to reinvent bash? > ... > It treats everything as text while we mostly need to manipulate structured information. Looking at the examples given, it's more like Powershell, but with better compatibility with existing Unix text-based tools. Which is awesome.

It seems like the concepts are orthogonal though. The reason powershell works is that it replaced the entire shell toolchain with object-oriented equivalents. Without that you're fundamentally limited because your inputs are still plain text, so you're still doing the equivalent of awk/sed scripts to transform text into structured data.

Using the same concepts as the REPL on Interlisp-D, Symbolics, Smalltalk, Mesa/Cedar, Oberon environments.

Which kind of makes Windows, with VS, .NET and Powershell, the closest to those environments.

Re: Closh – Bash-like shell based on Clojure

#126
post #105

Earlier quoted context omitted.

I don't think it is. In the words of Bill Clinton: "it's the economy, silly". Economic/social factors trump technical aspects 99% of the time, the 1% being technical revolutions. And Java or C# or Lisp being better than Javascript doesn't fall into the "revolution" category. Ergo Javascript everywhere :)

can run Javascript on the JVM, so I'm wondering what Node has over the JVM

SV hip factor.

Re: Closh – Bash-like shell based on Clojure

#127
post #89

Earlier quoted context omitted.

I think the concept of piping is actually more similar to function(function()) than .method().method(), because you're not limited to the scope of your initial object's methods. And the truth is that functionB(functionA()) reads much worse than functionA | functionB , so yeah I agree that this is something that shell scripting languages got right.

Clojure has threading macros that turn (function(function(function) into (-> function function function) An interesting take on that is a library called swiss arrows that lets you do (- (function arg1 ) (function arg2) (function arg1 arg2 ) Using the to indicate where the result of calling one shall be threaded into the next.

That's in the standard library, actually. It's called as->.

    (as-> value 
          (function1 arg1 )
          (function  arg2)
          (function arg1 arg2 ))

Re: Closh – Bash-like shell based on Clojure

#128
post #127

Earlier quoted context omitted.

Clojure has threading macros that turn (function(function(function) into (-> function function function) An interesting take on that is a library called swiss arrows that lets you do (- (function arg1 ) (function arg2) (function arg1 arg2 ) Using the to indicate where the result of calling one shall be threaded into the next.

That's in the standard library, actually. It's called as->. (as-> value (function1 arg1 ) (function arg2) (function arg1 arg2 ))

Found the old swiss arrows and didn't realize that as-> even existed thank you.

Re: Closh – Bash-like shell based on Clojure

#129
post #66

Earlier quoted context omitted.

That’s answered in the comments elsewhere on this page. Mainly because shell processes are started frequently and the JVM start-up time would be much too slow.

JVM starts pretty fast, the problem lies within Clojure's implementation. One can even AOT to native code, if desired.

The JVM is well-known to start slowly. It's not just clojure. For example, that's why people don't write command-line scripts in scala. I mean this is what I've always read, and is my experience from my limited contact with the JVM, and this is what people who use scala tell me. If you're going to contradict a widely-held belief then you need to provide some justification! Try googling "jvm slow startup".

Re: Closh – Bash-like shell based on Clojure

#130
post #102

Earlier quoted context omitted.

Exactly what yoavm said. The pipelining that shell languages do allows for more complex and more arbitrary data transformations. I feel that doing this in Python would be difficult, but I'm not very familiar with it. In scheme you can do something like this: (define (pipe . exprs) (if (null? (cdr exprs)) (car exprs) (apply pipe (cons ((cadr expr) (car expr)) (cddr expr))))) (pipe '(3 4 5) (lambda (x) (map 1+ x))) ;;…

Wrote something similar in Python, even called it the same! def pipe(init_val, *funcs): """Apply `init_val` to the composition of `funcs` pipe(init, func1, func2, ..., funcn) -> funcn(...(func2(func1(init_val)))) """ return functools.reduce(lambda val, func: func(val), funcs, init_val) Check out clojure's threading macros[1] which extends that to taking forms, where the current value is spliced in as the first or las…

>threading macros

Wow that's pretty awesome. I'd been annoyed with needing to use lambdas for this type of thing. I especially like the as-> macro.

I need to take the time to explore Scheme macros to see what other useful abstractions they can provide.

Post reply on HN