shenfeng / rssminer

An online rss reader written in clojure & javascript & java.
http://rssminer.net
147 stars 24 forks source link

This app as an example. #1

Open t-jones opened 11 years ago

t-jones commented 11 years ago

I'm a clojure novice looking for some good code to read to enhance my own understanding and learn about how web apps apps can be put together in clojure. In your opinion, would this app be a good choice for such an exercise? Thanks for your time.

shenfeng commented 11 years ago

In your opinion, would this app be a good choice for such an exercise

Yes. The APP is about 1600 lines of Clojure code. I write it quite carefully.

Clojure web application is very easy to write, no big framework to learn. You need MySQL and Redis to run the APP.

Start here: https://github.com/shenfeng/rssminer/blob/master/src/rssminer/main.clj

Routing: https://github.com/shenfeng/rssminer/blob/master/src/rssminer/routes.clj

Middleware: https://github.com/shenfeng/rssminer/blob/master/src/rssminer/middleware.clj

The rest are just application specific logic.

You may want to read Ring first: https://github.com/ring-clojure/ring Ring is Clojure's way of abstracting HTTP.

goballooning commented 11 years ago

Maybe we can start a wiki page and introduce it with more technical details. Really hope that more people would notice RssMiner, and make it better.

shenfeng commented 11 years ago

Thanks. It's a good idea. I will try to compile some page about the technical details later.

Currently, I had some trouble with my life, need few days to get back to normal, This is why I rssminer did not get update these days. I will come back in a few days, then, I will work hard, and make rssminer better.

Ranler commented 11 years ago

This is a very awesome app! Come on!

t-jones commented 11 years ago

I've worked through most of the clojure code and learned alot! I even co-oped the config pattern you use for an app I'm writing.

One question I have: how do you decide which portions to write in Java vs clojure? I see the same pattern in http-kit as well.

shenfeng commented 11 years ago

how do you decide which portions to write in Java vs clojure

  1. Clojure is not good at doing IO, I pref buffer style code of doing that (C style).
  2. A lot of detail, need to keep quite a few vars, and need to query/update, Java make it better (OK, C, style)
  3. Work with existing java library.
  4. Clojure is a little bit slower than JAVA. It trend to generate more garbage. Trend to use more map lookup instead of Java's field access.

Anyway, Clojure and Java, when write code together, is a lot of fun: You get performance and excellent API at the same time.