Arc Forumnew | comments | leaders | submitlogin
Can anyone give me a really brief tour of the Arc language?
5 points by sktrdie 4881 days ago | 2 comments
I read the tutorial page and I understand the language pretty well. Now I'm a bit more concerned in understanding how I can make web apps with. For example, even after reading the source code of this very web app (https://github.com/nex3/arc/blob/master/news.arc) I still couldn't figure out how it was working.

-How are requests being handled?

-Where is the database, how are entries being stored?

-Is the HTML really mixed with code-logic?

-How does HN (Hacker News) handle the huge load and promptly behave as expected, even though Arc wasn't designed for speed?

Thanks!



5 points by thaddeus 4881 days ago | link

  > Where is the database, how are entries being stored?
  > How does HN (Hacker News) handle the huge load and   
  promptly behave as expected, even though Arc wasn't   
  designed for speed?
All HN data is stored in text files and 90% of HN requested records (i.e. posts and comments) are held in memory for adequate performance. Also note that because 90% users only care about the top few pages of news, HN can get away with it. The remaining older items only get loaded into memory upon request, which isn't often, and they get dropped from memory over time.

Note that HN doesn't allow you modify records after a certain time frame and this gives HN the luxury to not support writes to older content and gives the users less incentive to go back to older items, lessening the need to access older data.

I believe the majority of applications many of us would need to write do not fit well into the HN model. So you'll likely discover arc has limitations given it was designed, largely, around HN.

-----

5 points by akkartik 4881 days ago | link

There is no database. news.arc stores its data in files under newsdir:

http://github.com/nex3/arc/blob/76a61293bc/news.arc#L73

Stories and comments are templates (http://files.arcfn.com/doc/template.html) and each of them is stored in a separate file:

http://github.com/nex3/arc/blob/76a61293bc/news.arc#L166

html is indeed codegenerated. See display-items, newpoll-page, etc.

pg has said in a few places that as load has grown, HN has cached commonly-requested data just enough to keep performance mediocre. Arc helps flexibly-yet-declaratively specify what to cache and when to evict it. Look at instances of defcache, then at its implementation. There's probably other sorts of caching; this code is several years old and we don't know how it's been changed as HN has grown.

"How are requests being handled?"

I don't know enough about what you know to answer usefully. Are you aware of defop?

http://github.com/nex3/arc/blob/76a61293bc/srv.arc#L196

It registers functions to handle different kinds of urls:

http://github.com/nex3/arc/blob/76a61293bc/srv.arc#L234

-----