Joe Maller.com

Re-thinking AngularJS

The Angular 2.0 preview roadmap was recently posted to HN and after reading it, I’m starting to think adopting Angular might have been a mistake.

Having built a few small projects with AngularJS, I’ve found the framework a pleasure to work with. Once past the initial learning curve, features started flying together. Most of my trouble-shooting time was spent getting backend data delivered correctly, Angular just worked. Based on this positive experience, I’ve been moving towards adopting Angular as the standard frontend of my web toolkit.

Choosing Angular wasn’t without doubts. Introducing this many new conventions, syntaxes and practices doesn’t come without a cost. The problem with re-invention is longevity: Either these new ideas succeed and become the norm, or they’re left for dead on the side of the road as technology marches on.

Parts of the 2.0 roadmap sound great. But it also sounds as if this future Angular will be very different from the Angular we know now.

How big is this rewrite?

Huge revisions rarely end well. From-scratch rewrites have famously been called the “single worst strategic mistake that any software company can make.” The goals always sound noble and the plans make sense, but by definition, engineering resources will be split between maintaining the original version and developing its successor. Either the original suffers or the rewrite falls behind or both.

Does a revision of this scale imply that the current codebase is impossible to maintain? I’ve looked through some of Angular’s source code, there’s some near-magic craziness in there. Is it too crazy?

If the Angular team doubts their own code and will presumably move towards conventions used in competing frameworks, wouldn’t it be smarter for users to jump ship now for those other tools? Competing codebases automatically become more mature if Angular basically starts over.

Questions about backwards compatibility

Regarding porting from Angular 1.2.x, the devs imagine “porting will be fairly straightforward but not free.” The arrogance of this position makes me doubt Angular more than anything else. The JavaScript world is ruthlessly forward-looking and moves very, very quickly. If upgrading to 2.0 is only moderately less painful than switching to another framework, Angular is doomed.

Angular blindsided many enterprise users in December 2013 when they announced they were dropping support for IE8. Even without API changes, jQuery’s usage statistics show their ie8-incompatible 2.0 branch is seeing dismal adoption rates. Python 3’s breaking changes have been a disaster for their mindshare. PHP’s dogged insistence on keeping nasty old code working is likely a factor in that language’s recent renaissance. Existing Angular code should probably be considered end-of-life.

Documentation fragmentation

Angular’s documentation has been a problem area for years. There’s no reason to believe documentation won’t lag behind again if the core functionality of Angular is significantly changed.

Outside resources and tutorials are a different problem. Most won’t be re-written, and search results will end up polluted with out-of-date information.

Google’s track record

When it comes to supporting technology, Google is phenomenally undependable. They’ve acquired and demolished a ton of popular web products (Reader, FeedBurner, Blogger, Picnik, Buzz, Wave, “Don’t be evil”, etc.). The only thing they’ve stuck with is the horrid Google+ monstrosity. Google’s support for the Angular project was initially an argument in favor of adoption, but really, the Google name is neutral at best and almost a negative. At least the Angular source code is open source and out in the wild.

And then there’s AngularDart. Google’s Dart meta-language seems kind of stupid to me, but for the most part, so does CoffeeScript (though my resolve is weakening). At very least Dart feels like one of those throwaway side-projects that a rogue team of Google super-geniuses put together–I don’t expect it will have a long life. Dart aside, the bigger question is the resource-cost of supporting a large, complex framework across several languages/dialects. This lack of focus doesn’t build confidence.

What’s next

I’ve really enjoyed working with Angular, but I’m doubtful for its future. Over the years I’ve seen too many great products die from rewrites or overly ambitious direction changes. The first Great JavaScript Awakening saw dozens of libraries before jQuery eventually won out. I hope I’m wrong, but I’m going to be looking at Backbone again, as well as React, Mithril and anything else to fall back upon if Angular proves to be a dead end.

Joe Maller
March, 2014

cross-posted here: https://gist.github.com/joemaller/9643049


PHP Composer on shared hosting

One of my goals with PHP is to simplify and streamline my workflow as much as possible. Ideally this helps prevent wasting enormous amounts of my time on stupid crap like autoloaders, library dependencies and re-inventing the wheel.

I’m using a few libraries on IOP’s site, but as much work as these have saved, I ended up with an ugly mishmash of autoloading and require code.

