The Web is a great, big, polished turd

Web development isn’t fun anymore. It used to be that you picked a server-side language, typed up some human-readable HTML, sprinkled it with a little bit of JavaScript to improve the user experience, and your job was done. These days it has become an all-you-can-eat buffet of overlapping frameworks, many of which don’t play nicely together, which you are almost blackmailed into using in order to fix problems or deal with a particular web browser, that is, if you’re not lucky enough to use something like Ext JS which takes care of all these hassles.

This past couple of weeks I’ve had to research using web components for a new project. “Keep calm and #UseThePlatform” it says on their web site. So what are they?

Web components are a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Custom components and widgets build on the Web Component standards, will work across modern browsers, and can be used with any JavaScript library or framework that works with HTML.

Sounds promising. Web components are not like your dime-a-dozen widget library and are supposed to be the future of user interfaces on the web. So I read some more and pretty soon it becomes clear that Polymer is probably the right way to go. Somewhere along the way I came across somebody who said that Polymer is to Web Components what jQuery is to JavaScript. It basically makes it easier to write Web Components and cuts down on all of the boilerplate code you have to write; that’s all I need to know.

The use case that I was given involves a simple web service call to search for records and display them in a grid. Easy. I’ve been doing that kind of stuff for almost two decades now, so this shouldn’t be much trouble at all. By a country mile, the only grid worth using if you want to create a custom element (another term for these things which means that I’m creating my own, reusable HTML tag, such as <my-awesome-tag>) is the one from Vaadin. This blog post is already becoming a rambling mess, so I’ll cut to the chase here and say that I couldn’t get version 2 of their grid to work with my Polymer 2 custom element, so I had to install version 3.0.0-beta1 (which works perfectly fine except that it hangs Internet Explorer 11 if you tab into the grid; I can see that beta1 has been pulled and only the 3.0.0-alpha2 version is available again, maybe because of this bug?). No biggie, they’re bound to fix it eventually which shouldn’t stop me from continuing my research.

Within a few days I created a magical web component which fired a custom event when the user selects a row (so that anybody who uses <my-awesome-tag> can add an event listener to handle it). I also set up data binding between my element and an input box which automatically sends requests to my web service whenever the query parameter changes, thereby updating the grid with new records seamlessly. Wonderful! Web Components really are the future of the web. There’s only one problem – I use Chrome as my web browser because it’s the fastest (especially when it comes to testing apps heavily dependant on JavaScript, such as Ext JS). Does it work in Internet Explorer 11?

No. All this time I had been coding away happily in a version of JavaScript that this nearly four-year-old browser does not understand. Just great! Polymer 2 uses the sixth edition of JavaScript, variously known as ECMAScript 2015 or ES6 [read this if you’re really bored]. If you want to use Polymer 2 components in IE 11 you have to transpile ES6 down to ES5 and serve up the former only to newer browsers (Firefox, Chrome, and Edge 14+) and the latter to all versions of IE and earlier versions of Edge. Yay! I get to experience the delights of browser sniffing (you could just serve the ES5 transpiled bundle to all browsers, including Chrome which supports Web Components natively, but you would need to include the custom-elements-es5-adapter.js shim, which just seems nasty; I’d rather do browser sniffing so that Chrome can fly and only IE suffers).

After getting that sorted, I turn my attention to getting this custom element to work from within an Angular app. You could do entire apps in Polymer but that would require a bit more work and Angular had already been chosen as the other framework for this new project anyway (not by me). So I start learning and find that Angular and Polymer both are projects by developers at Google with a lot of similarity, but one is playing the short game and the other a long game. Angular does its own thing whereas Polymer tries to adhere to standards (or specifications which eventually will become standards and supported by all browsers one day).

As I type this rant at home on a Friday night I’m trying to recall the arduous journey I’ve taken this week so that I can fully document the experience for everyone’s amusement. I can’t recall the finer details of the problems I had trying to get my Polymer 2 component to work with Angular 2, but my console was full of indecipherable errors and I soon realised that the two don’t play nicely together; I would need some assistance from @codebakery/origami and would have to upgrade to Angular 4. I suppose I should have started taking notes by this time because the journey was truly becoming tragic, but I couldn’t get Origami to work either, and my search for some other options came up empty handed. I decided to admit defeat and declare that I could not get Web Components to work with Angular.

