Fork me on GitHub

With all of the system management discussion recently, I’ve noticed that some people tend to componentize just the most low-level “effects” (eg database connection pool, in-memory cache) while others make components for higher-level subsystems that themselves use lower-level effects. I haven’t seen a lot of discussion or recommendations online or from the tools themselves on this topic, so question for the room: how do you architect your components?


it's components all the way down 🌀 nothing much to add myself, I've used Component to model modules in a modular app (Polylith style), or "repositories" as in data stores, etc. I guess there's no universal answer as there are many ways of an architecting an app.


I maintain a fairly large (~50kloc) web app/SPA in Clojure/Script. Initially I used Component but just for stateful things: web server, DB connection pool, and a handful of thread pools, but I recently decided that Component really wasn’t helpful for such a small number of components. Now I just have functions to start/stop the app by starting those components and passing the dependencies explicitly. For example, the thread pools usually need the DB connection pool, so I start the DB pool first, then pass it to each thread pool as I start it.


I created some Ring middleware to inject all the components into the request map so that web endpoint handlers can pull in whatever they need (typically just the DB pool).


Silly question but why do folks often throw a $ in front of their terminal instructions? like $ curl ... prevents me from doing a quick copy/paste of the instruction line. I figure I'm missing something here


I'm tempted to throw an alias in of alias $=' ' but I imagine that has some unforeseen consequences


$ signifies the prompt, mostly to distinguish user input from a program output.

✔️ 2

Compare e.g.

$ echo yes
echo yes
Run the latter to have the terminal keep agreeing with anything you say. :)


Also, $ often means "unprivileged user" and # means root.


hadn't realized that convention. neat. thanks


Ooh, now that is a good reason there. I can get behind that

Ben Sless20:08:19

At least when the prompt is # you can always safely copy-paste the prompt, but there's historical circumstance to consider. in csh it's %


I've had several folks request that I remove the $ from documentation and just separate commands from output more clearly. I believe there is also a CSS trick you can do to display $ on the web but make it not part of the string you actually copy'n'paste.


Similarly, I've had folks request that long lines not be broken up with \ because that only works on macOS/Linux and produces "bizarre" behavior/errors on Windows.


> I believe there is also a CSS trick you can do to display `$ ` on the web but make it not part of the string you actually copy'n'paste. The ::before pseudo-element can do that:

.terminal-command-input-line::before {
  content: "$ ";


I don't think making it easy to do quick copy paste from a document into a terminal is actually a good thing. you should be putting more effort into reading the thing you are copying than it takes to avoid grabbing the $


Sure. You can tell that to beginners all you like but it won't stop them doing it 🙂

👍 3

I'm just suggesting it's a "good friction"

👏 2

Yes! What @U051SS2EU said. Copy and pasting into a terminal is a bad habit, similar to curl ... | sudo bash.


> ... just separate commands from output more clearly. This is a lot harder when you're documenting a back-and-forth command/response "conversation".


2 reasons I can think of: the first and major reason is to tell the user what command is being run vs. output the second is much lesser and a bit more patronizing but I've heard people say that generally we should not be copying + pasting random snippets into our shell :<


I get that to a sense. I try to do that when following a coding tutorial or what not. But something like this $ curl -LO`` and it even has a literal copy to the clipboard button next to it. I don't like it! haha


i think github has made the copy not include the $ prompt right?


I still get the prompt from github. Nbd of course, I was just curious of the historical reasons


I think, the reason is to differentiate between a normal user, i.e., "$" and a root user "#". Of course, nowadays, the actual prompt is rewritten/redisplayed by some useful plugins, like powerline etc.., but on a naked shell, it really helps.


(and, # is also treated as a comment character, so if you're copying commands with abandon, it can really save your bacon, i.e, # rm -rf / 🙂 )


It's detailed on the POSIX guidelines too:


    This variable is used for interactive prompts. Historically, the "superuser" has had a prompt of '#'. Since privileges are not required to be monolithic, it is difficult to define which privileges should cause the alternate prompt. However, a sufficiently powerful user should be reminded of that power by having an alternate prompt.

Antonio Bibiano15:08:08

It works well in zsh, I decided to try it and in bash I went for :; to get the same functionality

Antonio Bibiano15:08:01

I discovered that : works like a no-op in bash


I've seen clojure repls that print a prompt like #_=> for similar reasons


maybe cider does that for multiline input?


Anyone tried with Clojure? Seems like it could still be useful, auto-announce, auto-git-tag, auto-update homebrew, etc.