Christian Heilmann

You are currently browsing the Christian Heilmann blog archives for February, 2012.

Archive for February, 2012

[watching] Salman Khan: Let’s use video to reinvent education

Thursday, February 23rd, 2012

Lately I got into watching TED movies in the gym (free video podcast, 20 minutes, perfect length for a crosstrainer session). Today I checked out Salman Khan’s introduction to the Khan academy and its beginnings:

All in all a great talk and I am a big fan of the Khan academy as a way to give a kick up the backside of education. As Salman explains in the video, most of the time of teachers nowadays is wasted on not interacting with the students. Instead, we apply a “one size fits all” approach to teaching that leaves a lot to be desired and a lot of students in limbo of knowing things. We teach to measure, not to bring knowledge.

What annoyed me about the talk was how US centric it was. Whilst I agree that education is a big issue in the US (which is very ironic seeing how prosperous the country depicts itself) I think a project like that could have even more impact in areas where education is not free and easy to come by. Instead of fighting a system that happily stays inefficient (as it means not learning new things, ironically) this could be a blueprint for areas where you can start from zero.

Khan talks about this briefly at the end explaining that a street kid from Calcutta could watch these movies at night as it needs to work during the day to make money for its family instead of going to school. That makes no sense whatsoever to me. If the family is too poor to have food then surely they won’t have money for a computer and a fast enough connection to see these movies – let alone have the computer literacy for it.

This could work immensely well if Khan academy and others would start facilities like that. Have public libraries and buildings with computers and a connection (this could be chrome books) where people can go and learn. I could see internet cafes world-wide dedicating one sponsored computer to Khan teaching for example.

Saying the content is available to all is not enough – we need also to make the system available. There is already a good start being made by subtitling the videos in other languages. Fun ahead. I think I sign up as a volunteer there.

A quick one: (ab)using mediaqueries to not serve CSS to IE < 9

Wednesday, February 22nd, 2012

I am right now writing a post on how to use :target selectors for image galleries. As always, older IE are the fly in the ointment there as only IE9 supports the selector. So I thought about a way to serve the CSS only to the browsers in the know. The options were of course conditional comments, adding a selector IE < 9 doesn’t understand to every selector I want to filter out (like using
body:last-child article the same way we used html>body to filter out IE6) but then it came to me: media queries are only supported in IE9 and above. So you can simply do a:

.foo {
  // ... styles for ALL THE BROWSERS
}
@media screen and (min-width: 400px) {
  .foo {
    // ... styles for newer browsers
  }
}

A test of a 400 pixel wide browser window should be more than enough, right? Discuss on Google+

A web in HTML5 canvas

Tuesday, February 21st, 2012

Whenever there is an open forum to discuss HTML5, you get very interesting questions. Sometimes you also get ones you just facepalm to. One of them was yesterday on Facebook where someone wanted a “simple web in HTML5”. As I was bored watching “revenge of the sith” I thought I give it a go. So here you go – a simple web in HTML5 canvas.

How is this done? Pretty simple actually, I just define one segment of the web in canvas:

var c = document.createElement( 'canvas' ),
    cx = c.getContext( '2d' ),
    angle = 0;
document.body.appendChild( c );
c.width = c.height = 400;
cx.lineWidth = 3;
cx.translate( 200, 200 );
cx.moveTo( 0, 0 );
cx.lineTo( -30, -200 );
cx.quadraticCurveTo( 0, -170, 30, -200 )
cx.lineTo( 0, 0 );
cx.moveTo( -25, -160 );
cx.quadraticCurveTo( 0, -140, 25, -160 )
cx.moveTo( -18, -120 );
cx.quadraticCurveTo( 0, -100, 18, -120 )
cx.moveTo( -12, -80 );
cx.quadraticCurveTo( 0, -60, 12, -80 )
cx.moveTo( -6, -40 );
cx.quadraticCurveTo( 0, -30, 6, -40 )
cx.stroke();

I translate the context of the canvas to the centre of the 400×400 pixel canvas and start painting the lines. I paint one line from 200/200 (which now is 0/0 as the translation happened) to – 30/- 200 which is the top left. I then paint a quadratic curve to the top right of the segment (30,-200) with the curve point being in between the two. I then move the canvas “pencil” to the other points on the left and draw quadratic curves to their counterparts. All of these I set with trial and error – I am sure there is a clever algo to do this, but this works.