If I was asked to evaluate Web Components specifically instead of any other widget library then there must have been a good reason, and my research lead me to the view that they might just be the holy grail of user interfaces on the web, so maybe Angular was the problem? I soon found this excellent summary of a talk by Rob Eisenberg comparing AngularJS, Angular 2, Aurelia, Ember, Polymer and React. Rob once worked at Google on Angular but eventually left over disagreements about the direction it was taking (and after my brief exposure, I began to see why: it’s over-engineered and would lock you in to using Angular for everything). The recommendation at the end piqued my interest in Aurelia: it doesn’t get in your way, supports web components, high performance, clean syntax (Angular 2 is just ridiculous!), standards compliant, and great if you’re a good developer.

I saw mention of Aurelia in some tech news article once but dismissed it out of hand, thinking to myself “yeah, yeah, another framework… yawn”. The Quick Start guide is probably one of the best such articles I’ve ever seen and the more detailed tutorial did not disappoint. The page describing its Technical Benefits seemed to tick all the boxes, too. I proposed to my colleagues that we should abandon Angular and use Aurelia instead, and after a little hesitation, they went along with it.

Another day, another framework to learn. Never mind, this one finally does seem like it’s worth my time, so I got stuck in and had a good time learning it. I then try to integrate my Polymer component with it and after a few issues (mainly surrounding me learning a new framework; nothing is ever easy!) it seems to play nicely enough. I was surprised that it seemed to “just work”. Great. Time to test it in Internet Explorer 11. Computer says no and I even served up the ES5 version just to keep it happy. I didn’t realise straight away that Aurelia even had a seemingly well documented article on Integrating Polymer components which I didn’t notice originally (there was a lot of stuff on the Internet, albeit slightly out of date, asking about Aurelia/Polymer integration which suggested it wasn’t officially supported yet, so that was my bad for not thoroughly browsing the docs).

My project directory already had about 120MB in my node_modules and bower_components directories from using npm and bower, but in order to get Polymer to work with Aurelia I had to also start using JSPM. This added another 50MB to my project, thank you very much! I have to call System.import(‘aurelia-bootstrapper’) after the WebComponentsReady event, but my project was created using the Aurelia CLI meaning that my app is started with a simple script tag pointing to scripts/vendor-bundle.js and wasn’t using the System.import method. My attempts to load the vendor-bundle that way didn’t work and when I tried to create a link element in vanilla JavaScript and append it to the DOM myself after the WebComponentsReady event had fired, I got a blank page in my browser and no errors at all. Well, that’s just great. Aurelia should update that Polymer integration document to explain how to kick-start your app if you’re using a production build and not the System.import quick start method.

By this stage the day was getting on and it being Friday, I thought, “enough is enough”. I don’t need this shit. Aurelia is nice and all, but I shouldn’t have to subject myself to this much torture just because Internet Explorer 11 has to be the default browser because of some shitty, over-priced, corporate application which only works if IE is set as the default browser, and of course, asking people to go into IE only for that shitty app and to use Chrome or Firefox for everything else just won’t do, now, will it?!

Sadly, this is what web development has become today:

Peter Griffin fighting with the venetian blinds

Being a web developer in 2017 and having to support Internet Explorer 11 is like a chef having to go dumpster diving for food to cook and being forced to serve it in a dog bowl.

I really don’t care any more. Let’s just use Angular for everything and be done with it. We can’t have nice things if people insist on using a web browser that’s almost four years old.

I’ve had the kind of week that only chocolate and ice cream can fix, and maybe binge watching a new TV series, too; I still haven’t watched the latest seasons of Fargo or Better Call Saul. That sounds like a plan to make everything better :-)

Coding on Apple is still a love/hate relationship

So, it’s been almost two years since I posted anything here, and it’s just over two years (almost to the day), since I last had a good whinge about XCode. It has only been laziness that has kept me from spewing much guts here about all kinds of annoyances.

So, I’ve been learning Swift for the past year, and whilst it was long overdue, it’s only the language part of the equation. The Cocoa API is still a nasty piece of work; give me the .NET Framework and C# ANY DAY (except if that means I have to use Windows at home; sorry, but I can use it at work writing web services and such like, but I’m not letting that operating system near my computer at home).

So, here’s what drove me mad about XCode/Swift/Cocoa today:

I used to have a drag/drop connection between a combobox and a class to handle the selection change event. That worked fine, however, when I modified it to also handle updating something as the user typed each letter in the combobox, the handling of selection changes failed. You can only handle one or the other when doing the drag/drop connection crap between the combobox and the IBAction.

