citizen428.blog()

Try to learn something about everything

Information Overload 2011-02-06

Review: Land of Lisp

Disclaimer: The awesome folks at No Starch Press were nice enough to provide me with a free copy of the book reviewed here, but what I’m about to write has not been influenced by this. I just wanted to get this out of the way…

Ever since I first learned about it, I was eagerly awaiting the release of Land of Lisp. If you have never heard about the book before, have a look at this promotional cartoon music video. Yes, that’s right, this book comes with its very own promotional cartoon music video!

Your reaction to this video is actually a pretty good indicator on wether or not you are likely to enjoy this book. If you can’t take the cartoons and strange humor, “Land of Lisp” will probably not be for you. If you do however, you’ll be relieved that the book is at least as awesome as the video and probably even more.

People believing that Lisp has been dead since the AI winter may be surprised by the release of new book on the language in 2010. They may however have missed the release of Peter Seibel’s Practical Common Lisp in 2005, which managed to expose the language to a wider audience again, a feat I think “LoL” might achieve too.

For me the best part about Conrad Barski‘s book is its very readable and entertaining style, combined with cartoons and the use of small games as demonstrations of the techniques introduced in the book. I think this is what makes “LoL” really stand out from the other Lisp books: it’s neither as academic as most of the texts focussed on Scheme (with The Little Schemer being an obvious exception), nor is it as dry as Seibel’s book (which otherwise is a pretty good read) or as dated as Paul Graham’s On Lisp which was written while Common Lisp was still in the process of being standardized. For many people “Land of Lisp” may very well be there first contact with the language, and I think with its funny and easy to follow style it may get quite a few people hooked.

The book is structured in 4 main parts, the first of which – called “Lisp Is Power” – serves as a general introduction to the language, explaing the basic syntax and so on. The second part (“Lisp Is Symmetry”) introduces the reader to flow control, data structures, input and output, lambda expressions and more. In the process you’ll write the first part of a game engine for text based games, a great little version of Hunt the Wumpus called “Grand Theft Wumpus” and “Orc Battle”, a small strategy game played in the REPL. The third part (“Lisp Is Hacking”) introduces us to the powerful and sometimes disputed “format” and “loop” commands, as well as streams. Game-wise you’ll encounter a little simulation of an evolving world as well as “Attack of the Robots”, a retro game where your aim is to get rid of some robots by making them collide with each other. The last part (“Lisp Is Science”) introduces functional programming techniques, macros, DSLs and laziness. Besides finishing the text adventure started in an earlier chapter, you’ll also write “Dice Of Doom”, a Dice Wars clone that’s the most complex program of the whole book. Last but not least there’s an epilogue, where the author gives a brief overview of several important topics that got little or no exposure up to that point, like CLOS or the condition system.

As a final summary I’d say that “Land of Lisp” is a truly great achievement. It’s fun to read and does a good job of introducing the reader to the most important concepts of Lisp, by giving a taste of the language’s power, without being overwhelming. For more experienced Lispers this might make the book significantly less interesting, since some really nifty things only get mentioned in the epilogue. If you are among them, Seibel’s book is probably what you want to read (if you haven’t already, which would be surprising). I’d also advise you to not get too excited about the “game development” part of the book, except for the last one all the games are rather minimal and simple, so don’t expect writing 3d shooters or anything like that. They are however awesome examples of the concepts introduced in the individual chapters and way more fun than the contrived examples one finds in way too many programming books. For new Lispers or people who need to brush up on their Common Lisp skills (e.g. when migrating from some other Lisp) this comes highly recommend, but even more senior Lispers might want to get a copy, even if it’s only for the odd cartoons.

Information Overload 2011-01-30

Information Overload 2011-01-23

SICP 1.12, Kind Of…

