Evan Martin (evan) wrote in evan_tech,
Evan Martin


I got all confused with that last post. What I was trying to say was:
  1. Human languages pretty much all do the noun-verb thing, and variation in structure is relatively minimal. Programming languages have a pretty small problem domain, but approach it a wide variety of ways.
  2. Human languages have a large lexicon, and programming languages usually don't. The neat thing about Haskell's lexicon is that there's so much abstraction that stuff connects together in all sorts of neat ways, so mastery of the lexicon allows truly succinct expressions of solutions much in the way a large vocabulary allows for shorter sentences. I spotted cool tricks like these while I was reading through the prelude:
    reverse          =  foldl (flip (:)) []
    (That colon is the cons operator, and "flip" takes a function of two arguments and produces the same function with its arguments in the other order.)
    any p            =  or . map p
    all p            =  and . map p
    (all predicate list evaluates to True if the predicate function is true for the whole list. The period is the function composition operator.)</i>

Speaking of language hacks: functional languages often have a problem with reading from files, because the "read" function typically either reads into a buffer, or returns a different string on each call. Haskell's answer?
readFile   :: FilePath -> IO String
It returns a list of chars that is the entire file. A waste of memory? No, because evaluation is lazy: bytes are only read from the file as other parts of the program evaluate those parts of the list.
Unfortunately, it's probably still inefficient because it reads a byte at a time from the file. But it's still neat.

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment