SmallTalk @ FP
I’ve just had a group introduction to Smalltalk. Piers was visiting Brighton and decided to teach us all about the roots of OO programming. In lieu of the usual 5-minute-on-keyboard sessions, Piers gave us a walk through of developing kata 4 in smalltalk.
This was a superb way to learn the language. There was more heckling than usual, but that was an important and necessary part of the process in this case. Watching smalltalk in action is absolutely necessary—it’s just such a visual experience (compared to regular programming languages, anyway). I now completely understand the smalltalk credo I’d read about: just type in what you want to happen, hit “run test” and when it breaks, write the code in the debugger window that pops up.
Just before half time, Piers started pairing properly. That was when the language differences really started to hit home. Smalltalk is so not an algol-influenced language. In particular, I adore the cascade:
fromRow: aString ^ self basicNew; initialize; setRow: aString; yourself.
That semicolon is calling methods (sorry, passing messages) to the same object after each semicolon. The statement is only terminated with a period. Conceptually, it feels similar to Perl’s
$_ (or “it”).
As usual, we didn’t get particularly far in the task, but we did learn a huge amount. A big thanks to Piers for visiting us and also to Devi for cat-herding in Joh’s absence (and doing an excellent job of keeping us on-topic).
Now, I’m off to download Squeak…
Skillswap: Intro to Rails
Last night I presented a skillswap, “Introduction to Rails”. This was meant to be a fairly quick overview for people who’ve done some web development before, but are completely new to Rails (and Ruby). The event was presented in two parts. First, a set of slides about what Rails is, why it works and a brief overview of Ruby. Then, a practical session.
For the practical, I installed Locomotive and we ran through a quick session of getting started with a rails application, building a model and putting up some scaffolding on top of that. There were only five macs, so people had to work together, which probably helped. I have to issue a huge thanks to lighthouse for the opportunity to use the fantastic venue.
I did actually have further slides and handouts, which progressed the practical, but it was already getting on for 20:30, so it seemed wiser to halt whilst things were still going well.
Like all live things, not all went to plan. The main annoyance was the fact that Locomotive-generated projects (well, Rails really) default to using MySQL. A quick switch to SQLite made things work a lot better. Servers can be a pain when you’re trying to get things running.
The slides and handout are available for download.
- Introduction to Rails (Keynote, 1.5Mb)
- Introduction to Rails (PDF, 776Kb)
- Introduction to Rails Handout (PDF, 68Kb)
- Introduction to Rails Handout (Pages, 36Kb)
Also many thanks to Jane for the kind words. 🙂
Coding Dojo Tonight
Despite not completing the task (as per usual!), I learned an enourmous amount from the interaction this evening. It felt really humbling to be amongst people who knew so clearly what they were trying to achieve. Chatting to Piers afterwards made me realise how I tend to be very focussed on solving the problem at hand rather than stepping back and trying to create something beautiful. I need to go back and read TDD and Refactoring…
On another note, I’m really looking forward to the festival dojo. It’s the 10th of May. Come and join us.
I’ve fairly recently gotten turned on to my local library. They have graphic novels. Lots of graphic novels. Yum. This is good, because it helps limit my expenditure on such things. So I’ve been going through them at a rate of knots.
When I’m reading, I tend to use business cards as bookmarks. $WORK purchased several hundred of them for me a while back. I have no idea why, as I only get to go see clients about twice a year. But they do make good bookmarks.
I was amused, however, to hear from a friend of my partner that her partner in turn had borrowed a book from the library and my card had dropped out of it. Now that’s geek advertising!
Coding Dojo 9
I’m just back from Dojo#9. We attempted Kata 4 again, but in Ruby this time. Even though I was the only one with much Ruby experience behind me, it still wasn’t much of a problem in practise. I did some cheat sheets, but they didn’t seem to be used much.
Exactly the same as the last time, we only completed the first part of the kata. I started the session by writing a small amount of code. In a very non-object oriented fashion. However, I honestly believe that for this problem an OO solution was utter overkill. The testing was probably useful, but to be quite frank a program this short can be visually inspected so easily, I hardly feel it’s worth it. Heresy, I know.
This is what I was aiming towards.
day = nil min_spread = nil File.foreach(ARGV) do |line| if line =~ /^\s*(\d+)\s+(\d+)\s+(\d+)/ spread = $2.to_i - $3.to_i if !min_spread || spread < min_spread min_spread = spread day = $1 end end end puts day
I’m pleased about using regexes though. They make the problem simpler (and more robust) than the previous Java solution using
Now, when it came to refactoring the program to get to the third part of the kata, an OO solution would have been more appropriate. Because you need to carry some state around, and you can obviously use inheritance to model the differences. And by that point, you’ve got two working programs you can extract a sensible design from.
SkillSwap on Typography
Last Thursday evening, Richard Rutter gave us a talk on Web Typography Sucks. It was a hugely successful event. It turned out that there were nearly 17 of us in the small room. Richard’s talk was essentially a preview of his SXSW talk, so if you can catch it there, I really recommend it.
Richard covered various aspects of what typography applies to the web (hint: it’s not just about fonts), and how we can improve on what we’re doing. He correctly pointed out that if the sun can do it, then so can we.
I was personally really pleased because a lot of the topics that he covered are things that I’ve had to a little bit of at work, but not really clearly got my head around. I now feel ready to go forward and make my next web site far more pleasant to read.
Interestingly, I’ve just noticed this article: Web Design is 95% Typography. How serendipitous.
Last night was the latest Coding Dojo. It was an astonishing success. Not only did we all manage to enjoy ourselves, we actually produced some working code! We were attempting Kata Four (data munging), which is split into three parts. Admittedly, we only finished the first part, but it still felt like a real achievement.
The task itself was interesting. It’s the kind of task that you’d whip up in a few lines of Perl or Ruby in a few minutes. Yet with Java, it all gets much more complicated. For starters, you get exposed to the morass of Java I/O classes, which confound and bemuse me every single time.
Then there’s the text processing aspect. This actually turned out to be easier in Java, because we were dealing with a fixed width format and the natural instinct is to reach for substring().
What was nice was that with half an hour to go, we decided that we wouldn’t try to start the second part of the Kata. Instead, we focussed on cleaning up the code we had written—a pleqsant experience.
I hope we pick this one up next time. It’ll be interesting to carry on with the rest of the task.
Skillswap is back!
For too long typographic style has been overlooked on the Web. This SkillSwap will show how new technology demands that websites receive the refinement that has been applied in print for centuries. The session will examine what currently sucks about typography on the Web, and how to implement those typographic principles which are so severely lacking. It will also highlight what is being done right typographically, and how that can be carried forward.
By explaining how everyone involved in a website can and should take typography to heart, the session will provide a blueprint for introducing typography at all stages of a project, thus ensuring that sound typographic principles and techniques become an integral part of the future of Web.
Please come along—just drop us an email at firstname.lastname@example.org.
Now, I just wish that I had managed to organise all this earlier… Mea culpa. I’m just grateful to Andy Budd for allowing us to pick up his excellent work. And also to my cohorts, Ribot, Rosie Sherry, Danny Hope and Glenn Jones who have really helped to pull all this together.
We started late because I was installing all the necessary bits (ruby + eclipse) on Joh’s laptop…
Having done that, I gave a quick presentation comparing Ruby to Java. I had been under the impression that most people there would be familiar with Java (based on previous experiences). Unfortunately, because it was Ruby it attracted a very different crowd. Thankfully, nobody seemed to mind too much.
After that, we started on the task: write a Sudoku solver. This was the point where I realised that whilst I’d brought along code for a board, I hadn’t actually brought a puzzle to solve. Ooops. So we hopped over to Wikipedia to grab a sample puzzle. And we then realized I needed an importer… So we knocked one up fairly quickly. Whilst I did feel quite embarrassed about lacking such a crucial part of the problem (bad prep! no cookie!), it turned out to be an interesting example of coding something simple. The fact that I was with Andy, who I know well helped a lot.
Unfortunately, as the evening progressed, it became rapidly clear that none of us had much clue about how to solve a Sudoku puzzle algorithmically. So most of the time ended up being spent discussing the problem as opposed to coding. Afterwards, it was suggested that a “time out” be taken so we could discuss the strategy as a group—that might have helped quite a bit.
Finally, the last pair on the keyboard started making real headway. Andy and James came up with an algorithm for listing the “opportunities” for a given cell and were in the middle of implementing it when the final whistle blew.
So we didn’t get very far at all towards a solver. But as usual the journey was interesting and entertaining.
SkillSwap is a really neat idea set up some time ago by Andy Budd. It’s all about getting the local web design community together to provide free training for each other. I managed to get into it fairly late on, and gave a presentation on subversion.
Unfortunately, in the last couple of years, Andy’s been really, really busy with his new business, clear:left. So there’s been no time to organise anything SkillSwap related.
Ok, I’ll be in the Earth & Stars along with Mr Ribot and Mr Budd on Thursday 18th (a week tomorrow). I’ll be there from 18:30 onwards.
If you’re at all interested in reviving SkillSwap, please come along. Hopefully we can have a good discussion and get some ideas about what people would like to see.
If you can’t make it, but still want to contribute, drop me an email with your suggestions and I’ll bring it along on the night.
I’m really excited about this—SkillSwap was an incredibly useful thing and I’d very much like to see it come back to life. But that’s only going to happen if we get people interested. So please spread the word and come to the pub next week!