4 ms·
Ask HN: Particularly elegant programs to study?
Examples help tremendously in learning any abstract subject. What are some famously well-written programs whose source is available to look at?
- nomurrcy 16y agoLua (The programming language) is very well written and well worth reading and understanding. http://www.lua.org/ http://www.lua.org/
- davidsiems 16y agoI have to disagree. The language spec and the docs on the Lua website are well written but the VM itself is a mess. It's a trainwreck of ambiguously named variables, minimal documentation, and overuse of macros to force inline code. The Lua VM is a good example of something that isn't well written from a reading / understanding point of view, but is something that is well written from the 'it works' point of view.
- pygy_ 16y agoHere are the source code reading order recommendations by Mike Pall (the author of LuaJIT). http://www.reddit.com/r/programming/comments/63hth/ask_reddit_which_oss_codebases_out_there_are_so/c02ppb8 http://www.reddit.com/r/programming/comments/63hth/ask_reddi...
- techbio 16y agoI searched for "russian doll pseudocode" hoping to discover something elegant, but the clearest "code" there is a nicely colored Venn-ish diagram. http://ijcai.org/papers09/Papers/IJCAI09-106.pdf http://ijcai.org/papers09/Papers/IJCAI09-106.pdf
- michael_dorfman 16y agoTeX. Or, any of Knuth's other Literate Programs. Also, the book "Beautiful Code" is an attempt along these lines, but personally, I don't find the programs there as beautiful as Knuth's.
- plinkplonk 16y agoCode from Peter Norvig's "Paradigms of Artificial Intelligence Programming"
- d4rt 16y agosqlite is both beautiful and has a significant test suite. http://www.sqlite.org/ http://www.sqlite.org/
- jamii 16y agoThe sqlite test suite is a fantastic example of how to produce solid software. I wish it were used as a case study for all software engineering courses.
- petercooper 16y agoThis is very Ruby specific (so mostly not "famous" stuff) but if that's your scene, I asked the same question to Rubyists recently and got some good suggestions: http://www.rubyflow.com/items/1817 http://www.rubyflow.com/items/1817
- jamii 16y agoI don't know about famous, but Conal Elliots ideas about denotational semantics have led to some beautifully elegant libraries - http://conal.net/blog/posts/denotational-design-with-type-class-morphisms/ http://conal.net/blog/posts/denotational-design-with-type-cl... Don't be put off by the academic tone, at its heart the paper is about how to design abstractions.
- sz 16y agoThis looks awesome, thanks. How to design abstractions was what I had in mind when posing the question.
- jamii 16y agoI really enjoy reading Conals work. This paper is a particularly good example of how denotational semantics can guide the design of a library - http://conal.net/blog/posts/paper-beautiful-differentiation/ http://conal.net/blog/posts/paper-beautiful-differentiation/
- abyssknight 16y agoc99shell. No, really, it's very well written.
- jashmenn 16y agoLéon Bottou's implementation of Stochastic Gradient SVMs is the most concise implementation of an SVM that you'll find: http://leon.bottou.org/projects/sgd http://leon.bottou.org/projects/sgd
- sz 16y ago(since I had to look it up what a SVM was) "Support vector machines (SVMs) are a set of related supervised learning methods... The standard SVM takes a set of input data, and predicts, for each given input, which of two possible classes the input is a member of... Intuitively, an SVM model is a representation of the examples as points in space, mapped so that the examples of the separate categories are divided by a clear gap that is as wide as possible. New examples are then mapped into that same space and predicted to belong to a category based on which side of the gap they fall on." [wikipedia]
- doublez 16y agoThe Lift framework core has some rather lithe Scala in it. Do mind that it's an actively developed, actively deployed framework - functionality sometimes takes priority ... ;)
- doublez 16y agohttps://github.com/lift/lift https://github.com/lift/lift
- dkurth 16y agoHere's Peter Norvig's toy spelling corrector (in Python), along with some helpful explanation: http://norvig.com/spell-correct.html http://norvig.com/spell-correct.html
- pierrefar 16y agoI've heard good things about the code of Redis and Tokyo Tyrant.
- variety 16y agoThe djb way: "straight, no chaser": http://cr.yp.to/ qmail in particular, and also (if you like math) primegen. BTW, his code is not easy to understand (quite the opposite) -- there are few source comments, and most of these are snarky, cryptic or both; and not only does he explain almost nothing on a global scale but oftentimes what he is doing might look, at first blush, kinda wrong, obtuse even. But that's precisely the point -- there are a lot of idioms in there that most C programmers just wouldn't think of, especially if you're into minimalism (when it comes to things like dealing with strings, error handling, forking, etc).
- kazuya 16y ago> and not only does he explain almost nothing on a global scale but oftentimes what he is doing might look, at first blush, kinda wrong, obtuse even. Can you give some examples?
- dawsdesign 16y agoI've heard that Postfix is as close to perfect you can get, but I haven't dived in personally.
- jbarham 16y agohttp://code.google.com/p/go/source/browse/ http://code.google.com/p/go/source/browse/ is the source for the Go compilers and standard library. Very clean, clear code in the Bell Labs tradition.
- srean 16y agoI am surprised that nobody has pointed to http://news.usethesource.com/ http://news.usethesource.com/ yet.
- deleted 16y ago[deleted]