Archive for the ‘Blog’ Category
Favorite Television Character in Recent Memory
Tickling Rats
Looks like the video went away. I assure you, rats were tickled in the video. It was very cute.
20 Boat Books
I finished the 20th and final (apart from the unfinished 21st novel) book in the Aubrey Maturin series this morning on the train. It’s kind of neat timing, as today is my last day working at my current job. New job won’t require me to ride the CTA. These boat books were big CTA reading for me over the past couple of years, so the wrap up is tremendously appropriate.
I’m not recommending the books to anyone, because they’re really not for everyone. I loved them, more than any other series of books I’ve ever read. I feel like I should get some sort of lapel pin to mark the occasion. Something.
Ants Beat Bees!
I just saw this ant simulator on reddit, very cool looking. It’s almost exactly what I was shooting for when I started messing around with my various bee simulators. I never buckled down and finished any of them. The bees have lost to the ants. Sorry bees.
Akismet
I installed it yesterday…as of this morning, it’s caught 411 spam comments. Deleting spam comments was getting to be a real hassle, I’m hoping this solves it. So far, so good.
Followup: What's a Block?
This article pretty much explains it, The Magic of Ruby Pens.
It’s a very good write up on exactly why a Ruby block is useful, and isn’t just for iterating over a list.
A Very Simple Ruby DSL Example
Last night at the Perl Monger’s meeting, I showed some code I’ve been working on at work that implements a basic Ruby domain specific language. I pulled the basic concept together this morning and put it into my subversion repository here.
Building your own little mini-language is all the rage, and it ends up being pretty fun to do. However, finding simple examples can be tough. The example in my repository implements what Jamis Buck refers to as Sandboxing.
A runner script opens the file with instructions written in your mini-language, and eval’s it in the context of your DSL class. My example is of the “hello” language. You can save this to the file hellodsl_example:
[source:ruby]
hello ‘Chris’
hello ‘Camri’
hello ‘Cotton’
hello ‘Tulip’
[/source]
…execute ./hellodsl_runner.rb hellodsl_example, and get this as a result:
Hello there Chris
Hello there Camri
Hello there Cotton
Hello there Tulip
The magic happens in the HelloDsl class:
[source:ruby]
class HelloDsl
def initialize(dsl_text)
eval(dsl_text)
end
def hello(name)
puts “Hello there #{name}”
end
end
[/source]
When you initialize the class, you pass it the text of your dsl file. The text is eval’d. So you text becomes a series of method calls within the context of the HelloDsl class. The class instance, in Jamis’ explanation, becomes a sandbox in which your code is executed.
Chicago.pm Recap
I presented last night at the Chicago Perl Mongers meeting. The theme was introducing Perl people to some other languages. I think it went over pretty well. For each language, I talked a little bit about the basic syntax, library resources, and general community stuff. Then gave one “cool thing” that I think typically really makes a first looker’s eyes go wide. For Python it was list comprehensions, for Ruby it was blocks and adding methods to existing classes.
Python was a slam dunk demonstration wise, it makes sense to people. List comprehensions are so similar to map that it wasn’t really a conceptual leap. It was just something cool. Ruby was a harder sell. Opening up String and adding a is_cool? method got some good reactions, but the block concept just left a lot of heads shaking. Block usage seems sort of odd at first. I remember not really understanding how my_list.each {|i| puts i} is better than for i in my_list do. I explained that blocks are something you just use for a while, and then you realize that they sort of invert the way you think about simple things like iteration. I built a quick closure, thinking that would help, but it didn’t.
I’m giving this presentation again next month out in Wheaton. Anyone have an advice for how to better present blocks? I think it may very well be the sort of thing you don’t appreciate until you use them for a while, but it would be nice to have an example that really shook people up. Any advice is appreciated.
Notes for Tonight's Chicago.pm Meeting
I’m presenting tonight at the Chicago Perl Monger’s meeting. I’m giving a tour of some stuff that might appeal to Perl programmers who want to learn new languages. I’m focusing on Ruby and Python. Here are the notes, they’re also available in my public subversion repository:
Language Hootenanny
Notes for the language hootenanny presentation at February’s Chicago.pm meetings.
Agenda
- A little bit about me
- Find out what everyone wants to know
- Language overview
- for each language, a brief discussion about its culture, philosophy, and resources. Then the one thing about it that’s really “cool” and some code samples.
What I like about a language
Object oriented, good testing framework, great documentation, fun community, lots of libraries, web stuff. Also, interactive shells…the total time it takes to learn a language is cut down considerably if you have an interactive shell to play with. They’re pretty standard anymore, so this is usually just a given.
Classifying languages
There’s really two kinds of languages in my book, the kind you can make money from and the kind you learn for fun.
Ruby
Resources
- Main Ruby site
- Rubyforge, just like Sourceforge but with all Ruby projects
- The Pragmatic Programmer’s Ruby Book (The Pickaxe) by Dave Thomas
- _why’s poignant Ruby guide <—quirky guide to Ruby
- Code Snippets <—actually, this is good for all three languages
My recommendation to learn Ruby is to buy the pickaxe book, and start playing around with it. why’s guide is also good, but it is _pretty quirky, so be prepared. The pickaxe is better if you’re already familiar with object oriented programming and you want to learn Ruby.
One cool thing
Blocks
Python
Resources
- python.org
- Python Tutorial <—the first python tutorial you should read.
- Dive into Python <—the second python tutorial you should read.
The best way to learn Python is to jump into the Python tutorial on the website, then skip around “Dive Into Python.”
One cool thing
List comprehensions.
Perl 6
Resources
PHP?
I haven’t been keeping up with the PHP community enough to really be able to tell you what’s up. I do know that PHP5 is interesting. Discuss amongst yourselves if anyone is interested in PHP.
Other Stuff I Don’t Know (but would like to learn)
Haskell, Lisp
Stuff that other people want to learn, but I’m not so sure about yet.
Erlang, REBOL
February ChiPy Meeting
Last night the Humanized crew presented their new application, Enso to the group. Enso looks pretty great, and it’s written mainly in Python. They’ve redefined what I’ve thought was possible from a Python application, especially on Windows. We were all pretty amazed with what they’ve accomplished.
One of the interested tidbits that came out of the talk was a library they wrote that enforces contracts between modules, similar to the design by contract feature in Eiffel. They plan on releasing the library as open source soon.
