Live data from Hacker News

Closh – Bash-like shell based on Clojure

github.com

131–138 of 138 posts

Re: Closh – Bash-like shell based on Clojure

#131
post #66

Earlier quoted context omitted.

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

First of all, there are AOT native compilers for Java, making as fast to start as any other native compiled language.

Second, it is a well known fact in the Clojure community since several years, that the blame lies in Clojure itself.

http://blog.ndk.io/jvm-slow-startup.html

https://dev.clojure.org/display/design/Improving+Clojure+Sta...

Re: Closh – Bash-like shell based on Clojure

#132
post #66

Earlier quoted context omitted.

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

> Try googling "jvm slow startup".

Its slow because a bare bones hello world takes 40ms in Java instead of 1ms in C. Its "slow" relative to other languages, but its not really that slow over all. I can use mvn without noticing that its slow, but leiningen takes multiple seconds to run a command.

Take a look at this image, taken from the link pjmlp posted: http://blog.ndk.io/img/jvm_vs_clojure.svg

Note that the Clojure team are working on improving this, but it will never be as fast as pure Java and certainly never as fast as other languages (including cljs on node)

Re: Closh – Bash-like shell based on Clojure

#133

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.

Ok, half a million. Similar order of magnitude ...

Re: Closh – Bash-like shell based on Clojure

#134

One of the tricky things about shells is the interaction between fork and pthreads. For example, if you fork while another thread holds a lock, you risk deadlock. node uses pthreads for certain asynchronous operations like stat(). How does Closh handle forking when there are multiple threads?

JS is single-threaded by design and node encourages use of asynchronous operations and then runs callbacks on the event loop. Node provides higher-level non-blocking function spawn, so closh currently does not need to do forking directly. I hope this can get us far before the need to drop into lower level and start dealing with threads.

I am curious, what does fish use threads for and how does it handle them?

Re: Closh – Bash-like shell based on Clojure

#135
post #29

Nice, I've been waiting for a good modern shell to replace ZSH. Fish just wasn't enough of an improvement for me to abandon ZSH. This is an area where most open-source developers have avoided, as it's a "solved" problem, but it really isn't. I'm currently waiting on Elvish [1] to mature. It's written in Go [2], but they're developing a new language on top of it for shell scripting, which I tried for a week. It's a ni…

Sounds like what you want is more along the lines of the Ion shell[1], rather than Elvish. It's written in Rust, and the performance well exceeds Dash (written in C), despite having a lot of features that Dash is unable to do efficiently. Go's just not a good a language for writing a shell, especially once you get into job control and signal handling, or if you care about performance.

Some of the great features you won't find in Bash or Zsh are the string and array methods[2], first class arrays[3], slicing syntax[4], tuple assignments[5], optionally type-checked assignments[6], ability to use functions within pipelines, typed function parameters, a much simpler syntax, and more. Many of the best ideas from Fish, Oil, Elvish, Bash, Zsh and other shells have been implemented or are in the process of being implemented.

- [1] https://github.com/redox-os/ion/

- [2] https://doc.redox-os.org/ion-manual/ch05-05-method.html

- [3] https://doc.redox-os.org/ion-manual/ch04-02-arrays.html

- [4] https://doc.redox-os.org/ion-manual/ch06-00-slicing.html

- [5] https://doc.redox-os.org/ion-manual/ch04-00-variables.html#M...

- [6] https://doc.redox-os.org/ion-manual/ch04-00-variables.html#T...

Re: Closh – Bash-like shell based on Clojure

#136
post #16

Earlier quoted context omitted.

Steady-state performance tends to be better on the JVM but startup performance is always much better on top of JavaScript. That makes it an enticing trade off for shells which is a process that you start new ones of constantly and where the performance of the shell itself is often not very important. (Performance-critical or hard-to-duplicate code like, say, line editing code, can be done equally well on either platf…

Why not just make a server that starts up once in the background and then a lightweight c frontend to the server that essentially just pipes every keystroke to the server?

Shells are supposed to inherit a ton of state from their parent — [e]uid, groups, working dir, env vars, nice, umask, chroot, ... This takes zero effort in unix, but would all have to be (securely!) re-implemented to be able to send code to a shared execution daemon...

And I expect the right implementation for many of these params will be running separate daemons anyway (eg. you clearly want one per user).

Re: Closh – Bash-like shell based on Clojure

#137

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…

Is this satire?

And yours must be one of those funny stereotypical HN jerk comments right?

Re: Closh – Bash-like shell based on Clojure

#138
post #74
post #53

Earlier quoted context omitted.

Scsh runs in a modified scheme48 repl - no problems with interactive use, though I've not run it as an actual login shell, though perportedly that works

I mean more that it's not ergonomic for interactive use. Typing: (run/string (| (ps aux) (grep foo) (grep -v grep)) is quite a bit more of a pain than: ps aux | grep foo | grep -v grep Or at least I think so. It's really meant for providing a nice Lispy interface to POSIX, and at that I believe it succeeds.

Ah sure. But for those cases you can always drop to a normal session with:

   (run sh)
again.. haven't ever used as login shell though :)
Post reply on HN