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.
Closh – Bash-like shell based on Clojure
121–130 of 138 posts
Re: Closh – Bash-like shell based on Clojure
#122Earlier 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))) ;;…
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.Re: Closh – Bash-like shell based on Clojure
#123Earlier 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.
Re: Closh – Bash-like shell based on Clojure
#124Earlier quoted context omitted.
Ideally, we want a Symbolics Clojure Machine.
I suspect that a hardware JVM implementation would get you halfway there.
As alternative, if one is feeling bored, why not create an FPGA for it? :)
Re: Closh – Bash-like shell based on Clojure
#125> 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.
Which kind of makes Windows, with VS, .NET and Powershell, the closest to those environments.
Re: Closh – Bash-like shell based on Clojure
#126Earlier 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
Re: Closh – Bash-like shell based on Clojure
#127Earlier 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.
(as-> value
(function1 arg1 )
(function arg2)
(function arg1 arg2 ))Re: Closh – Bash-like shell based on Clojure
#128Earlier 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 ))
Re: Closh – Bash-like shell based on Clojure
#129Earlier 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.
Re: Closh – Bash-like shell based on Clojure
#130Earlier 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…
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.