Random Thoughts
Thursday, 25 April 2013
Sunday, 21 April 2013
Libraries and Frameworks
The past few weeks I've been implementing a stock trading interface for cell phones. I thought I'd give jQuery Mobile a whirl. It looked quite nice in the demos, at least, and I was curious.
jQuery Mobile promises that the pages will look app-ey, and will work on iPhones, Androids and Windows Phone 8 devices. This turns out to be true. It works.
The main idea with jQM (as the kids today call it) is that you generate very standard HTML, and then you point jQM at the HTML. jQM then transforms the HTML into... more complicated HTML. This usually means that an <a> element is turned into an <a> element with three divs nested outside it, and four <span>s inside it. Or something. To get the proper styling and rounded corners and everything nice.
And it works. You write a minimal web page with <a>s, and as by magic, it turns all app-ey.
After working with it for a week or so, I had most of the stuff working. You could enter orders and get real-time quotes. But there were niggling bits that were just ugly.
iPhone would "flash" the address bar on page transitions. The only way to make it stop doing that is apparently to not use <a> elements. So I generated (nested) <span> elements that I instrumented from Javascript to do the right thing. Success!
Then I discovered that if I put in a jQM dialogue box, it doesn't just display it -- it ejects the previous page from the browser, so that if you hit the "cancel" button, it reloads the previous page. That just doesn't work on complicated order entry pages, where the user may be in the middle of something. So I wrote my own dialogue popup thing. Success!
jQM keeps three "pages" in the DOM at all times, so that it can do fancy transitions. This means that if you have elements that use document.getElementById(), they may stop working if you're unlucky enough that any of the pages happen to have elements with the same ID in them. So either rewrite all the code to use "class" instead of "id", or alter the page cache to prune selected pages from the DOM so that this doesn't happen. So much. Er... success?
So this is what I'm bitching about:
When you start working with a new library, you usually doesn't have a very good overview of what it provides, so you write un-idiomatic code. As you get more confident in how it works, your code grows better, clearer, shorter and more idiomatic.
With frameworks like jQuery Mobile, you start off with something that looks like the demo app, totally idiomatic. Then you discover that it doesn't quite do what you need, so you add more and more hacks to get around the framework. The code grows less and less idiomatic, and uglier and bigger and more complicated.
It's like there's a separate tribe of Frameworkers that put all their effort into making the Demo App like two lines of code. If you want to do something a teensy bit outside of what was intented, you end up writing 10x as much code as you would have done without the framework.
It's pretty annoying. By this point, the remaining bits of jQM that I'm actually using is pretty small. I've mainly crabbed a lot of the (quite pretty) CSS declarations, and use some of the page transitions stuff, and the rest is hand-rolled. The code would probably get shorter if I ejected jQM completely.
*sigh*
jQuery Mobile promises that the pages will look app-ey, and will work on iPhones, Androids and Windows Phone 8 devices. This turns out to be true. It works.
And it works. You write a minimal web page with <a>s, and as by magic, it turns all app-ey.
After working with it for a week or so, I had most of the stuff working. You could enter orders and get real-time quotes. But there were niggling bits that were just ugly.
iPhone would "flash" the address bar on page transitions. The only way to make it stop doing that is apparently to not use <a> elements. So I generated (nested) <span> elements that I instrumented from Javascript to do the right thing. Success!
Then I discovered that if I put in a jQM dialogue box, it doesn't just display it -- it ejects the previous page from the browser, so that if you hit the "cancel" button, it reloads the previous page. That just doesn't work on complicated order entry pages, where the user may be in the middle of something. So I wrote my own dialogue popup thing. Success!
jQM keeps three "pages" in the DOM at all times, so that it can do fancy transitions. This means that if you have elements that use document.getElementById(), they may stop working if you're unlucky enough that any of the pages happen to have elements with the same ID in them. So either rewrite all the code to use "class" instead of "id", or alter the page cache to prune selected pages from the DOM so that this doesn't happen. So much. Er... success?
So this is what I'm bitching about:
When you start working with a new library, you usually doesn't have a very good overview of what it provides, so you write un-idiomatic code. As you get more confident in how it works, your code grows better, clearer, shorter and more idiomatic.
With frameworks like jQuery Mobile, you start off with something that looks like the demo app, totally idiomatic. Then you discover that it doesn't quite do what you need, so you add more and more hacks to get around the framework. The code grows less and less idiomatic, and uglier and bigger and more complicated.
It's like there's a separate tribe of Frameworkers that put all their effort into making the Demo App like two lines of code. If you want to do something a teensy bit outside of what was intented, you end up writing 10x as much code as you would have done without the framework.
It's pretty annoying. By this point, the remaining bits of jQM that I'm actually using is pretty small. I've mainly crabbed a lot of the (quite pretty) CSS declarations, and use some of the page transitions stuff, and the rest is hand-rolled. The code would probably get shorter if I ejected jQM completely.
*sigh*
Friday, 5 April 2013
Further Non-Legal Developments
I didn't really pay attention, but I think this is about "lies" being told about something called "WorldComp"? Anyway, I'm apparently being sewed again because of somebody wanting to have stuff removed, but not being willing to ask the list admins to ask me to have it removed.
So much drama. I'm swooning all over the place.
So much drama. I'm swooning all over the place.
Sunday, 31 March 2013
Friday, 22 March 2013
Wednesday, 20 March 2013
1995: Den store sledereisen
Or "The Big Sled Ride", by Knud Rasmussen.
My mother gave me this book in 1995. It had been one of her father's favourite books.
My grandfather lived even more way to the north of Norway than I did. He was a fisherman, going out on the northern seas in his boat. Fishing... some kind of fish. I guess. He died when I was ten-ish, so I don't really recall all that much about him.
I remember going fishing with him in the stream that ran along the valley a few farms inwards from his house. I don't think I caught anything.
And I remember him regaling us with stories about going hunting seals on the ice around Spitsbergen. Especially the story about the adult male, er, hooded seal?, that wasn't quite dead and ... did... something. Ok, I may remember him telling these stories, but I don't quite remember the stories themselves. I think the seal mangled or killed somebody. Possibly him.
I suck.
Anyway, this book is a Danish book written in the early 20s, detailing a dog sled ride across northern Canada, all the way from Greenland to Siberia. But it's really more about the eskimo (as he calls them) peoples he encounters along the way.
He's an ethographer, and gets the people he meets to tell him oldee-timey stories and legends, as well as stories about themselves. He's very enthusiastic about everything! And uses lots! Of exclamation marks! But he's a very sympathetic character, who always tries to see things from the eskimo's side, which might have been more of a stretch in the 20s than now.
Many of the stories they tell are of joy and contentment, but there's also the occasional cannibal story, lots of murders, and a ton of girl infanticide. It's not all rosey, but Knud remains firmly on the side of the eskimos.
Rating: Inuitiffic
My mother gave me this book in 1995. It had been one of her father's favourite books.
My grandfather lived even more way to the north of Norway than I did. He was a fisherman, going out on the northern seas in his boat. Fishing... some kind of fish. I guess. He died when I was ten-ish, so I don't really recall all that much about him.
I remember going fishing with him in the stream that ran along the valley a few farms inwards from his house. I don't think I caught anything.
And I remember him regaling us with stories about going hunting seals on the ice around Spitsbergen. Especially the story about the adult male, er, hooded seal?, that wasn't quite dead and ... did... something. Ok, I may remember him telling these stories, but I don't quite remember the stories themselves. I think the seal mangled or killed somebody. Possibly him.
I suck.
Anyway, this book is a Danish book written in the early 20s, detailing a dog sled ride across northern Canada, all the way from Greenland to Siberia. But it's really more about the eskimo (as he calls them) peoples he encounters along the way.
He's an ethographer, and gets the people he meets to tell him oldee-timey stories and legends, as well as stories about themselves. He's very enthusiastic about everything! And uses lots! Of exclamation marks! But he's a very sympathetic character, who always tries to see things from the eskimo's side, which might have been more of a stretch in the 20s than now.
Many of the stories they tell are of joy and contentment, but there's also the occasional cannibal story, lots of murders, and a ton of girl infanticide. It's not all rosey, but Knud remains firmly on the side of the eskimos.
Rating: Inuitiffic
Subscribe to:
Posts (Atom)