## More Coursera courses

In the recent months I participated in more online courses on Coursera. Once again it’s time to share some impressions. If you care only about functional programming I suggest you skip directly to Programming Languages section of this post, but I highly encourage to read reviews of two other courses as well.

# Think Again: How to Reason and Argue

Some time ago I?ve been quite interested in proper ways of arguing and in spotting logical errors in argumentations. Needles to say when this course was announced I enrolled without hesitation. It looks that this subject draws a lot of interest since this was in fact one of the most popular Coursera courses to date. The course lasted 12 weeks, which in my opinion is very long for an online course ? even Compilers took only 10 weeks. The course wasn?t very time-demanding, taking about 2-3 hours a week to watch the lectures and possibly another hour to complete the homework. I didn?t get the textbook so I did no additional reading but I guess this would take another 3-4 hours a week.

The course was divided into 4 units. Unit 1 was about analysing arguments: identifying premises and conclusions, separating relevant argumentation from verbiage, distinguishing between valid and invalid arguments, rephrasing the arguments and so on. I’m good at pure sciences and not really good at humanities so this unit was a bit hard for me. Still it was interesting. Unit 2 made a turn towards propositional and categorical logic. This on the other hand was easy for me, but I felt this was only dry theory and there was no demonstration how to apply it in analysing or giving arguments. Unit 3 covered inductive arguments, causal reasoning and probabilities. Once again the material was easy for me and interesting, but it wasn’t placed in a larger context and few applications were demonstrated. Finally Unit 4 focused on logical fallacies and refuting arguments, which are the topics I’ve been waiting for the most. The presentation of material was very good and I had the feeling I understand all of it, but when it came to tests it turned out that I actually have problems with applying in practice what I have learned. This was a bit frustrating. Oh well, I guess I wasn’t born for the humanities.

Think Again was the most fun online course I have participated in so far. This is mostly thanks to the great lecturers Walter Sinnott-Armstrong and Ram Neta, who put a lot of work and energy into lectures to make them both interesting (even entertaining) and informative. I think few things could be improved in this course. When it is redone in late August (that?s the current plan) I highly recommend it to anyone

# Heterogeneous Parallel Programming

The subject of Heterogenous Parallel Programming was parallel programming in CUDA. This is a subject I got interested in recently so I decided to participate. While Think Again was one of the best online courses I took, this one is by far the worst. It’s hard for me to explain how big disappointment this course turned out to be, though perhaps I shouldn’t be so harsh on it because I decided to quit during the third week.

So is there anything good to be said about HPP? Luckily, yes. Professor Wen-mei Hwu was very responsive and replied to many objections people have raised in the discussion forums. As you see from the above review I am not convinced by these explanations, still it’s a big plus that he took part in the discussion. I don’t know how this course has ended. I guess that you can learn CUDA from it if you really want but judging by the first weeks of the course it’s better to just grab some online tutorials.

# Programming Languages

Programming Languages is a currently ongoing course that covers different aspects and features known from various programming languages. The topics include recursion, scoping, higher-order functions, pattern matching, algebraic data types, parametric polymorphism, currying, type inference, laziness, memoization, macros, inheritance, mixins and many more. As you may have noticed most of these features are typical to functional languages and indeed the courses focuses on functional approach to programming. Languages used in the course are SML, Racket and Ruby, though the course is not about these languages per se – they are only used to demonstrate various features a programming language can have.

The course is very demanding. During 10 weeks there will be eight sections of the material. Each section has usually over 3 hours of lectures. It takes about 4-5 hours to watch them due to the breaks you will likely take between the lectures as well as the time needed to test on your own the demonstrated code. Homework is also time-consuming. It took me about 3,5 hours to complete the first assignment and 2 hours to do the peer review of other participants’ solutions (that’s part of the grading). I think this is quite a lot given my background in functional programming. Others have reported times of up to 12 hours and I know many people have given up on the course because of the difficulty. I myself have given up not because of the difficulty itself but simply due to the lack of time. Sure, learning more about SML and Racket would be fine but I’d rather spend those 8-12 hours a week working on Haskell. I still watch some of the lectures that cover topics that interest me.

While I think that making the course material challenging as it is now is a good thing I don’t like the strict policies about deadlines. There are about 9-10 days for each assignment and the hard deadline comes only two days after the soft one. Given that the lectures are released in the middle of the week, people working full-time will have to put a lot of work to successfully complete this course. That’s a pity, because the course is awesome and relaxing the deadlines would make it accessible to a wider audience without lowering the quality of material. Still this is a highly recommended course.

## Don’t panic! It’s only an upgrade

Time for another upgrade of my GHC installation. OK, I know I already posted about this twice but yet again the process was different from the previous ones.

