Picking up the axe

posted Mon, 29 Aug 2005 00:42:00 GMT by Jonas Bengtsson

It’s been a while since I’ve been coding Ruby. I learned the basics back in 2002 but since I’m much more fluent in Python I very rarely use Ruby when I need something done. But this time I have the motivation of Rails and a newly bought Programming Ruby 2nd edition (a.k.a. PickAxe).

Now to some random incoherent things I’ve learned about Ruby recently.

The most important and interesting aspect of the language, IMHO, is blocks, and I think I grok it now and am able to know when to apply them.

There were two conventions that made Rails-code hard for me to understand before: symbols and e.g. belongs_to. Kevin Clark taught me symbols and this piece of code describes how belongs_to et al. work:

def tinker_with_class
  class_eval do
    def hello
      puts "Hello world!"
    end
  end
end

class Hello
  tinker_with_class
end

h = Hello.new
h.hello

Output: Hello world!

One thing that I wasn’t aware of before was that Range supports custom classes (implementing the succ and <=> methods), which is neat and something that Python lacks.

Mixins seems to be a really good means of reuse, but I don’t know that much about them for a couple of chapters.

Private methods and variables can only be accessed by the own object, i.e. you can’t access private methods and variables of objects of the same class (as you can in Python, C++, Java and most other languages).

Many of the Perlisms seems to be less preferred now than the first edition of the PickAxe, which is a good thing. Who wants to remember the difference between $!, $&, $., $_, $~ etc?

The main gripe I have is that irb doesn’t work that well with Swedish keyboard layout on Windows, which is a shame since interactive Python was instrumental in my learning of Python.

Anyhow, I like most aspects of Ruby and I hope it will become as natural to me as Python.

Comments Zero comments

Snow Crash

posted Thu, 11 Aug 2005 20:34:00 GMT by Jonas Bengtsson

I very rarely read books, which is a shame since I like doing it, but during the summer I always try to read at least one novel. This time I ended up reading the science fiction novel Snow Crash by Neal Stephenson. Maria recommended it one and a half years ago, I ordered it a few weeks ago and it took almost a week to read (with a few abruptions and days off).

Reviews of books and movies are not part of my skill set (and you can currently find 444 reviews over at Amazon), but at least I can recommend it :-). It’s cyberpunk with a dystopian future where franchises rule the world. There are some nice action scenes with pizza delivery, skateboarding++, motorcycles, and sword fighting. Parts of the book happens inside what the internets have morphed into, the Metaverse, a virutal reality world quite similar to Second Life (which was brought to my attention by some podcasts on IT Conversations and I have yet to try it out, but basically the users can program/create things, retain the ownership and can sell them). There is also quite a lot of history and religion thrown into the mix.

I found some passages quite hard to read due to what Wikipedia describes as “many arcane references to geography, politics, anthropology, philosophy, linguistics, history, and computer science”, and when I started reading after taking longer pauses it took a while to get going again — but I account that to my lack of experience reading English novels. Except for those problems, it was a really captivating, interesting, exciting and entertaining book.

So go read it if you like books like it! :-)

Comments Four comments

Book blogging, blogging books

posted Mon, 28 Feb 2005 00:32:00 GMT by Jonas Bengtsson

I’ve spent something along the lines of five hours on trains this weekend. I like trains because they give me time to read (and listen to podcasts, but that is way more easier finding time for). During my first year at the university I spent a fair amout of time on trains and that was enough for me to do most of the reading required for my studies. This time I continued reading Pragmatic Programmer, which I love but it takes a lot of time for me since I’m reading books far too rarely.

As I arrived in Malmö, waiting for my ride, I browsed a pocket book shop at the station. There I saw what I think is the first book I’ve seen as a blog first (perhaps it wasn’t a pure, by-the-book, blog, but at least blogish) Mil Millington’s Things My Girlfriend And I Have Argued About (hmm, but it seems like it’s a “work of fiction loooooooooosely ‘inspired’ by the Things page”, well ok I was close :-) ), translated into Swedish indeed. But I didn’t buy it.

The day after, Saturday, I went to Akademibokhandeln for the annual book sale. I have mixed feelings about book stores. I like books, I really do. There is something about the lo-fi, the feel, and the guts and endurance of the writer to go through with the editing process and releasing a book that appeals to me. Don’t get me wrong, I really like reading on web as well, the low barrier for entry of blogs, and the sheer amount of text and diverse topics you can digest in a small amount of time. If reading blogs is like looking through windows to other worlds, reading books is like being invited and setting up your tent (but of course less dramatic). But unfortunately the pile of unread books keeps growing and I rarely take the time to read them. So I try to refrain from buying books, no matter how tempted I am.

I planned on continue my not-buy-any-books streak, as I stumbled upon Wil Wheaton’s Just a Geek. I wouldn’t recognize the name, probably not even the face, had I seen it a couple of months ago. But his great appearance on ITConversations changed that. He is a really good, witty, smart and entertaining speaker and author. Back in the days he played Wesley Crusher in Star Trek: The Next Generation (I’m not a trekkie, but I saw a few episodes). The podcast made me subscribe to his blog (WWdN), which in turn made me buy the book.

The book is an autobiography, in the format of old blog posts dating from 2001, intermingled with some after-the-fact writings. As a reader, and fellow geek, Wil invites me to take part of his life. Of how it is to be a struggling actor, beeing called a “has been”, ending up in second place audition after audition, beeing one small part from success, loved and heckled, stepfathering two sons, supported by his wife, mending cats and dog, and most of all living. You know all the things you get to read in those blogs that makes you appreciate people’s honesty, transperency, and openness. And here you get the additional value of Wil describing the backstory of the entries, and especially in the earliest entries, why he sometimes didn’t write the whole story and euphemized. A fascinating read so far!

Thanks Wil for sharing!

Comments Zero comments