3 ms·
One thing that's really underappreciated in my opinion is the ability to use the REPL as a general tool for interacting with the system. A lot of devops tasks c
by yogthos 4y ago
One thing that's really underappreciated in my opinion is the ability to use the REPL as a general tool for interacting with the system. A lot of devops tasks can be done very conveniently from the REPL.
For example, you can start a Babashka nREPL by running bb --nrepl-server and connect an Clojure editor to it. Then you can do a lot of fun stuff from there. For example, if you have osquery installed, then you can start querying your system for all kinds of stuff, get data back in EDN and manipulate it using standard Clojure functions:
(require '[clojure.java.shell :refer [sh]]
'[cheshire.core :as json])
(defn osquery [query]
(let [{:keys [exit out err]} (sh "osqueryi" "--json" query)]
(if (zero? exit)
(json/decode out true)
(throw (Exception. err)))))
=> (osquery "select * from routes where destination = '::1'")
=> ({:hopcount "0",
:interface "lo0",
:mtu "16384",
:type "local",
:source "",
:gateway "::1",
:netmask "128",
:flags "2098181",
:destination "::1",
:metric "0"})
I find I often just leave a bb nREPL running with Calva connected to it and some scripts to do common system tasks in it.
- tosh 4y agohttps://www.osquery.io/ https://www.osquery.io/ https://github.com/osquery/osquery https://github.com/osquery/osquery
- pjmlp 4y agoThe difference is that each of those are their own little silo, instead of being part of a single language ecosystem.
- pjmlp 4y agoI always mention that a shell is a poor man's REPL, based on REPL based OSes like the ones from Xerox and ETHZ used to offer their OS interaction workflows alongside the development experience. Shells like Powershell and Fish are the closest to it, due to their integration with programming language and OS APIs.
- yogthos 4y agoCompletely agree, having an interactive programming interface to the system is superior to using a shell in practically every way.
- 0x445442 4y agoWhy do you think Powershell and Fish are closer than EMACS Eshell to the REPL based OSes?
- pjmlp 4y agoThey aren't part of a text editor, and integrate with the complete OS. Emacs is a shadow of the REPL experience from using a Lisp Machine.
- agumonkey 4y agoI think the time is right to revamp a basic shell. Something that generalizes pipes to async DAGs. The idea floats in the air between reactive objects graph in a browser or systemd services, docker composer .. It would reseat the base os user interaction to something cleaner and leaner IMO.
- gemstones 4y agoThis is great! For any SWEs that would be more comfortable in a Python REPL, you can do the same thing like this: import subprocess import json def osquery(query): return json.loads(subprocess.check_output(["osqueryi", "--json", query])) #>>> osquery("select * from routes where destination = '::1'") #>>> [{'destination': '::1', 'flags': '2098181', 'gateway': '::1', 'hopcount': '0', 'interface': 'lo0', 'metric': '0', 'mtu': '16384', 'netmask': '128', 'source': '', 'type': 'local'}] I hadn't heard of osquery - thanks for pointing me to that!