My first attempts of installing GHC and the Haskell Platform a year ago relied on using packages from my distribution’s repository. This quickly turned out to be problematic so I decided for a direct installation of the Haskell Platform. This worked perfectly fine except for the fact that Haskell packages were installed in different subdirectories of /usr/local, which lead to a bit of a mess and problems with controlling what is installed where (this is useful if you want to remove a package). So the second time I was installing Haskell Platform I was smarter and refined the whole process. This time I confined the installation to a single directory so that both GHC and all the packages are located in a single, easy to find place.

Yesterday I figured out it would be great to get a new version of GHC. GHC 7.6.1 was released on 6th September 2012 and the updated 7.6.2 version is only two weeks old. While GHC 7.6.1 has been out for over 5 months it is still not part of the Haskell Platform and it won’t be for the next three months. That’s too long a wait for me so I decided to send the Platform to /dev/null and just install GHC and its environment from scratch.

My plan to install GHC from precompiled binaries went up the spout:

This build requires libgmp.so.3.

Watwatwat? Now what is that supposed to mean? Previously released binaries didn’t depend on one particular version of libgmp library. Of course my system has libgmp.so.10 and any attempt to install an older version results in breaking package dependencies. I downloaded binaries anyway and tried to run them:

[killy@xerxes : ~/ghc-7.6.2/ghc/stage2/build/tmp] ./ghc-stage2 --interactive ./ghc-stage2: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory

OK, so that requirement is true – you need the exact version of libgmp. So what now? I know! Compilation from sources! I’ve been hacking on GHC recently so I already have sources on my drive. Unfortunately it turned out that after switching GHC repo and all its subrepos to ghc-7.6 branch I get some compilation errors. I wasn’t in the mood for debugging this so I switched everything back to master and downloaded the source snapshot. From now on things are easy, assuming that you already have an older version of GHC on your system. After extracting the sources I copied $(TOP)/mk/build.mk.sample to $(TOP)/mk/build.mk (\$(TOP) refers to directory containing GHC sources) and uncommented the line BuildFlavour = perf-llvm. This gives me fully optimized build using LLVM. Now the compilation:

perl boot ./configure --prefix=/usr/local/ghc-7.6.2 make

This will build GHC and prepare it for installation in /usr/local/ghc-7.6.2. Fully optimized build takes much over an hour on all 4 cores. After the build is done all one needs to do is run make install as root. At this stage old GHC can be removed. You of course need to add /usr/local/ghc-7.6.2/bin to PATH environmental variable. As I already have mentioned I have the habit of installing all the packages system-wide in a single directory. For that I need to edit /root/.cabal/config file by adding the following entry:

install-dirs global prefix:/usr/local/ghc-7.6.2

All that is left now is installing cabal-install. Grab the sources from hackage, extract them and run (as root) sh bootstrap.sh --global in the source directory. This installs cabal-install with its dependencies. Now you can start installing other packages that you need (a.k.a. compile the World).

This completes Yet Another Installation of GHC.

## To Mock a Mockingbird or: How I learned to stop worrying and learned combinatory logic

Yesterday I finished reading one of the most remarkable books I read in my life: “To Mock a Mockingbird and Other Logic Puzzles: Including an Amazing Adventure in Combinatory Logic” by Raymond Smullyan. When I finished reading The Little Schemer that book was listed as one of the suggested further readings. The title was quite intriguing so I got the book and started reading it. That was a year ago and I finished the book yesterday. Why? Because I got stuck and couldn’t understand some of the material. Luckily I now had some time to approach the book once again and grok it.

As the title suggests the book is a collection of logic puzzles. Out of six parts of the book – 25 chapters total – two are devoted to general logic puzzles, many of them about different aspects of truth telling. These can be regarded as a warm-up because in the third part the book makes a sudden turn towards combinatory logic. And this is the moment I found difficult in the book. Of course Smullyan doesn’t expect that readers work with combinators so he camouflages them as singing birds. Having some mathematical background I rejected this cover and tried to approach problems formally. Now, after reading the book, I think this was a major mistake that lead to my failure. I wasn’t able to deal with first 10 puzzles but I was more or less able to follow the solutions. Still I felt that reading solutions without being able to solve puzzles by myself was cheating so I gave up. A few months later I made another approach to the book but the results were exactly the same. Three weeks ago I made a third attempt, but I decided not to give up even if I won’t be able to come up with my own solutions. I figured that being able to only understand given solutions is completely fine. That decision turned out to be a good one. Although at first I wasn’t able to solve puzzles on my own at some point things just clicked. I solved one puzzle, then another and another and I realized that I know how to solve most of the puzzles. From now on the book went quite smoothly. Part four about logical paradoxes and inconsistencies in logical systems gave me some problems and I was afraid that each subsequent part will be equally challenging but it turned out that it was not the case. Part five gives a nice overview of computations using SKI combinators, while part six presents Church encoding of natural numbers and culminates with a proof of Gödel’s theorem.

$g\tilde{a}\tilde{b}=Z\tilde{a}f(Z\tilde{b}t(g(P\tilde{a})(P\tilde{b})))$