Enter the Composer project.

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

Together with Packagist, which is sort of a nascent RubyGems or PyPI equivalent, using libraries in PHP just got a whole lot cleaner. Composer even generates a complete autoloader, meaning a bunch of annoying code can be replaced with a simple composer.json file and this:

require 'vendor/autoload.php';

Except when they don’t. Because, sometimes, they won’t.

There’s always a catch, isn’t there?

The problem I ran into was the dated default PHP configuration on our shared cPanel host. Trying to run curl -s http://getcomposer.org/installer | php threw this back at me:

#!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The phar extension is missing.
Install it or recompile php without --disable-phar

The allow_url_fopen setting is incorrect.
Add the following to the end of your `php.ini`:
    allow_url_fopen = On

The ionCube Loader extension is incompatible with Phar files.
Remove this line (path may be different) from your `php.ini`:
    zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so

* sigh * These are not settings most shared hosts grant users access to–and if you ask they’ll probably just try to upsell you a VPS. Thankfully though, many cPanel installations now allow users to select different versions of PHP (A2 does). And thankfully again, these alternate versions are often compiled with different flags.

That’s great for web pages, but Composer’s installer uses the command line. To use an alternate version of PHP in a shell, we need to know where the alternate PHP binaries are. An easy way is simply to switch the PHP Version via cPanel, then load a page containing phpinfo();. The actual PHP binary path isn’t listed, but it’s easy enough to figure out from what’s there. Mine was /opt/php/php-5.4.0/bin/php.

Once you’ve got that, you can fiddle with your $PATH (it’s searched from left to right) or just alias the alternate PHP binary:

alias php='/opt/php/php-5.4.0/bin/php'

I aliased php in my .bashrc file (reasons previously discussed) and composer installed flawlessly.


IE6, IE7 and IE8 Compatibility testing with Microsoft Virtual PCs

Or: How to covert Microsoft’s Internet Explorer Application Compatibility Virtual PC images for testing on a Mac with Parallels Desktop or VMware Fusion. (but that’s kind of a mouthful)

To help with web development and testing, Microsoft provides several compatibility environments for past versions of Internet Explorer. These are time-limited, pre-configured Virtual PC disk images, intended for use with Windows Virtual PC.

That’s great, except Virtual PC doesn’t really run inside another virtual environment like VMware Fusion or Parallels Desktop. Since so much web development is done on Macs these days, this makes testing difficult. But, the VPC images are just virtual hard drives, so they can be easily converted to the native format of either Parallels or VMware.

Below are instructions for converting Microsoft’s .VHD files to native Parallels Desktop or VMware Fusion virtual machines. The goal is to do everything without using another Windows machine or digging out your old WinXP CD.

Get the IE Compatibility VMs

Download one or all of the Internet Explorer Application Compatibility VPC Images. Self-extracting EXEs can be decompressed on a Mac with The Unarchiver. The VHD is all that’s needed, one or all of these:

  • IE6Compat.vhd
  • IE7Compat.vhd
  • IE8Compat.vhd
  • Vista Business with IE7.vhd
  • Vista SP1 x86 with IE8 2009-Apr.vhd

Convert the VHD image to Parallels’ or VMware’s native virtual disk format

Currently, Parallels Desktop 6 can’t convert VHDs through it’s GUI, but it does include a hidden command-line utility which works perfectly. Create a new Parallels VPC in the default location (~/Documents/Parallels) with this command:

$ /Library/Parallels/Parallels\ Service.app/Contents/PlugIns/Parallels\ VM\ Converter.app/Contents/MacOS/prl_convert IE7Compat.vhd 

For VMware Fusion, use one of the components in Q (qemu-img, details) to convert the .VHD files to VMware’s .vmdk format.

$ /Applications/Q.app/Contents/MacOS/qemu-img convert -O vmdk -f vpc IE7Compat.vhd IE7Compat.vmdk 

Create a new Virtual Machine using the vmdk as the disk. I could not get Vista to work dependably with VMware.

XP: Fix Windows Drivers

On first boot, the VM will attempt to re-activate Windows. This will fail because the networking drivers haven’t been installed yet.

Next the VPC_EULA will open and the first of many “Files Needed” dialogs and “Found New Hardware” wizards will appear. Close and cancel everything until you’re back at the Windows XP desktop.

