3 ms·
Anyone find any clever ideas, designs, idioms in the code yet? I'm not interested in starting a reddit clone, but am interested in reading interesting code. T
by jimbokun 18y ago
Anyone find any clever ideas, designs, idioms in the code yet?
I'm not interested in starting a reddit clone, but am interested in reading interesting code. The one file I glanced through was readable, straightforward, and concise, the hallmarks of good Python style. That's a very good thing, but I'm wondering if they've done anything especially clever, or implemented anything generally applicable beyond the realm of discussion sites.
Not that they should. Clear, concise, readable, simple code that builds on existing, open code wherever possible is a wonderful recipe for success. But I'm still interested in whether they went beyond that anywhere.
- mrkurt 18y agoThey actually use PostgreSQL's user defined functions, which is kind of cool.
- asnyder 18y agoHow is that cool? That should be standard with PostgreSQL. User defined functions lend themselves to be used, and are far easier to do in PostgreSQL than other databases. It's shocking that using functions/stored procedures is an anomoly, it should be standard. It is in all our projects.
- y0ghur7_xxx 18y agoUsually I avoid using SPs so I can be database independent. If you need to switch database and don't have SPs you don't have to rewrite all that logic. Another reason not to use them is that the DB is difficult to scale. You can avoid using valuable CPU time for SPs on the DB server if those functions can be executed on the application or middle tier layer (that one scales well) as well. But when I don't have scaling problems, or don't plan to change DB I use them as well.
- mrkurt 18y agoIt's cool in the sense that most people don't do it. :) At least, most people who release open source stuff.
- cousin_it 18y agoSkimming the code now. Looks clean and DRY, maybe a bit define-happy. Definitely better than I'd have written it.
- gms 18y agoDon't be so quick to make that judgment regarding your code - they had a lot of opportunities to iterate.
- schtog 18y agoIt was writeen in LISP first so a lot of defs make sense if just porting the code. What's wrong with a lot of defs anyway?
- cousin_it 18y agoNothing wrong, it's a matter of taste. To me there are two kinds of code: "worker code" that does actual work, and "managerial code" that passes the buck. Lots of managerial code, deep call stacks, short extracted methods that are used only once etc. are heavy smells to me. Not saying this is the case with the reddit codebase!
- jrockway 18y agoTheir form validation is nice: @validate(over18 = nop('over18'), uh = nop('uh'), dest = nop('dest'))