Month: October 2010

Decided to work on non-software project for a while

I started a comic novel GRTZ way back in the day and have been thinking of adding some more stuff to it, and working on it for a while. I need a break from doing software in the evenings because I can’t concentrate on it.

Here are the existing chapters:

Have a peruse if you want, I will be posting more over the coming few weeks.

New stuff

I suppose this is chapter 3

Imported Comments:

Laurel Wingfield

I enjoyed this. I liked the tone of irony, the ring of reality, in that the Big Corp running the operation were trying to do the whole thing as cheaply as possible, the idea that humans can take the desirable qualities of some animals and use them to modify and augment themselves, and the tongue-in cheek humour.

I found the writing style a bit rough-and-ready, but once polished up and completed, I think this would make a very entertaining novel. It has a sort of ‘Starship Troopers’ ring to it, with a grim humour which might appeal to fans of ‘Firefly’ or ‘Blake’s 7’. It would be difficult to find a publisher who would be prepared to accept this, though, with so much competition out there.

Francis

Thanks, Laurel. I have a huge, far too serious novel I could send you if you want… 🙂

Ruby and Rails 2010: Corey Haines

Thoughts from Software Craftsmanship

Corey Haines

Pair programming started in 1946!

Definitive source of information – googlefight. Says it’s good.

TSA – top secret information. Kept erroring out.

Travel visa for Australia – rejected for a Visa

New term Softwared! Follow Glyn Vanderberg – glad I’ve got the skills feel sorry for the folks who don’t. @glv

This is US!

All written our fair share of things we didn’t test. We’re the ones who are creating all the crap that doesn’t work.

SWC manifesto. Make the world a better place for the people who aren’t developers.

Career ideas – become better at what we do. Business software and web apps aren’t hard but you have to pay attention to the detail.

Alan Kay OOPSLA 1997 talk. Air force tape. Everyone came up with their own formats. Beginning of tape has pointers to code that has the read and write routines. Didn’t have to write code to read any more. All of these ideas slowly started coming in over time. Combined together.

Bruce Tate – most people have never done non OO. Interesting idea most people don’t know what it was like not doing OO.

MongoDB – Document DB – new hotness. .Net only talk about Mongo. Lotus Notes, schema less. Awful job of email. Nothing new about Mongo – had document databases for a long time.

Cuke – inspired by COBOL!

Looking back at the tools can sometimes give us useful insights. Quote: older a program gets the more valuable the readability never hear that this is the value of cuke.

Relishapp.com – all the documentation for rspec. How to use Rspec. Relish takes cucumber features and generates documentation – all doco in the cuke scenarios. If they’re green that’s how rspec work.

Not just code, systems we use. Techniques come from who taught us. Wing Chun teacher focused on interactions between people, fluid interaction. Influenced development style, focues more on interaction – behaviour-oriented. Don’t know where you came from not going to be able to build effectively.

Uncle Bob.

  • Professionalism
  • Design techniques
  • Abstractions

David Chelimsky

RSpec Maintener

  • Care for code
  • Testing techniques
  • Naming

Attention. All of these things very imprtant to him

Continual learning. As we go through our careers always going to have new stuff to learn. Also improtant to get better at what you already do.

Cratsmanship-oriented career model. Don’t spend a lot of time learning from those around us, new people. Just stick with what we know. Feeding the same techniques.

When studied with teacher did what was asked – do what needed to learn, not blind. Respect the person enough to trust that what being taught works. Once studied and become effective, stable point in your career.Most people have other people around them that you can work with, user groups etc.

Knowing what you do know and practicing stuff you don’t : Deliberate Practice

Focus on performing. What would you do if you went to see a band who only play instruments when they’re on stage, but we do it every single day. E.g. write and delete/rewrite? The things you know you should do. Practice – minimise the difference between “get it done” and “do it right”. On stage, you want to just play.

Practice Techniques

Outside of getting it done.

  • Code Kata
  • Dojo
  • Retreats

Randori style. All attack one person and they defend themselves, two people, crowd and then swap one at a time. Get to watch and get to do a little bit. Wonderful. User groups. Pick a small problem.

