Less CSS

Ruby people really don’t like CSS do they? But Less is actually pretty cool. It’s basically an attempt to bootstrap features, specifically Variables, Mixins, Operations and Nested Rules, into CSS. The best part about this is it uses CSS syntax and a simple one step compiler. I’d be interested to know what the folks at the W3C think about this.

So for instance you can do:

pre. /* LESS */ brand_color: #4D926F; #header { color:brand_color; } h2 { color: @brand_color; }

and compile it down to:

pre. /* CSS */ #header { color: #4D926F; } h2 { color: #4D926F; }

Message Queues at Cambridge Geek Night

Last night was the first Cambridge Geek Night and saw 35 people or so fill a room above a pub to listen to a few short talks and converse with fellow geeks. I had the pleasure of giving the first talk, a short introduction to using message queues for web developers.

I got lots of good questions from interested people and by the sounds of things it had the desired effect - for people unfamiliar with using a message queue to go out and have a play with some of the cool software available to solve your problems.

Overall the night was definitely a success. Suitably geeky conversations. A chance to meet new people as well as old friends. Good job Vero and David for organising the event and here’s to the next one.

How to Decide on Your Next Programming Language

Neil Crosby got me thinking yesterday about which language to learn/play with next by tweeting

so, lovely people of the interwebs. What webly language should I be spending my time learning then? Right now, I’m all about the PHP.

Neil appears to have gone for Python, but more specifically I’m interested in how you decide what to learn next? And improving the likelihood of you seeing it through and being able to add it to you toolbox. Personally I’ve messed around with a wide range of languages but I would say I’m proficient in only a few of those.

So here goes with a list of questions to ask yourself.

  • Do you have a small pet project you can use the new language on straight away?
  • Is the language increasing or decreasing in popularity?
  • Does the language overlap with what you already know in terms of applicability?
  • Is it a different style of programming to what you’re used to? Say a pure functional language if all you normally do is object orientated.
  • Is the language in demand in the jobs market? If not why not?
  • Could you use the language in your current job if you were allowed to?
  • What are the learning materials like? Are there books or websites that teach the language without passing on bad practices.
  • What is the community around a language like? Do they have an IRC room where beginners can ask questions without being mocked?
  • Does the language have an interactive mode? Sorry but I find anything without to be a chore to learn.
  • What is it going to cost you in terms of time? Remember some languages are bigger that others.
  • What is it going to cost you in terms of money? Do you need specialist software, or hardware, or licenses?
  • Do you have friends or acquaintances who use the language and who will help you out with pointing you in the right direction of resources or helping review your code?
  • Do you have somewhere you can go to meet other people who write the language. That might be a formal user group or it might just be a more general pub meetup that you know a few people attend.
  • How is the language represented on GitHub? Seeing what other people build and being able to read working code is hugely useful when learning anything.

I don’t think all of these apply to everyone or apply all the time, but it’s worth considering and rejecting them when they don’t.

Feel free to disagree in the comments or, even better, add extra ones. Or alternatively just cut to the chase and tell me what I should learn next.

garethrushgrove.com update

I’ve updated my vanity domain at garethrushgrove.com with a bit of information in case anyone might be interested in my services.

my personal site

The short version is I’m on the lookout for future projects, probably of a freelance or contract basis but if it’s particularly interesting then maybe a full time position. Basically I’m in quite a nice position and able to wander about a bit looking for something cool to do.

If you reading this site then you know what floats my boat. Python, testing, automation, system design, maybe get into Ruby or another language properly, etc. I’d particularly like to help people get started with testing, continuous integration or automated deployment and the like.

Cambridge Geek Night

It’s the first Cambridge Geek Night next week, on Wednesday the 10th to be precise. You can find more information on Upcoming or on the Cambridge Geek Night blog. The event also has a twitter feed to keep up with goings on. If you’re in Cambridge you don’t want to miss the perfect combination of geeks and beer.

Testing WSGI Application with Urltest

I found myself wanted something to make writing high level, functional tests for WSGI application easier and quicker. If I liked the term I’d call it a domain specific language for testing URLs. Basically I found myself writing a lot of tests like:

pre. def test_404_handler(self): response = self.app.get(‘/does-not-exist’, expect_errors=True) self.assertEquals(“404 Not Found”, response.status)