So, I found a delegate method, which means that I modified the relevant view controller to implement the NSComboBoxDelegate protocol so that it suddenly receives all of the methods in that protocol, whether I implement them or not; the ones I care to implement actually do get called, and the others are ignored. This seems strange to a .NET programmer, and takes a bit of getting used to, but it can also be very powerful (and a time saver in some cases).

This delegate method is the comboBoxSelectionDidChange notification. Being a “did change” event you’d think that it would only call the method when I have actually finished selecting an item from the drop-down list portion of the combobox. You would be mistaken. Past tense apparently isn’t past tense in Cocoa.

Only one problem: if I use “combo.stringValue” inside that method it still returns the previous value in the text part of the combobox. If I want to get the text of the item that the user selected, I’ve got to do this:

dateCombo.itemObjectValueAtIndex(dateCombo.indexOfSelectedItem) as! String

I do not have the words to describe my disappointment.

Come on Apple, the Cocoa framework needs a decent upgrade.

Please.

Crappy Linux Twitter Clients

I’ve about had it with the range of Twitter clients on offer in Linux. Twitux seems capable of producing nothing but “Timeline Parse Error” messages these days, so I went looking for something else. Found two possibilities: gTwitter and Gwibber. Judging by the screenshots, Gwibber is a screen real-estate hog, so I don’t think I’ll bother with that. So that leaves gTwitter. More disappointment in store, it seems…

I install gTwitter and land at a preference window, which is fine. Entered what I thought were my credentials but they didn’t work. The gTwitter window says “Click on the Preferences button to enter username and password” but there is no such button. There’s a refresh, and a paint-brush icon in the “What are you doing?” text field, but no preferences button. I try right-clicking in the humungous top area where it says “Connection failed!” but nothing shows. The “Connection failed!” message is actually a button that loads a web page; no thanks. Clicking on the icon of a PC with two screens simply toggles the humungo-area between error message and a “Name:” label and nothing else. No sign of a “Preferences button” as advertised.

Turns out there’s an icon in the panel at the top of my screen that I have to right-click on to then get to a preferences menu! Grrr! Now since I paid the princely sum of $0.00 dollars for my Ubuntu setup, I don’t really have much recourse, but come on! It’s crapware like this that makes you wonder how Linux will ever win over the masses. I should have expected it, though, since gTwitter depends on Mono, which provides the .NET plague especially for Linux.

Oh, and now that I’ve just started Twitux one more time to confirm I got the error message right, the little bitch decides to work this time! Why on earth has it been such a right pain in the you-know-what for days on end now, and it’s only after I go flirting with another crappy Twitter client that it realises it has to put out to keep me? Crikey! Sometimes computers really piss me off!

I’m with Linus: KDE 4 sucks!

A week ago I posted an entry saying that I might use Linux, but I wouldn’t recommend it. A comment to that post by one “JD” said that this was because I have “made bad Linux choices”. Well, having decided to bite the bullet and give Ubuntu with GNOME a try, I’m inclined to agree. KDE might have kept a control-freak like me reasonably happy until now, but compared with Ubuntu’s GNOME, the 4.x variety is just rubbish! Even Linus himself thinks so.

About six weeks ago I switched from Mandriva 2009.0 to openSUSE 11.1, but the problems gradually mounted. Here’s a summary:

  • The hard disk would grind away like a ticking clock when downloading files or streaming video, and would sometimes even lock Firefox or another application until the disk operation had finished. I did try fiddling with swappiness and the I/O scheduler, but none of these made a difference in openSUSE. I hardly ever hear the disk in Ubuntu
  • I couldn’t play audio CDs
  • KDE 4.1.3 would occasionally just die with desktop icons disappearing then all my applications failing to respond; couldn’t even switch to a full terminal to log in
  • Dismounting removable media in Dolphin doesn’t show logical feedback of the change
  • YaST2, even though I said it was better than drakconf, eventually became irritating with its constant refreshing on startup
  • Special effects in KDE 4.x are lame compared to Compiz and aren’t as fast, either
  • The Kicker eventually annoyed me. Yes, I could have switched to the old style, but it just added to the feeling one gets when a product “just feels crap” all over
  • Audacious is available by default in Ubuntu’s repositories and I didn’t have to use a third-party Packman repo to get it
  • Power management for my Dell 2407WFP-HC monitor actually works in Ubuntu. In openSUSE I had to keep switching it off and on all the time if I didn’t want to waste power. After six weeks of this the button doesn’t work anymore and I’ve had to arrange an exchange with Dell
  • After installing VirtualBox in Ubuntu, I didn’t have to reboot for it to work. Not that this is major but I had to reboot in openSUSE for some reason
  • Auto-completion of emails in Kontact didn’t work. Now that I’ve switched to Thunderbird, things are better
  • K3b couldn’t eject burnt DVDs half the time