In order to achieve the web effect all I had to do was to rotate the canvas before painting each segment. I increased the angle by 18 degrees on each iteration and rotated the canvas in radians:

var c = document.createElement( 'canvas' ),
    cx = c.getContext( '2d' ),
    angle = 0;
document.body.appendChild( c );
c.width = c.height = 400;
cx.lineWidth = 3;
cx.translate( 200, 200 );
for ( angle = 0; angle <= 360; angle += 18 ) {
  cx.save();
  cx.rotate( angle * Math.PI/180 );
  cx.moveTo( 0, 0 );
  cx.lineTo( -30, -200 );
  cx.quadraticCurveTo( 0, -170, 30, -200 )
  cx.lineTo( 0, 0 );
  cx.moveTo( -25, -160 );
  cx.quadraticCurveTo( 0, -140, 25, -160 )
  cx.moveTo( -18, -120 );
  cx.quadraticCurveTo( 0, -100, 18, -120 )
  cx.moveTo( -12, -80 );
  cx.quadraticCurveTo( 0, -60, 12, -80 )
  cx.moveTo( -6, -40 );
  cx.quadraticCurveTo( 0, -20, 6, -40 )
  cx.restore();
}
cx.stroke();

And that’s that – a web in HTML5 canvas.

Stumbling on the escalator

Thursday, February 16th, 2012

I am always amazed about the lack of support for progressive enhancement on the web. Whenever you mention it, you face a lot of “yeah, but…” and you feel having to defend something that should be ingrained in the DNA of anyone who works on the web.

Escalator

When explaining progressive enhancement in the past Aaron Gustafson and me quoted the American Stand-Up comedian Mitch Hedberg and his escalator insight:

An escalator can never break – it can only become stairs. You would never see an “Escalator Temporarily Out Of Order” sign, just “Escalator Temporarily Stairs. Sorry for the convenience. We apologize for the fact that you can still get up there.”

This is really what it is about. Our technical solutions should be like escalators – they still work when the technology fails or there is a power outage (if you see CSS animations and transformations and transitions and JavaScript as power) – but they might be less convenient to use. Unlike real world escalators we never have to block them off to repair them.

We could even learn from real-world escalators that shut down when nobody uses them for a while and start once people step on them. On the web, we call this script loading or conditional application of functionality. Why load a lot of images up front when they can’t be seen as they are far away from the viewport?

An interesting thing you can see in the real world is that when an escalator broke down and became stairs people stumble when they enter it. Our bodies have been conditioned to expect movement and our motor memory does a “HUH?” when there isn’t any.

This happens on the web as well. People who never were without a fast connection or new and shiny computer or phone with the latest browsers have a hard time thinking about these situations – it just feels weird.

Travelator

Another interesting thing are the horizontal walkways you have in airports. These are meant to accelerate your walking, not replace it. Still you find people standing on those complaining about their speed.

On the web these are the people who constantly complain about new technology being cool and all but they’d never be able to use it in their current client/development environment. Well, you don’t have to. You can walk in between the walkways and still reach the other side – it just takes a bit longer.

So next time someone praises flexible development and design practices and you have the knee-jerk reaction to either condemn them for not using the newest and coolest as “everybody has a xyz phone and browser abc” or you just don’t see the point in starting from HTML and getting to your goal re-using what you structured and explained in HTML as “GMail and Facebook don’t do it either” think about the escalator and how handy it is in the real world.

Think about it when you are tired (accessibility), or you carry a lot of luggage (performance) or when you just want to have a quick chat whilst being transported up without getting out of breath. Your own body has different needs at different times. Progressively enhancing our products allows us to cater for lots of different needs and environments. Specialising and optimising for one will have a much more impressive result, but for example a lift is pointless when it doesn’t work – no matter how shiny and impressive it looks.

Our job is to make sure people can do the things they went online for – get from their start to their desired goal. This could be convenient and fast or require a bit of work. Our job is to make sure that people do not get the promise of a faster and more convenient way that fails as soon as they try taking it.

You can comment on Google Plus if you want to.

jQuery UK conference in Oxford, England – slides, audio, impressions and notes

Saturday, February 11th, 2012

Yesterday I attended the jQuery UK conference in Oxford, England where about 300 developers gathered to hear the newest and coolest about probably the most successful JavaScript library out there.