When working through SICP while you are tired, you might end up solving the wrong problems. This happened to me today with exercise 1.12, which asks the reader to “[w]rite a procedure that computes elements of Pascal’s triangle by means of a recursive process”. I somehow missed the “computes elements” part, and instead wrote a program which generates Pascal’s triangle up to a certain row. Anyway, here it is as a reference for the next guy who can’t read:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<span class='line'><span class="p">(</span><span class="k">define </span><span class="p">(</span><span class="nf">pascal-sums</span> <span class="nv">lst</span><span class="p">)</span>
</span><span class='line'>  <span class="p">(</span><span class="k">if </span><span class="p">(</span><span class="nf">empty?</span> <span class="p">(</span><span class="nb">cdr </span><span class="nv">lst</span><span class="p">))</span>
</span><span class='line'>      <span class="o">&#39;</span><span class="p">()</span>
</span><span class='line'>      <span class="p">(</span><span class="nb">cons </span><span class="p">(</span><span class="nb">+ </span><span class="p">(</span><span class="nb">car </span><span class="nv">lst</span><span class="p">)</span> <span class="p">(</span><span class="nb">cadr </span><span class="nv">lst</span><span class="p">))</span>
</span><span class='line'>            <span class="p">(</span><span class="nf">pascal-sums</span> <span class="p">(</span><span class="nb">cdr </span><span class="nv">lst</span><span class="p">)))))</span>
</span><span class='line'>
</span><span class='line'><span class="p">(</span><span class="k">define </span><span class="p">(</span><span class="nf">pascal-triangle</span> <span class="nv">depth</span><span class="p">)</span>
</span><span class='line'>  <span class="p">(</span><span class="k">define </span><span class="p">(</span><span class="nf">triangle-iter</span> <span class="nv">lst</span> <span class="nv">n</span> <span class="nv">acc</span><span class="p">)</span>
</span><span class='line'>    <span class="p">(</span><span class="k">cond </span><span class="p">((</span><span class="nb">zero? </span><span class="nv">n</span><span class="p">)</span>
</span><span class='line'>           <span class="p">(</span><span class="nb">reverse </span><span class="nv">acc</span><span class="p">))</span>
</span><span class='line'>          <span class="p">(</span><span class="nf">else</span>
</span><span class='line'>           <span class="p">(</span><span class="nf">triangle-iter</span> <span class="o">`</span><span class="p">(</span><span class="mi">1</span> <span class="o">,@</span><span class="p">(</span><span class="nf">pascal-sums</span> <span class="nv">lst</span><span class="p">)</span> <span class="mi">1</span><span class="p">)</span>
</span><span class='line'>                          <span class="p">(</span><span class="nf">sub1</span> <span class="nv">n</span><span class="p">)</span>
</span><span class='line'>                          <span class="p">(</span><span class="nb">cons </span><span class="nv">lst</span> <span class="nv">acc</span><span class="p">)))))</span>
</span><span class='line'>  <span class="p">(</span><span class="nf">triangle-iter</span> <span class="o">&#39;</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="nv">depth</span> <span class="o">&#39;</span><span class="p">()))</span>
</span><span class='line'>
</span><span class='line'><span class="c1">;; &gt; (time (pascal-triangle 7))</span>
</span><span class='line'><span class="c1">;; cpu time: 0 real time: 0 gc time: 0</span>
</span><span class='line'><span class="c1">;; ((1) (1 1) (1 2 1) (1 3 3 1) (1 4 6 4 1) (1 5 10 10 5 1) (1 6 15 20 15 6 1))</span>
</span>

Emacs Twittering-mode

When my usual Twitter client stopped working last Tuesday, I got inspired by Ruben’s Emacs 30 Day Challenge and decided to look what Emacs had to offer in terms of Twitter clients. On the always helpful EmacsWiki I found a list of available options and after some browsing settled on twittering-mode. I got hooked really fast, so even after getting Nambu to work again (somehow authentication got screwed up), I decided to stay with Emacs for my Twitter needs.

Here’s a screenshot from the Emacs wiki (although I usually have the avatars turned off):

Emacs twittering-mode

If you also want to give this awesome mode a spin, I recommend starting at this EmacsWiki page, which has installation instructions, a summary of key-bindings and options and some discussion by users.

Here are the relevant parts of my Emacs config, with extra comments added for this post:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(require 'twittering-mode)
; update every 10 minutes
(setq twittering-timer-interval 600)
(setq twittering-url-show-status nil)
; Show character count in compose buffer
(setq twittering-use-show-minibuffer-length t)
; I added is.gd support myself, pull request sent.
; standard options are tinyurl and toly
(setq twittering-tinyurl-service 'is.gd)
; See http://www.reverttoconsole.com/blog/nix/twitter-mode-for-emacs-with-oauth/
(setq twittering-use-master-password t)

; This tells twittering-mode which time line buffers
; to open when starting
(setq twittering-initial-timeline-spec-string
      '(":friends"
        ":replies"
        ":direct_messages"
        ":search/clojure/"
        ":search/#jlang/"
        "citizen428/tupaleros"))

; some key bindings
(add-hook 'twittering-mode-hook
          (lambda ()
            (mapc (lambda (pair)
                    (let ((key (car pair))
                          (func (cdr pair)))
                      (define-key twittering-mode-map
                        (read-kbd-macro key) func)))
                  '(("R" . twittering-native-retweet)
                    ("l" . twittering-goto-next-thing)))))

TImelines

As you can see twittering-initial-timeline-spec-string defines which timeline buffers get opened when starting. This is really convenient, since you can use f and b to cycle through them. If you want to see only the timeline of the author of the currently active tweet hit v, C-c C-v will open the profile in a web browser. V gives you access to all pre-defined timelines like :public or :retweets_of_me.

Tweets

Inside a timeline j and k let you jump from tweet to tweet, whereas p and n go to the previous or next tweet by the same author. Replying to a tweet is as easy as pressing enter. I’ve rebound twittering-native-retweet (for “new style” retweets) to R instead of the somewhat unwieldy C-u C-c Enter, “organic” retweets are possible with C-c Enter. r opens related tweets, so it’s easy to follow conversations and u let’s you post a new tweet. My favorite function is probably twittering-goto-next-thing (bound to l in my setup), which jumps to the next username (to make it easy to visit the profile), URI, or timeline symbol (like a hashtag).

There are many more useful functions and key combinations (like i for showing/hiding avatars), it’s best to look them up on the EmacsWiki page. I’m very impressed by and happy with my new Twitter client, browsing through my update stream has never been so fast and efficient.

Information Overload 2011-01-16

Information Overload 2011-01-09

Information Overload 2011-01-02

2010 Reading List

A list of the books I read in 2010, sorted by finishing date. According to Goodreads that’s roughly 18.5k pages, not bad considering I worked full-time and also studied on the side:

The Disaster Area: J.G. Ballard
Balkan Blues: Petros Markaris
The Ministry of Special Cases: Nathan Englander
Diary: Chuck Palahniuk
Mathematik Fuer Das Bachelorstudium I: Grundlagen, Lineare Algebra Und Analysis: Mike Scherfner
A Case of Two Cities: Qiu Xiaolong
Strangers: Taichi Yamada
Goedel, Escher, Bach: An Eternal Golden Braid: Douglas R. Hofstadter
Haroun and the Sea of Stories: Salman Rushdie
Journey through Genius: The Great Theorems of Mathematics: William Dunham
Fight Club: Chuck Palahniuk
The Man Who Loved Only Numbers: Paul Hoffman
Vernon God Little: D.B.C. Pierre
Fermat’s Last Theorem: Simon Singh
The Bell Jar: Sylvia Plath
Prime Obsession: Bernhard Riemann and the Greatest Unsolved Problem in Mathematics: John Derbyshire
Suite Francaise: Irene Nemirovsky
A Monk Swimming: Malachy McCourt
South of the Border, West of the Sun: Haruki Murakami
Dynamic Web Development with Seaside: Michael Davies
Wie der Soldat das Grammofon repariert: Sasa Stanisic
What I Talk About When I Talk About Running: Haruki Murakami
Learn Prolog Now!: Patrick Blackburn
Reise in die Nacht: Gianrico Carofiglio
Compiler Construction: Niklaus Wirth
All Families Are Psychotic: Douglas Coupland
The Little Schemer: Daniel P. Friedman
Shantaram: Gregory David Roberts
Zwei von zwei: Andrea De Carlo
Number Freak: From 1 to 200- The Hidden Language of Numbers Revealed: Derrick Niederman
Refactoring: Ruby Edition: Jay Fields
Practical Clojure: Luke VanderHart
Flatland: A Romance of Many Dimensions: Edwin Abbott Abbott
House of Leaves: Mark Z. Danielewski
What Happens Now: Jeremy Dyson
Maramba: Paula Koehlmeier
A Carrion Death: Michael Stanley
Little Brother: Cory Doctorow
Programming Erlang: Software for a Concurrent World: Joe Armstrong
The Hacker Crackdown: Law and Disorder on the Electronic Frontier: Bruce Sterling
Submarine: Joe Dunthorne
Holy Cow: An Indian Adventure: Sarah Macdonald
Der Gourmet. Leben und Leidenschaft eines chinesischen Feinschmeckers: Lu Wenfu
Sandman Slim: Richard Kadrey
Tod im April: Jose Luis Correa
How To Create Your Own Freaking Awesome Programming Language: Marc-Andre Cournoyer
A Case of Exploding Mangoes: Mohammed Hanif
Gute Macht: Fabian Faltin
Practical Common Lisp: Peter Seibel
The Book Thief: Markus Zusak
Eloquent JavaScript: Marijn Haverbeke
Programming in Haskell: Graham Hutton
The Half-Made World: Felix Gilman
Twitterature: The World’s Greatest Books Retold Through Twitter: Alexander Aciman
Stupid History: Tales of Stupidity, Strangeness, and Mythconceptions Throughout the Ages: Leland Gregory
John the Revelator: Peter Murphy
MetaGame: Sam Landstrom

I also read the first 100 or so pages of “Land of Lisp” by Conrad Barski, but this will be in next year’s reading list.

Copyright © 2016 - Michael Kohl - Powered by Octopress