Kata. Originally Dave T small problems, but broadened out martial arts – a solution. Over and over again, don’t alter them, the goal is to make the motions perfect. When the time comes you won’t be slow. Kata in software, small solution, e.g. string calculator, roman numerals. Solve it. Then do it again, again, again until you don’t have to think about it. Techniques you use will speed you up in day to day work, e.g. flatten array.

Performace Kata – learn it and perform it. At the end feedback. I noticed you did this, better if did that Lots of katas online. katacasts.com

Code retreat. A day where we work on specific problem, e.g. game of life. 45 mins, delete, swap. Can’t finish in 45. Pressure goes away, so look at the process & write perfect code – problem takes too long. Throw away idea of even finishing.

Practice

Being better. Not just the new Gem/DB/banana about being excellent. Fundamentals of s/w development the heart of s/w craftsmanship

We have the greatest job in the world

Get paid to do things you enjoy.

(Except maybe fighter pilots)

Comes down to happiness. Be happy every single day. If we enjoy what we do then everyone will want a piece of it.

Not going to convince anybody without being happy. People want some of that.

Ruby on Rails 2010 notes part 2

Concurrency: Rubies, plural

Elise Huard

Moore’s Law finally hit in 2002. Multiprocessor response, plus non-uniform memory access. Important to be aware of concurrency.

But … forget all that (mostly)

Concurrent programming != parallel computing

Thread level paralleism vs instruction level

Not orderly more like a stream of cars on a busy road that soldiers in lock step.

Scheduling

  • Preemtive → told to yield
  • Cooperative → thread yields control

Threads are the unit of execution. Process container/memory space of one or more threads. Context of thread.

Ruby

Process

  • 1.8 green
  • 1.9 Native threads MRI 1.9, Rubinius

MRI: GIL

Global Interpreter Lock

Only one thread executed at a time, scheduling of threads fair. Main and time. Blocking region to allow limited concurrency. (Blocking IO driver)

Other Rubies

Parallel quicksort

Easy to parallelise, put each tree in its own thread.

Multiprocess

Separate state
disadvantege overhead to cpawinign & context switching

Ruby: for and IPC: IO.pipe Mmap

DRb

Fibers – not parallel. Cooperative scheduling, coroutines – passing between fibers at same point.

MVM

Rubinius – VM per native thread. Looks out of date now and not supported?

Shared state will melt your brain

  • non-determinism
  • atomicity
  • deadlock
  • livelock
  • fairness/starvation
  • race conditions

Actor model

named actors: no shared state – asynchronous message passing fire & forget

CSP

Communication Sequential Processing

  • Process calculi
  • Events, processes
  • Synchronous message passing (rendez-vous)
  • named channels – dual to Actor model

Languages

  • Erlang
  • Clojure
  • Go (CSP)
  • Haskell (several)
  • Scala (Actors)

Ideas

  • Functional programming – no side effects, immutable data
  • Nothing shared
  • message passing

Erlang

  • Actor model: Actors, asynch message passing
  • actors = “green processes:
  • efficient VM (SMP since R12B)
  • high reliability

Rubinius

  • Actions in the language, threds with inbox
  • VM actors (not working at the moment)

Ruby: Revactor

  • elrang-like senatics: actor spawn/receive, filter
  • Fibers (so coop scheduling)
  • Revactor::TCP for non-blocking

Go

  • Fairly low-level fit for systems programming
  • static typing
  • goroutines: parallel execution – sort of async lightweight thread
  • channels (sync named)

Clojure

Functional, lisp-like

Concurrency, Sottware Transactional Memory system

  • Vars = variable state is thread isolated
  • Refs = shared, and mitation within a transaction (atominc. consistent, isolated) – Multiversion concurrency control

Ruby: STM

  • @mentalguy

Kernel stuff

Some of these problems have been solved before.

http://www.delicious.com/elisehuard/concurrency

http://github.com/elisehuard/rubyandrails-2010

Rubinius

Dirkjan Bussink, Nedap

1.1 is out! Bug fixes, block inlining, new debugger API and included debugger as a reference, improved GIL (used ideas from Python 3.2)

2006 Ruby interpreter in Ruby, is it possible to write more of Ruby in Ruby?

2010 1.0 release

2 virtual machines (3 if you count the 1st VM in Ruby) new VM in C++ better fits Ruby’s model from C++