Naturally I thought it a good idea to give a talk that they shouldn’t use it. Well, more to the point that it is not necessary to use jQuery for everything out there and that there is quite a lot of redundant use of it. jQuery showed browser makers what developers want and browser makers listened. A lot of the initial concepts of jQuery – accessing the document via CSS selectors rather than the DOM and simplifying the handling of CSS classes are now natively available with querySelector, querySelectorAll and classList.

Slides, notes and audio

You can read the slides with notes online or embedded below (left+right to go back and forward, down for next bullet point and N to toggle notes):

As always I also recorded my talk and the audio is available on archive.org, soundcloud or embedded here:

The feedback was overwhelmingly good, and I am very happy that I dared to be different and didn’t get vegetables thrown at me.

My general impressions of the conference

As the first European (or UK?) jQuery conference I can safely say it was a massive success. The success of a conference very much depends on the passion of the organisers and the group behind this one has passion to spare. You always knew where to go and got help immediately if you didn’t.

The event was run professionally without pestering attendees with unnecessary communication (“Please fill out this survey”) and the venue was incredible. The lecture hall had power plugs and ethernet connectivity on the seats and the wireless stood up (probably because of the ethernet option).

The food was sandwiches, fruit and cookies – more than enough for a single day – and the fermented beverages at the party were bountiful. There were lots of giveaways for the audience (Playbooks, T-Shirts, books, awesome Firefox stickers, Tequila bottles and Kendo sticks).

As a one-track conference, they invited too many speakers which is why the speaking slot was 30 minutes. This at first threw me a bit but in hindsight it went really well and gave the conference a much better flow. There was no moment of boredom.

The audience was very good and the Twitter backchannel buzzing and very creative and observant. The vitriol and trolling attempts you find at other conferences was not happening at all – great stuff. Instead people created awesome doodles and live-blogged the sessions on GitHub(!). The low number of female attendees was a bit of a surprise to me – I’d expected more at a jQuery conference.

Some quick notes on the talks

Some speakers asked me about feedback and I am happy to give some more in person and detail (contact me again, please), but here are a few impressions I got from the talks I saw.

  1. Conference organiser John Wards started the day with the necessary housekeeping and explaining the day – the main shock there was to go to Oxford to hear a strong Scottish accent on stage first thing (memories of Highland Fling?)
  2. Ralph Whitbeck followed up with a report on the state of the jQuery project – the only predictable talk, delivered informatively and keeping the audience on the ball
  3. Todd Parker then explained the ins and outs of jQuery Mobile in my favourite talk of the day. Engaging, funny and full of goodness in terms of best practices I very much subscribe to, too (progressive enhancement, real hardware testing…)
  4. Fellow Ajaxians Dion Almaer and Ben Galbraith followed with a longer talk on Web vs. Apps discussing the benefits of the web as an application platform and how far we are from matching the native experience. Ben and Dion work very well together on stage and had some interesting insights.
  5. Jörn Zaefferer talked about the pitfalls of single page applications. Despite being nervous, he managed to give a good idea about the necessary steps to deliver one of those without breaking the web experience
  6. Haymo Meran of Aloha Editor showed how the editor works and explained the problems of using and implementing contentEditable in the browser and stay accessible. He also used the opportunity to release Aloha WikiDocs, a collaborative live editable wiki
  7. Paul Irish talked about the App development stack for JS developers covering the whole range from preprocessors to developer tools in Chrome previewing the upcoming remote debugging and sourcemapping. Lots of great content there – maybe too much for one talk, but I am sure the (very elaborate 3D effect ladden) slides will help us digest a lot of that.
  8. Addy Osmani talked about building large-scale applications with jQuery covering a few of the architectures followed in larger libraries like YUI and Dojo and explained a few patterns to use and patterns we already do use without knowing it. Again, a bit too much to digest in a half hour talk, but lots of good stuff to dive into
  9. Doug Neiner finished off with Contextual jQuery explaining a lot of great tips on how to create lighter, more responsive jQuery solutions by applying functionality when it is needed and not upfront. A very interesting talk full of pragmatic goodness

All the talks were filmed and will be released in the nearer future.

Thanks

All in all I am very happy to have attended the conference and hope there will be more by these organisers. I was the first speaker asked (imagine my surprise given that I hardly have anything to do with jQuery) and I have to say thanks – it was a great experience.

You can comment on Google+