A problem that I’ve had for some time was the clipboard breaking whenever I ran VirtualBox but I eventually discovered that updating the guest additions to the current version fixed it (no more “ŸŸ” pasting only, yay!) so I can’t blame either Mandriva or openSUSE for that, but I think VirtualBox should detect old tools and notify the user.

So, I now have none of the above problems in Ubuntu 8.10 (I went with the 64-bit version, and so far, no hassles, apart from having to add a -vm switch to my Eclipse icon telling it which Java version to use for Aptana). That’s not to say that there aren’t some things I’d prefer were different in GNOME, so here goes:

Nautilus:

  • Can’t drag/drop files onto buttons in the pathbar (have to open a tab first then drag to that tab)
  • I wish there was a List View size between 33% and 50%
  • No rubber-band file selection in List View (this has prevented me from using a GNOME-based distro for ages, but since everything else works so flawlessly in Ubuntu, this is a sacrifice worth making)
  • Pause/resume for file copy operations (and a bit more information) would be nice
  • Needs a way to hide some places in the left column (like partitions I haven’t bothered to format yet)
  • Beeps when deleting files – very annoying! (have to turn off default beep completely!)
  • Doesn’t show current directory size down the bottom

Other:

  • It would be nice to be able to see if a package was 32 or 64-bit in Synaptic
  • Ctrl+Tab instead of Ctrl+Alt+Page_Up/Down would be better in gedit
  • You can’t drag/drop files out of File Roller into Nautilus (or anywhere else)
  • Transmission is too basic, even by GNOME standards, and needs a pause/resume all menu item in the tray icon. Just an observation, since I’ve gone with Deluge anyway

Having got those off my chest, I’ve reached the point with KDE 4.x that even these GNOME annoyances are now minor in my view, and I’m prepared to live with them to get an operating system as near perfect as Ubuntu. Even the fonts seem to look better than in openSUSE or Mandriva, which always irked me in KDE. Maybe it was the distro’s choice of fonts, I don’t know; all I care about is the fact that there can be no question in my mind now that Ubuntu is the most popular Linux distribution for a reason: it just oozes quality! KDE and their distributions are going to have to do a damned fine job before they’ll entice me back now.

I might use Linux, but I wouldn’t recommend it

I’ve been using Linux as my one and only operating system at home for about 14 months now (12 months with Mandriva and the last two with openSUSE). During that time I’ve successfully managed to kick my dependency on proprietary software. Switching to OpenOffice.org was a major help because the need for MS Office was keeping me on Windows, and since Apple are too full of themselves to release a mid-range system without a monitor or an operating system that doesn’t treat me like a moron, Linux was the obvious choice. But I’d be lying if I said I was in computing heaven.

One of the things to really annoy me of late is the I/O scheduler in Linux, and anything involving disk activity. Copying large files across the network shouldn’t hang my applications for long periods of time. A friend in the know says that Windows prioritises the focused Window whereas Linux treats all tasks equally. Maybe this is why the I/O scheduler is now “completely fair queuing” by default. So I changed it to “deadline” for a while to see if that helped. It actually seemed to make Firefox hang even more, so I’m now trying “anticipatory” for a while, and so far, it might just feel better (but only time will tell). My next step will be to do away with a swap partition altogether. I have 2GB of memory for goodness sake, so Linux shouldn’t need to swap anything (even though I’ve set “vm.swappiness = 10” to try to discourage swapping).

The other day I copied some files to my brother’s very new 8GB flash drive using Dolphin in KDE 4.1.3 and let’s just say that I was getting some pretty dirty looks. The kind of look that says “*this* is how good Linux is? are you insane?” The files would seem to copy very quickly for a short while (up to about 8MB per second) but then the transfer rate would progressively slow down (under 1MB per second) to the point where it would seem to be doing nothing, then speed up again. My own 4GB USB seems fine, so perhaps Linux doesn’t like his brand (I’m sure he’d have noticed if Windows had trouble copying to it).