1.75 garbage collectors

3 bytecode compilers (based on MRI parser)

1 Ruby core library

2 primitives systems – call into VM to do work for you

JIT compilers

Rubyspec

Create a reference for Rubinius and create in Ruby.

Memory

Compacting garbage garbage collector
Generational – long lived objects out the way not scan every object every time

Fast workers die young

Instance variable packing, keeps track of instance variables used in compilation

JIT

InlineCache – simple technique, remember where method was found. But need to invalidate caches if class has been changed. Method calling much faster than MRI. Counts how many times you call the method, and looks at chain of calls. JIT using LLVM – intermediate representation (IR) assembly language for LLVM.

Debugging

Debugger.here – shows backtrace, disassemble into bytecode

The awesome backtrace, proper alignment, different colours for what kind of code

Profiling

Measuring is knowing and guessing is often wrong. Runs twice, warm up to get inlining and optimisations. Profiler graphs too so that you can trace why things take time when they don’t in isolation.

Contributing

One patch accepted == commit access

Rather have a policy of being very open.

rbx my_awesome_code.rb

Future

  • 1.9 support new Hash syntax, encodings
  • Windows support
  • Hydra GIL removed

Audio Synthesizers

Jeff Rose, Sam X

Clojure. Serge modular synth

Modules/patch cables/no save button

Software synths like Circle – can’t get into the guts and rearrange things. Visial programming analogues. Finally found SuperCollider – own language based on Smalltalk. Getting into clojure, connect it to back end audio engine of SuperCollider …

Generate music / hack. Representing a waveform as arrays of numbers and manipulating them. Software – sound card DAC takes sample values and makes smooth waveform. Voltate corresponds to position of an electromagnet.

Crash course in Clojure …

Overtone – library around SuperCollider API

Compile synthesiser in terms of DSP units and function you can call to trigger it.

Live coding session followed. It was ok for a while.

Ruby on Rails 2010 notes part 1

Mildly incoherent, but here they are:

Culture of Testing

Jon Yurek, Thoughtbot, @jyurek

Testing & version control not taught in school, no reason not to. Java testing getters and setters – insane. Culture of Ruby is to test/TDD.

  • Coming of age blog
  • Then framework

Contrib factory_girl/shoulda. Out the box very limited. Then we found cucumber. Didn’t like at first, but then having a story. 2009 Rumble – pure cuke. Can’t test with just cuke. Fakes – sham-rack. Tiny apps that can run basic API hits. Outside-in the way forward.

Don’t write integration tests like unit tests – cuke stories are not supposed to be code.

Steps not just long-winded method calls.

Don’t have time to test – it will make us faster. Technical debt – won’t be able to refactor or add new features. But if you really need to, go ahead. Once done, and calmed down rewrite it the right way headaches down the line.

Working with the unknown – write stuff to find out what the approach is. Understand problem and then throw it away. Experiments, toss them out. Weren’t writing your best code in the first place.

Code is communication, tests even more so.

Tests are also tests – tests are first client for app. No-one will know how to change, cargo culting. Tests will tell you what the coder was thinking.

Look at tests first.

RSpec & Shoulda have very few watchers on github.

Everybody’s testing, just not very efficiently.

Use the scientific method hypothesis/test/control/results Profit!

Hypotheses – Greatest challeng to any thinker is stating the problem in a way that will allow a solution Bertrand Russel

Test explicitly exposes solvable problem and confirmation. Harder than writing a solution. More time,

All testing in some sense – switching over to TDD – make code better.

Black-box testing. Outside in, refactoring should make no difference.

We owe it to ourselves and our profession to prompte automated testing. Having this culture.

Crazy ideas would like to see –

  • Javascript in Ruby (exists, but crazy).
  • Automated tests for HTML/CSS
  • CPAN tester network for gems

Good testing ==== public shame

Won’t run gems without tests.

Tests are professional – respectful enough of their code to document in code.

All work in topic branch – git pull requests. Code coverage done through review.

Git the stupid NOSQL database

Rick Olson

Github use it more like a database.

git hash-object

(what?)

Send some JSON into a file and get it out again – crazy.

Git also a graph database – Nodes to nodes

Tree – subdirectory of blobs