If you’re running Parallels Desktop, it will take over and install its tools. If you’re using VMware, choose Install VMware Tools from the Virtual Machine menu. VMware also asks for a handful of drivers during tools installation, cancel these, they’ll be fixed later. The VM will reboot when the tools and drivers finish installing.

After the initial reboot, Windows requires WGA activation. Since this is a Microsoft-provided license, the VM will pass WGA and Windows will be activated. There’s no point in registering, so skip that. Everything from here forward is cleanup.

The easiest way to fix a bunch of drivers is to install XP Service Pack 3. Download the ISO from Microsoft here: Windows XP Service Pack 3 – ISO-9660 CD Image File

Any lingering driver issues can be resolved in Device Manager (Control Panel > System > Hardware tab > Device manager). The problem items should either have their drivers updated or, if that doesn’t work, disabled altogether. VMware’s audio driver failed to load initially but updated successfully. Mystery USB devices were a problem in both, but can be disabled.

Ironically, I had much more trouble getting these VMs running natively under Virtual PCs on a Windows box. Many of these steps are necessary there too.

Other stuff I install:

VMware or Parallels?

For years I’ve been bouncing back and forth between the two. It seems that with each major release, one leapfrogs the other. After testing VMs in both, I’ve decided to switch back to Parallels. At the moment, it just seems more full-featured and seamless. According to a recent MacTech virtualization comparison test, Parallels is also faster.

Disclaimer

The above process may violate the second paragraph of the “Installation and Use Rights” section of Microsoft’s XP EULA:

You may install and use one copy of the software on your device of which you are running a validly licensed copy of Microsoft Virtual PC or Microsoft Virtual Server. You may not change or convert the virtual hard disk image from the VHD format.

However, no such clause appears in the Vista EULA which seems to contradict the above and fully supports virtualization:

You may install and use one copy of the software on your device of which you are running any virtualization software able to run Virtual Hard Disk (VHD) formats, including Microsoft Virtual PC or Microsoft Virtual Server.

Anyway, I assume no responsibility for what anyone does with this information.


Download Google’s Web Fonts

May 1, 2013 update: I’m no longer providing a download link to the font files. Please use the googlewebfonts repository on GitHub. Just click the Zip button.

Google’s Font Directory and API for web fonts could have a transformative effect on how we read the web. The only problem is, Google has made it very difficult to download all of the actual font files.

Web designers must be free to experiment with fonts, to sketch, comp and get to know the typefaces in browser and non-browser applications. Making the fonts difficult to get or requiring special software isn’t helpful.


Faster and easier Gitweb installation

The idea of using make to build Gitweb isn’t just excessively complex, it’s also mostly unnecessary. Building gitweb.cgi from gitweb.perl only changes 19 of the source file’s 6734 lines (0.2%).

Fact is, to get Gitweb working only one line needs changing. After the following edit, all local configuration values can be loaded from a simple config file.

On line 546, insert the name of your config file:

-our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++"; 
+our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "gitweb_config.perl";

A set of fully-documented configuration files is available in the Simple Gitweb Config project on Github, to help get things up and running quickly.

(more…)


NYTimes search bubbles begone!

nytimes-search-balloons-1

Those little search bubbles that popup on the New York Times website whenever you select text really annoy me. Clicking this bookmarklet on any NYTimes page will prevent them from appearing:

NYTfix

This is a 2-minute solution, there’s no domain checking or anything, all it does is remove existing bubbles then cancel the document’s mouseup observer, which the NYTimes site uses to trigger the search balloons. The bookmarklet was very quickly checked in Safari, Firefox and IE8, NYTimes text selection doesn’t work at all for me in IE6 or IE7.


Where to watch the Inauguration online

On Tuesday I’ll be working in an office without TV, so I gathered up list of sites where the inauguration can be watched online.

Information and schedules:

The official schedule has the swearing in ceremony as starting at 11:30 am. I only found one source listing the Vice-President’s swearing in at 11:45 and President’s at noon.

Live video streams

The following sites have announced live streaming coverage of the inauguration.

Video sites:

News:

Governmental sites:

Other “where to watch” articles:

CNN, CNet, PC World, WebTVhub, TechCrunch

I won’t be at all surprised if the Internet melts on Tuesday, just before noon EST. But I hope it doesn’t.



Next Page »