Day 2: Monads! and other things
Oct. 7th, 2014 09:21 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
First, a follow-up on yesterday's lulz with the eBird data: I lied a bit when I said it was a tar file that was being troublesome; the initial download was a tar file, which decompressed to a few README-ish files and a gz file, but the actual trouble came about when I tried to decompress the gz file—which contains the actual data, and was causing the trouble.
I decided to see what gzip thought the size of the file should be when uncompressed, and, uh...
Apparently gzip thinks my massive text file should be smaller once it's uncompressed??? (And definitely not >60GB like it tried to do?)
Anyway, today I did a lot of little things (read a chapter in Introduction to Algorithms because someone had a really cool question about one of the problems therein, cleaned up some documentation for an OSS library, poked around the Amazon Mechanical Turk API, worked more on the Matasano crypto challenges...), none of which were super long/involved enough to make a full blog entry... there's so many exciting things going on here that it's hard to focus on just one thing! Which is a good problem to have, but still a problem, haha.
But I can talk about the really cool discussion-y thing me and a few other hackerfolk had with Crista Lopes! She's this week's resident, and last night, during her talk about programming style, she mentioned that monads made a lot more sense to her once she started thinking of them as objects, which caught my interest.
Now: it's been a few years since I wrote much code in a pure functional language, so while I generally know what's going on with them, I stopped juuuust short of monads when I was working through Learn You a Haskell, and the few blog entries I've read that try to explain monads never seemed very clear to me. And I certainly never heard the term "object" mentioned in any of them.
Several other folks' interest seemed to be piqued as well, so we got together and checked out Crista's implementations of a few different monads in Python. I'd rather not attempt to add to the slew of "what are monads?" blog posts on the internet, since I only felt like I started to "get" them during that discussion, but! I think what was really cool was the way she thought of the problem in both utilitarian and historic terms.
By utilitarian, I mean: "What made language designers think of this problem?" For instance: monads are a big deal in Haskell because the language is very committed to its purely functional approach, which should mean "no side effects!" But, since you must have side effects to do things like file I/O and networking and the like, you have to figure out a "pure" way to handle that—and thus, monads seem like a good way to at least isolate those side effects.
And history helps too! Crista mentioned that one of the first papers to describe monads for programming languags was "How to Declare an Imperative" by Wadler. I haven't read the paper (yet!), but just the title hints at what monads are trying to accomplish, and she said reading it reinforced the idea of monads being object-like.
Now I just need to remember these next time I'm trying to explain something new to someone :)
I decided to see what gzip thought the size of the file should be when uncompressed, and, uh...
dhcp-0059526637-5b-99:ebd_relAug-2014 flowerhack$ gzip -l ebd_relAug-2014.txt.gz compressed uncompressed ratio uncompressed_name 7232458369 2856865220 -153.2% ebd_relAug-2014.txt
Apparently gzip thinks my massive text file should be smaller once it's uncompressed??? (And definitely not >60GB like it tried to do?)
Anyway, today I did a lot of little things (read a chapter in Introduction to Algorithms because someone had a really cool question about one of the problems therein, cleaned up some documentation for an OSS library, poked around the Amazon Mechanical Turk API, worked more on the Matasano crypto challenges...), none of which were super long/involved enough to make a full blog entry... there's so many exciting things going on here that it's hard to focus on just one thing! Which is a good problem to have, but still a problem, haha.
But I can talk about the really cool discussion-y thing me and a few other hackerfolk had with Crista Lopes! She's this week's resident, and last night, during her talk about programming style, she mentioned that monads made a lot more sense to her once she started thinking of them as objects, which caught my interest.
Now: it's been a few years since I wrote much code in a pure functional language, so while I generally know what's going on with them, I stopped juuuust short of monads when I was working through Learn You a Haskell, and the few blog entries I've read that try to explain monads never seemed very clear to me. And I certainly never heard the term "object" mentioned in any of them.
Several other folks' interest seemed to be piqued as well, so we got together and checked out Crista's implementations of a few different monads in Python. I'd rather not attempt to add to the slew of "what are monads?" blog posts on the internet, since I only felt like I started to "get" them during that discussion, but! I think what was really cool was the way she thought of the problem in both utilitarian and historic terms.
By utilitarian, I mean: "What made language designers think of this problem?" For instance: monads are a big deal in Haskell because the language is very committed to its purely functional approach, which should mean "no side effects!" But, since you must have side effects to do things like file I/O and networking and the like, you have to figure out a "pure" way to handle that—and thus, monads seem like a good way to at least isolate those side effects.
And history helps too! Crista mentioned that one of the first papers to describe monads for programming languags was "How to Declare an Imperative" by Wadler. I haven't read the paper (yet!), but just the title hints at what monads are trying to accomplish, and she said reading it reinforced the idea of monads being object-like.
Now I just need to remember these next time I'm trying to explain something new to someone :)