git update-index
git write-tree

commit-tree

refs (not an object, a tag/pointer)

tags

2 types – lightweight, branch pointer to sha, annotated tags object that points to a commit w custom tag message who/when

gem install grit
gem install gollum

Local wiki clone of the one in git

Hmmmm – git grep

Latest files updated atom feed

diff-tree —name-only master~10 master

Need to know how many commits or will errir

Gollum suited for small to medium projects.

Smoke is grit on the cloud – proxies out to Erlang services.

Rails Admin, The right way of doing data administration

Bogdan Gaza, @hurrycane

Rails Admin Ruby Summer of code 2010

Way you organise & control your data

Admin panels – PITA

Simple, secure & fast – custom error prone not fast or simple.

CMS? Simple but not always flexible. Rails Plugin/engine, usually secure fast & simple

Choices:

  • lipsiaAdmin (R2) ExJS
  • Active Scaffold (R2)
  • Hobo (R3) includes a lot of non-admin stuff

RailsAdmin sferik/rails_admin

Port Merb-Admin to R3. Merb slice/R3 engine, structure pretty much the same.

Engines similar to plugins, but work like Merb slice.

Namespaced controller/model/routes. Mountable app outside Rails structure

gem ‘devise’
gem ‘rails_admin’, :git => ‘git://github.com/sferik/rails_ad,in.git’

bundle update

rails g rails_admin:install_admin

Not using devise? Override or use another warden-based solution.

authenticate … and current_user

3.1 it will be mountable.

Automatically adds history and search

Will be the admin panel of choice in future.

Seecodez – a code review manager

Seecodez is a project I’m working on in amongst the million other things I’m doing at the moment. I’ve decided to set up a Rails 3 project on my little Evo machine that I can take with me and work on when I’m waiting for things. I use the Evo rather than my MacBook when I don’t want to lug the damn thing about or worry about it getting stolen as the Evo only cost me a few quid.

It’s interesting but you can run Ruby 1.9, Rails 3, Emacs and Google Chrome on an old Pentium 3 with 512MB RAM. It’s not particularly slow, but I am running Ubuntu and not some Microsoft excuse for an operating system.

Discovered that Rails won’t run without open SSL installed on Ubuntu. This is a problem I’ve been through before with Ruby 1.8.6 about a million years ago.

Anyway, I’ve defined my first model. Now need to write some tests and start homing in on the functionality I want.

Progress of a sort.

Moving to a Rails-based blog engine, Enki

Blog City, who used to host this blog, decided that they’d had enough but didn’t seem to tell anyone who had a subscription that was about to lapse. Thanks guys, I’ve been a customer of yours for over 7 years!

I was planning on moving to another site eventually, but not right now because I’ve got too much to do. I was concerned that I was going to lose all that effort, and potentially useful stuff. So went into panic stations mode (I suppose) because I just wanted to get it done and move on to something else.

In the end I did some Unix shell hacking and pulled all of the entries through into a format where I could load them into a Rails application of my choice. I decided to use Xavier Shay’s Enki – it’s minimalist, but there’s enough there to get up and running quickly and it does comments and pages out of the box, which is pretty damn cool. The old blog posts are all now pure HTML and the comments are missing, sorry.

Then the fun started. As it comes out of the box Enki won’t run on the Heroku servers because of some problem with the gems in the Gemfile. I messed about with this for ages and in the end went for the obvious solution.

  • Create an empty app with the latest Rails 2 (2.3.10) and see it deploys (tick)
  • Copy the migration and app files across and see it still runs (tick)
  • Copy in the plugins (tick)
  • Let ’er rip and see what gems she needs (tick)
  • Put those gems, and those gems only in the Gemfile (tick)

Thar’ she blows!

So I have a version of Enki that isn’t a fork, but a Heroku-friendly pulling across of the core files into 2.3.10. Good news is that moving from this to Rails 3 should be really easy, in fact it might even make sense to repeat the process but with a Rails 3 base. Bad news is that it isn’t a fork and I don’t know how to get it back into Xavier’s main code base.

Imported Comments:

Ruben Berenguel

Congratulations for your move. I have been watching it over twitter. I’m glad it worked out!

Cheers,

Ruben (from mostlymaths.net)