13 ms·
Reimplementing “git clone” in Haskell from the bottom up (2013)
- wldlyinaccurate 12y agoAs somebody who has only recently started looking into functional programming, this was absolutely fascinating. Even though I'm not very familiar with Haskell, I find this code much more concise and easy to follow compared to the original git-clone implementation in C. Though perhaps that's more down to the author's coding style?
- hashtree 12y agoAs to your question, I think it is both. The author's ability to walk you through his thought processes in a clear and concise manner, his general strength as a writer, the fact that he added diagrams and models to help the reader, and that this did not seem to be written only for Haskellers to read... well they all add up to what you are describe. Kudos to the author.
- spopejoy 12y agoI'm having an interesting experience with this at my job ... Haskell appears to be MUCH more approachable when you understand the problem at hand. So much Haskell pedagogy wants you to write a compiler or a parser or ... whereas this article is taking you through a solution. And whaddyaknow -- Haskell comes across as gorgeous, elegant, compact, and highly comprehensible. When I show a FIX server or REST API written in Haskell to a non-Haskeller coworker (ie everyone else :) ), with minimal explanation they're getting what's going on. I look forward to many more "Haskell-in-anger" articles to show the world how fantastic it is to work with.
- eru 12y agoYes. Haskellers are just too much in love with compilers and parsers. Those are much easier to write in Haskell, but not enough people have grappled, and suffered (and failed) to write one in eg C to appreciate.
- stefans 12y agoAuthor here. Thanks for the kind comment, happy to see that other people and not just myself got something out of this exercise.
- wyager 12y agoIn my experience, pure functional programming, combined with Haskell's relatively permissive syntax, allows for very natural-language-like and well-structured programs. Languages like Agda can do this even more impressively. You can do stuff like write if_then_else_ : Bool -> a -> a -> a And you can split up the "if", "then", and "else" and put the arguments where the underscores are.
- taeric 12y agoMeh. I think it is arguable that the code from this article is as easy as it is to understand as much from the prose that goes with it as from the language it is written in. My argument would actually lean towards more so.
- Dewie 12y ago> I think it is arguable that the code from this article is as easy as it is to understand as much from the prose that goes with it as from the language it is written in. This was hard to understand.
- taeric 12y agoApologies. I think I should have just written that in multiple sentences. I don't think mere commas can save it. Simply put, my assertion is that it is the accompanying prose and diagrams that truly make the code easy to understand. Not its implementation language. I would love to say that my terrible sentence above illustrates that prose is not a panacea. Well, I think I can claim that. I can not claim it was intentional. :)
- pmoriarty 12y agoFor what it's worth, I found your original statement perfectly clear.
- eru 12y ago> Simply put, my assertion is that it is the accompanying prose and diagrams that truly make the code easy to understand. Not its implementation language. Haskell does help somewhat, in that it's offers you a lot of flexibility in how to structure your program. So you can tailor your program to your explanation. (Knuth's literate programming tools help bring those capabilities and more to more conventional languages.)
- sleepychu 12y agoDon't suppose anyone knows where those nice diagrams are from? (Hoping they're generated from a tool)
- ky3 12y agoYou're correct that they're generated from a tool, and it's diagrammix [1]. [1] http://www.reddit.com/r/programming/comments/1cgi2x/reimplementing_git_clone_in_haskell_from_the/ http://www.reddit.com/r/programming/comments/1cgi2x/reimplem...
- sleepychu 12y agoOSX :-(
- kevin_thibedeau 12y agoIt seems like the graphic shading could be replicated with SVG filter effects inserted as a post-processing stage applied to images output from Dia or Visio.
- maccard 12y agoI quite like gliffy for styled diagrams. Not quite the same effect as the ones in the article, but still very nice. http://www.gliffy.com/ http://www.gliffy.com/
- chriswarbo 12y agoDitaa is quite nice http://ditaa.sourceforge.net http://ditaa.sourceforge.net It uses ASCII-art boxes, lines, etc. as input (which you can draw using Emacs's artist-mode, for example)
- deleted 12y ago[deleted]
- amelius 12y agoInteresting. It would also be a nice exercise to implement all of the internet RFCs, such as an email server, etcetera in Haskell. That's still a bit lacking. And it would be very useful if it existed, IMHO.
- chii 12y agoimplementing a spec using haskell is a great learning exercise.
- tempodox 12y agoImplementing a spec is the only way you can use Haskell sensibly. All other uses are PITA.
- nicolast 12y agoI wrote an NFS server in Haskell, using Literal Haskell to implement all related RFC's 'inside' the RFC documents, interleaving code (lots of serdes stuff...) with the specification.