Arc Forumnew | comments | leaders | submitlogin
Nested comment system
6 points by subless 215 days ago | 2 comments
I'm not an Arc,Lisp,Racket, etc. programmer so please forgive me. Looking over the documentation of Arc just confuses me more. I tried looking over the documentation to learn how the nested comment system works or at least is designed.

I love Hacker News and love its minimal and simplistic look. I am interested in creating my own community for topics outside of STEM subjects but no matter how many times I try or read online tutorials on nested-comment design's I cannot get anything close to working.

Could someone explain how I would design such a nested comment system if I was 5 years old? I mostly get hung-up on the nested part cause I cannot understand how to design the database for that type of system.



3 points by krapp 204 days ago | link

Nested comment systems tend to use one of two patterns - both of which assume you're using a relational database. Arc forums doesn't, which IMO greatly reduces flexibility in exchange for Lisp purity.

The most common pattern is the "adjacency list" model[0]. Every entry has an ID and parent ID, at least. You can also include an "origin" ID for the root of the tree. For this, you need to build an entire thread with recursive queries (for each ID, get children of ID, etc.) HN and other Arc based forum use this.

Slightly more involved is the "nested set" model[1] which actually maintains a balanced tree. It's easier to query an entire tree than with the adjacency list, but insertions and deletions are more costly.

[0] https://en.wikipedia.org/wiki/Adjacency_list

[1] https://en.wikipedia.org/wiki/Nested_set_model

-----

2 points by zck 211 days ago | link

Have you looked at the code for HN? You could look at display-comment-tree and display-subcomments (https://github.com/arclanguage/anarki/blob/master/apps/news/...).

Basically, each comment has a list of its child comments. Then, when you're going to print out a tree, you recursively also print out child comments.

-----