News for hackers. Stuff that matters.
Re:A Slack clone in 5 lines of bash by spicybright on Wednesday July 05, 2023 @12:14AM (#36595452)
In case you're passing over this because it sounds like click bait (it KIND OF is), this was actually a good read to me.

It goes over a utility called "suc" (Simple Unix Chat) that implements server functionalities from Slack, Discord, etc. using a very small codebase.

The novel part is it leverages existing unix tools and methodology instead of re-inventing them.

- Auth is handled by SSH.

- Channels are just a file and admin/mod controls are handled by user groups and file permissions.

- Support for rich text, file uploads, etc. aren't a concern as you just write whatever data you want to the channels and let the client interpret it.

- Bots are very easy as you just pipe to/from the channel files.

You're not going to be making a perfect slack clone with the 5 lines that write messages to the channels from the article, but I'm pretty impressed how far you can with really simple unix tools.

Re:A Slack clone in 5 lines of bash by cornel_io on Wednesday July 05, 2023 @12:45AM (#36595604)
Slack to most end users is the client, though. As well as the admin, user management UI, scalability, webhooks, etc, absolutely none of which is handled by "you can chat with other users in Linux if you all log into the box" which every *nix has had since before most readers here were born.
Re:A Slack clone in 5 lines of bash by linschn on Wednesday July 05, 2023 @04:07AM (#36597243)
Indeed ! The question is whether all that is worth so many engineer-hours. I'm not advocating for all Slack channels to be replaced by suc, that would be silly. I'm just pointing out how costly it all is. There's got to be a middle ground that does not require hundreds of thousands of lines of code.
Re:A Slack clone in 5 lines of bash by dclowd9901 on Wednesday July 05, 2023 @01:12AM (#36595748)
Big emphasis on “kind of”.

“Here’s how to make $2 million dollars over night”

_reads article_: “have $4 million in the bank…”

Re:A Slack clone in 5 lines of bash by cassepipe on Wednesday July 05, 2023 @05:34AM (#36597939)
I laughed reading your comparison but I don't agree. I clicked waiting for a shallow trick and found that there was indeed a trick, but not a shallow one at all This ability to bring complex capabilities to a chat system by leveraging so much of its ecosystem is truly amazing. Definitely worth the hn front page. And you only need basic shell literacy in order to use it, little more to understand it
Re:A Slack clone in 5 lines of bash by BenLloydPearson on Wednesday July 05, 2023 @09:11AM (#36599946)
I came for the pithy title, I stayed for the unique, yet simple, approach the author took and how they explained the examples.
Re:A Slack clone in 5 lines of bash by lynx23 on Wednesday July 05, 2023 @02:20AM (#36596180)
Wait, KISS is a novelty? :-)
Re:A Slack clone in 5 lines of bash by TeMPOraL on Wednesday July 05, 2023 @03:50AM (#36597094)
Novelty? More like the ways of our great grandparents.
Re:A Slack clone in 5 lines of bash by nonethewiser on Wednesday July 05, 2023 @06:48AM (#36598489)
> The novel part is it leverages existing unix tools and methodology instead of re-inventing them.

That pretty much always explains the “X in unfathomably few lines of code.” No faulting the other, he was very upfront about this.

Re:A Slack clone in 5 lines of bash by dexen on Wednesday July 05, 2023 @07:24AM (#36598766)
"Append-only files" would be a great fit here: to ensure regular users and bots don't modify others' posts. Sadly this Plan 9 functionality is not ported to Linux yet. That's a permission bit, similar to "read" or "write", but even more specific.
Re:A Slack clone in 5 lines of bash by ComodoHacker on Wednesday July 05, 2023 @07:55AM (#36599093)
Not so great if you're talking about real use cases where moderation is mandatory.
Re:A Slack clone in 5 lines of bash by Pannoniae on Wednesday July 05, 2023 @09:12AM (#36599961)
Moderation is never mandatory, it's just something most people desire.
Re:A Slack clone in 5 lines of bash by linschn on Wednesday July 05, 2023 @11:09AM (#36601490)
The host owner (there's no root on Plan 9) can change those permissions and edit the file if need be.
Re:A Slack clone in 5 lines of bash by HerrMonnezza on Wednesday July 05, 2023 @01:08PM (#36603454)
IIRC, Linux' ext2/3/4 support an 'a' attribute that make a file append-only.
Re:A Slack clone in 5 lines of bash by throw10920 on Tuesday July 18, 2023 @11:18PM (#36781730)
> re-inventing them

Existing chat platforms don't "re-invent" Unix tools - they're simply not suitable for building on top of. There's a reason that approximately 0 large production systems are written in shell script using the "everything is a file" paradigm - because it's not acceptable for any non-trivial system that needs to see real-world use.