Testing more than a view URLs like this got boring quickly. What I wanted was a short hand syntax for defining this sort of simple test and then running them all individually. So was born Urltest. It uses the rather nifty Webtest module and hooks into unittest from the standard library. You’re test script then looks a little like:

pre. #!/usr/bin/env python from example_app import application from urltest import verify_urls if name == “main“: urls = ( {‘url’:“/”, ‘code’:200}, {‘url’:“/bob”, ‘code’:200}, {‘url’:“/jim”, ‘code’:404}, {‘url’:“/jim”, ‘method’: “POST”, ‘code’:405}, ) verify_urls(urls, application)

Let me know if you use it as at the moment this is works for me ware, although it’s reasonably well tested and commented.

Another Glue Python Framework - MNML

Although still a big fan of Django, but for some problems I’m finding more and more cases where I prefer less code and more freedom. My biggest issue for some types of problems being Django’s assumption that you’ll be using a relational database, or a database at all. Django wasn’t the reason I started using webapp for App Engine stuff, but in doing so I found that webapp often did all that I needed.

So when I small, non appengine project cropped up I started looking at the different options available and played with a few of them.

  • I played with Pylons but again got lost in code. I’ll probably play with Pylons more in the future and for bigger, team based, projects it looks a good mix of component parts and shared conventions.
  • Web.py - I’d used web.py before I started with Django (I even wrote a very basic PHP clone) and although I still like somethings about it, it felt like more code than was required for what I wanted.
  • Juno is similar in design to Sinatra but again it wasn’t really what I was after this time. I prefer separating my routing from my code and I’m not sure I like that it comes with it’s own templating engine.
  • Newf was more like it. Basically a hugely stripped down WSGI framework which provides the very basic building blocks. Something to build on perhaps?
  • MNML (by an ex-colleague Brad Wright) is build atop Newf adding a few more features and cleaning up some of the interfaces. My only problems here were that I prefer regex based routes and wanted individual methods for each HTTP verb. The former was a specific design decision Brad had made in order to be able to reverse routes, the later was on the todo list.

So, I set about forking MNML to create my own branch. I added extra comments as I was making my way through the code, wrote a few tests to checks thinks worked and allowed for pluggable routing mechanisms. MNML applications look a bit like the following:

pre. from mnml import RegexBasedApplication, RequestHandler, HttpResponse, development_server class HelloWorld(RequestHandler): def GET (self): return HttpResponse(”

Hello World

“) routes = ( (r’^/$‘, HelloWorld), ) application = RegexBasedApplication(routes) if name == ‘main‘: development_server(application)

If you want to use the token based routing you would substitute in something like the following:

pre. routes = ( (‘/’, Foo), (‘/myview/:stuff/‘, Bar) ) application = TokenBasedApplication(routes)

The best bit is that it’s only about 350 lines of code, a great deal of which is accounted for by comments. It’s also really quite fast - especially using something like spawning to run the WSGI application. The other thing I like is the ease with which you can add WSGI middleware into the mix.

So, if you have a small scale problem where simple and fast beats everything else then have a look and let me know what you think. It will take less time to read the code and tests than it will be read the introductory chapter on whichever larger framework you choose to look at.

Beyond Basic Web Development

I did a talk at the recent barcamp North East on web development tools. Specifically I wanted to talk about the fact that an awful lot of people just use the basic stack of tools they are familiar with. So Microsoft people will just use C#, MSSQL and ISS and lots of people just use PHP, MySQL and Apache. I’m not saying their is anything wrong with those tools, but if they are all you have in your tool box you’re limited how well designed your software can be.

I’d knocked the presentation together in my hotel room pretty quickly before heading down to barcamp and the lack of an internet connection meant I didn’t have links and didn’t cover a few tools I should have. It did seem to have the desired result in any case as several people spoke to me afterwards about wanting to use one of the tools I mentioned for something specific.

We also had a good discussion afterwards and people mentioned a few other tools.

Now it’s possible to spend too much time playing with small tools that are likely to be peripheral to the bulk of your application. But the number of stories I’ve head of people writing their own messages queuing systems in PHP, or using PHPMyAdmin as an application admin interface or ignoring the fact that their fancy new application only supports a few people at once.