Today I don’t seem to be able to press Ctrl-Alt-Right or Left to switch virtual desktops, even though the KDE 4 “Personal Settings” window shows that they’re still set to these values. I finally decided to give virtual desktops a try the other day because I had so many windows open I couldn’t make sense of it all, and since I was doing some web development, including using The GIMP for graphical stuff, I couldn’t see the Toolbox or the Layers windows in the taskbar. Turns out The GIMP doesn’t show these down there (very handy, even though they’re fully-fledged windows and not like floating palettes in MS Windows).

What a bizarre beast this GIMP is, especially the openSUSE version, where the File menu isn’t on the Toolbox and instead appears at the top of an empty image window the first time you start it (and all other image windows subsequently). To top it off The GIMP’s selection saving is quite peculiar if you’re used to Photoshop (you have to save to channel, then, if you want that selection back again, right-click on the channel in the layers/channel window – that doesn’t appear in the taskbar – and choose Channel to Selection). Perhaps I should try “gimpshop” but right now I’m too annoyed to be bothered. And it won’t remember my recently-opened files, either.

Of course I could go on about the obligatory nuisance that is Adobe Flash. Actually, I think I will. I’m using the 64-bit version of openSUSE 11.1, and the admittedly alpha version of Adobe’s 64-bit flash player, but do you think that a web browser in Linux could still manage to play a simple applet without turning itself into a grey square again? By all accounts this 64-bit Linux flash player is supposed to be good, but as far as I can tell, it’s no better than before. Maybe Flash is just an abomination since it’s always been so, but surely in this day and age a simple sound-playing applet on naxos.com can bloody well play a simple audio stream without kicking the bucket? And that’s another thing, finding all the annoying little packages that are required to play various media formats. Like previewing sound on Amazon.com, which appears to be a little flash applet. But since the whole world of media formats is one big sloppy orgy where everyone’s invited, including the dirty old troll who lives under the bridge out of town, it’s a frigging nightmare out there trying to get by.

That last slew of problems isn’t really Linux’s fault, but by George, you soon get to be intimately acquainted with them if you try to break free of Windows and all those evil Quicktime systray applets, Adobe updaters, pointless Java icons, and virus updates. Linux isn’t necessarily better in most respects, it just gives you different problems to deal with. The only good side is that you’ll at least have to adopt open file standards and your chances of being able to switch to a different OS one day will be greatly increased. If I’m not beholden to Windows any more then perhaps I could actually switch to Mac one day if Apple figured out how to create an OS acceptable to people with intellect. Like a decent Finder and the ability to really configure keyboard shortcuts (more than just redefining what the menu exposes). I’m sorry, Apple, but I simply must be able to press home/end to move my cursor to the beginning or end of the line. Ctrl-Left or Ctrl-Right is unacceptable. And forcing me to buy a system with a crappy screen with a locked-in hard drive and a crappy video card simply because I choose not to be price-gouged into a Mac Pro is no way to attract new customers (with a brain, that is).

I hadn’t intended to type all this tonight, but things have really been annoying me lately. Like my clipboard breaking every time I use VirtualBox, or not having back/forward mouse button support in Dolphin, or Pidgin periodically crashing whenever I receive a message from somebody (on MSN or XMPP), or not being able to read or play audio CDs, and Kontact not being able to auto-complete recent email addresses. I didn’t have any of these problems in Windows, but I did have a very healthy systray, and I had to have a virus scanner. Which is a bit of a deal breaker, really. Unless my problems mount up in Linux, I think I really do have the lesser of all evils. But it’s not such that I would be confident in recommending somebody switch to Linux. Assuming they’re stupid, I’ll just recommend they buy a Mac. And if their relationship with Windows has reached the point of separation, and they have a brain, they’ll just have to work around Linux’s issues themselves. I simply don’t have the time or the patience any more for this kind of crap.

21-Feb-2009: While I think of it, other things that are broken include K3b not being able to eject the DVD after burning, and the power management for my Dell 2407WFP-HC 24″ monitor not working, forcing me to switch it off all the time, to the point where the switch is now busted. Thank goodness for the “5 years advanced exchange” warranty on it. The default focus-stealing prevention is a bit too eager, I think. Clicking on a newly-inserted medium in the device notifier would load Dolphin, but wouldn’t actually focus the window or bring it to the front; you have to click on the glowing entry for it in the taskbar. If I just clicked on it in the device notifier, that generally means I want to open it! I just checked and the “Focus stealing prevention level” is set to “low” so I guess you have to choose “none” to fix this and really get annoyed like never before!