Universal Internet Explorer 6 CSS and different types of sites

Andy Clarke, as only he can, has started something of a slagging match with his proposals for a single, central IE6 stylesheet. My first impression was that this is basically a much better version of the browser defaults.

Between backslapping and shouts of heresy there are a few good comments floating on the post so far (I’d expect more). But most of them seem to assume only two types of website exist:

  1. Websites for clients. You know, business to business or business to consumer sorts of things. Online stores, radio station websites, newspapers, company brochures, etc.
  2. Personal blogs

Obviously that covers only a fraction of web pages, but it covers a much larger proportion of web sites. What do I mean by that?

  1. Admin interfaces. Available all over the place and often used by a very small number of people.
  2. Intranets. If your company default browser isn’t IE6 then don’t spend more time that you have to supporting it.
  3. Internal application interfaces. Everything from holiday to payroll to IT helpdesk requests are often built as well apps. Again if the audience using them isn’t using IE6 then don’t waste you’re time.

Most people (ok so this might be my opinion) seem to work within small to medium sized agency style places. Smallish companies need to rely more on employees as part of their marketing effort, younger people tend to be more militant and people working for smaller organisations (like Andy) tend to benefit more from a little celebrity. But that ignores an army of people who work in house or in other types of company that just happen to build top notch web sites or applications. I’ve now worked in everything from small agencies, via medium sized agencies to freelance and inhouse. They are all different and all place different types of time pressure on the people involved.

Another argument to be had here is summed up by Sion (http://twitter.com/sionnnn/status/1872141409)

if u write code with all browsers in mind from the offset it doesn’t take any longer though? hows that commercially unsound?

And this is pretty much how I used to work. But this means ignoring whole swathes of the unsupported parts of CSS2 and in particular CSS3. CSS3 doesn’t really allow you to make designs that you couldn’t make before (ok, that’s a little unfair, maybe) but it does allow you to do what you did before much more efficiently. Multi-column layout stuff, multiple background, rounded corners, opacity, RGBa. Smaller stylesheets are easier and quicker to write, test and maintain. And sometimes the time saved is worth more than the additional overhead of writing and maintaining CSS for IE6. Maybe not for a decent sized consumer project with a reasonable team and a few hundred thousand budget. Maybe not for a local council or government site. But for a surprisingly large range of other types of projects this might be a worthwhile approach.

Something else I think that comes through in many of the comments is that it’s often seen as the web designers job to fight for things. So we fight to ensure time is spend on making something accessible. We fight to make sure we use valid code wherever possible. We fight for sensible fallbacks when javascript isn’t available. But we also get accused of not being able to see both sides and at times being unrealistic. Worth considering with regards peoples initial reactions to this, mine included.

The only thing I would say to anyone looking to use this is don’t create your own version. Use the one from google code. As Andy suggests, do suggest improvements, ideally by making the changes yourself presumably along with a solid test case. The time saving benefits basically disappear if we all have to maintain our own versions, before that means we have to test our own versions.

I’m not saying ignore IE6, and neither is Andy (I don’t think). I’m saying pick your battles. I’ve build websites to support everything under the sun. Sometimes it’s been absolutely the right thing to do, sometimes in hindsight it’s probably been a little bit of wasted time. I’m sure you can think of similar times from the sites you’ve been involved in.

Back in Toon - Thinking Digital

After what seems like longer than a year I’ve finally managed to make it back up to Newcastle. It’s the Thinking Digital conference again this year and so far it’s been a hoot. A mix of practical, inspirational and just odd speakers (and acts) suits me pretty well. Lots of twitter activity too.

The highlights for me so far I think has been Dan Lyons talking about the future of media and print businesses. Basically a somewhat rambling attempt to describe where newspapers and print publications find themselves in this day and age (in trouble) and where they might head for salvation (either dumbing down or becoming more exclusive/expensive). Throw in interesting stories and anecdotes, the odd joke and some personal thoughts on the future for journalists and everyone’s happy.

An honorable mention goes to Johnny Lee Chung as well for showing off drag and drop between a laptop and a table. Oh, and everything else has been pretty interesting as well and it’s not even the end of day one yet.

I’m around until next week too, which means I should be able to get along to barcamp - assuming my mind hasn’t melted with all the stuff to take in.