About a month without Google Reader

As a bit of an RSS junkie – see previous post – I had to go look for alternatives to Google Reader. I’ve been a feedly user on and off for a few years but I was never that taken with it. It does seem to do mostly do what it says on the tin and the availability of the various tablet apps is a good thing, but it tends to run into a few issues with high-volume feeds (craigslist feeds, I’m looking at you).

In the end I decided to do with a self-hosted installation of Tiny Tiny RSS. The UI isn’t as spectacular as feedly’s – OK, out of the box it’s downright boring, and I haven’t got around to playing with the themeing yet – but it does what it says on the tin, hasn’t got problems with craigslist feeds and so far just works. Importing the OPML from Google Reader was a snap once I figured out how to export it from Google Reader so as a bonus I didn’t have to mess with the folder structure that I had built up over time. Plus, as I self-host it, as long as I’m paying my hosting bill I don’t have to worry about the service being discontinued.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

Of course I have to post something about Google Reader, too

The demise of Google reader viewed from a slightly different perspective. I find the analysis from someone who isn’t a proto-geek but rather an investment professional  interesting, mainly because there are insights that some like me – who doesn’t spend the whole day looking at companies and trying to figure out what they are doing as opposed to what they say they are doing – would and this case, have missed.

Obviously I’m also one of these dinosaurs who are Google Reader users and I’m also in the unhappy camp at the moment. With hindsight, it probably wasn’t too smart to put all eggs in one free basket, but part of the problem was that Google Reader is/was the 800 pound gorilla in the room and mostly squeezed out the competitors. I certainly have no objection to paying for this type of useful service but like a lot of other people the availability of decent clients for nearly all OSs I use was a major factor and for quite a while this has been a case of more-or-less Google Reader on nothing.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

If you’re using boost::variant, you need to have a look at Boost 1.53

I was profiling some code a while ago that makes extensive use of boost::variant and one of the lessons from the profiler run was that boost variants appear to be fairly expensive to construct and copy.

As of 1.53, variants support rvalue constructors and rvalue assignment operators. My initial measurements suggest that when used with types that are “move enabled”, their is a benefit in upgrading to this version of boost variant, both in performance and memory consumption.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

Improving the Emacs integration in Windows

I was trying to make Windows a little more Emacs-friendly (or was it the other way around?) First step was to enable the emacs server in my .emacs so I could make use of Emacs for quick and dirty editing tasks that would require an editor better than Notepad but where the average Emacs startup time was just a little too long to make Emacs a viable alternative. A typical example would be to use Emacs as the editor for commit messages in Mercurial. A quick tweak of my global .hgrc provided me with an appropriate editor setting:

  [ui]
           ... other settings ...
  editor = C:\Emacsen\emacs-24.1\bin\emacsclientw.exe -c

Please note that there are no quotation marks around the emacsclientw command line, adding them will result in an error message rather than an Emacs frame. Guess how I found that out. I would also suggest to extend the command line to include the “alternate editor” parameter -a to either start Emacs or another editor if there is no Emacs server running. Given that I tend to start Emacs right after I start the browser and the email client on most machines, this would be an unnecessarily cluttered command line for my use.

I also set up Emacs as an external editor from Visual Studio as described in this
blog post, so now I can hit Tools/Edit in Emacs from Visual Studio 2012. Hooray! The only tweak I made to the emacsclientw invocation described in the blog post was to make “+$(CurLine)” the first parameter of the emacsclient invocation. That way, the Emacs cursor position is synchronised with the cursor position in Visual Studio at the time you invoked “Edit in Emacs”.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

The stuff you find when you’re moving home

Happy New Year to all readers.

I’ve been blogging even less recently as we’ve just moved house but unpacking all the boxes meant that I came across one of my favourite magazines:

c't-erstausgabe

 

German readers of this blog (are there any) might recognise the magazine – it’s the first issue of “c’t”, a magazine that is still going on strong almost thirty years later. The issue above is dated November/December 1983 and has moved house (and continents) with me a fair number of times.

And yes, I’m still subscribing to c’t these days, although there are fewer articles in it that require a soldering iron.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

How to make a self-signed SSL certificate work with Windows RT’s Mail App on a Microsoft Surface RT

Long title, I know…

I was trying to get Windows RT’s Mail App to access the email on my own server. The server uses IMAPS with s self-signed certificate as I only want SSL for it encryption and don’t really need it for authentication purposes as well. As long as it is the correct self-signed certificate I’m happy.

The Mail app however rejects certificates that weren’t signed by a trusted authority and doesn’t offer an obvious exception mechanism (like Thunderbird or Apple Mail) that circumvents the need for a trusted certificate. The original Mail app that came with my surface also displays only a very cryptic error messages, but the latest update from earlier this week correctly suggests that one needs to add the self-signed certificate to the certificate storage in order to get Mail to recognize the certificate.

In my case the saving grace is that I use the same cert to secure the webmail access so IE can easily access the certificate. However as Joe User, you can’t add another certificate to the certificate store – you have to be Administrator to be able to add a certificate and I initially couldn’t find an obvious way to run IE as Administrator.

The trick turns out to be that you have to run IE from the desktop (yes, the Surface RT has a standard Windows Desktop, too). The easiest way to get there is to run IE from the ’tile’ UI, pull up the bottom menu and select ‘view on desktop’ from the settings icon menu. Once you are on the desktop, right-click (two-finger click on the ZX81 keyboard cover) on the IE icon. Bummer, no ‘Run as Administrator’ menu entry. However, there is an entry in this menu that says ‘Internet Explorer’. Right click/two finger click on that one and you get ‘Run as Administrator’. I fired up IE as administrator and the buttons to install the certificate were no longer greyed out.

At this point there was one last hurdle to climb over – if you let IE determine where the certificate is saved, Mail still does not recognize the certificate. You have to install it in ‘Trusted Root Certification Authorities’. And now, I can finally read my email on my Surface RT. Just be aware of the security implications of doing so as your certificate can now act as a root certificate for other certificates. Of course, you could simply get a ‘real’ certificate and not have that sort of security issue.

The above worked for me because I use the same certificate for two purposes. If you can’t simply access the certificate via a browser you’ll have to download the certificate onto your machine as a file and then use certmgr to import it. Again, you’ll most likely will have to run certmgr as Administrator as it won’t allow file operations otherwise.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

I don’t want to see another “using namespace xxx;” in a header file ever again

There, I’ve said it. No tiptoeing around.

As a senior developer/team lead, I get involved in hiring new team members and in certain cases also help out other teams with interviewing people. As part of the interview process, candidates are usually asked to write code, so I review a lot of code submissions. One trend I noticed with recent C++ code submissions is that the first like I
encounter in *any* header file is

using namespace std;

If we happen to review the code submission using our code review system (a practice I’d highly recommend), the above line is usually followed by a comment along the lines of “Timo is not going to like this”. And they’re right, I don’t.

So, why am I convinced that this is really, really bad practice despite a ton of (maybe not very good) C++ textbooks containing the above piece of code verbatim? Let’s for a moment review what the above statement does. Basically, it pulls the whole contents of the namespace “std” (or any other namespace that the author used the using statement
for) into the current namespace with no exceptions. And I mean *anything*, not just the one or two classes/typedefs/templates you’re trying to use. Now, the reason that namespaces were introduced in the first place is to improve modularization and reduce the chances of naming conflicts. It basically allows you to write the following
code and ensure that the compiler picks the correct implementations:

std::vector<std::string> names;
my_cool_reimplementation::vector<our_internal_stuff::string> othernames;

Now assume that we’re trying to reduce the amount of typing and put the above using statement in the code (or worse, use both namespaces) and write the following:

vector<string> names;
vector<our_internal_stuff::string> othernames;

If the author of the code is very lucky, the correct implementation of vector will be picked, at least initially. And some time down the road, you’ll encounter strange compiler errors. Good luck finding those – I’ve been in situations where it took days to track down this sort of problem. That’s a heck of a timewaster that you just got for saving to
type five characters.

Also, if you’re putting the using statement into the header file, you’re aggravating the problem because the conflicts you will run into sooner or later will be in a module far, far away for no apparent reason until you find out that three layers down, one include file happens to include the file that contains the using directive and suddenly polluted
whichever namespace the file contained with the whole contents of namespace std.

So why is using namespace std; found in so many textbooks? My theory is that it does help with the layout of the book and it reduces visual clutter. In a dead tree book, you only have very limited amounts of space so you need to make the most of it, plus the code examples are generally fairly trivial. That, and the various namespace qualifications
introduce a lot of visual clutter that doesn’t help with getting the author’s point across in the context of a textbook. Neither of these really hold true when it comes to production code in the age of 24″ monitors and text editors that can handle more than 60-80 characters per line (try it, it works!). So, don’t do it.

So, what can you do if you absolutely, positively have to use a using declaration in a header file? There are other ways to reduce the impact of having to do so – you can use one of them, or all of them in various combinations.

First, you can simply use a typedef. I would suggest that this is good practise anyway even if I don’t always follow my own advice. Using a typedef actually has two benefits – it makes a typename more readable and it documents the author’s intent if a well chosen name has been used. Compare the following declarations:

std::map<std::string, long> clientLocations;
typedef std::map<std::string, long> ClientNameToZip;
ClientNameToZip clientLocations;

The second declaration – even though it spans two lines – is much more self documenting than the first one and it gets rid of the namespace fuzz at the same time.

Another option is to limit the scope of the using statement in two ways – only “using” the names of the symbols you need to use, for example:

using std::string;

Again, just throwing this statement into a header file is almost as bad an idea as putting in “using namespace”, so you should limit its visibility by making use of C++ scopes to ensure that your using declaration really only affects the parts of the code that need to see your using declaration in the first place. For example, you could limit
the scope to a class declaration:

namespace bar
{
  struct zzz
  {
    …
  };
}
class foo
{
  using namespace bar;
  zzz m_snooze; // Pulls in bar::zzz 
};

Or you can limit the scope of a using directive to a single function, for example like this:

void temp()
{
  using namespace std;
  string test = "fooBar";
}

In either case, you are restricting the visibility of a using directive to the part of the code that requires it rather than throwing it right into everybody’s way. The bigger your projects get, the more important it is to ensure proper modularization and minimize unintended harmful side effects.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

That’s another warranty voided, then

Last night I did something I was adamant I wasn’t going to do, namely rooting my Android phone and installing CyanogenMod on it. Normally I don’t like messing with (smart)phones – they’re tools in the pipe wrench sense to me, they should hopefully not require much in the way of care & feeding apart from charging and the odd app or OS update. Of course, the odd OS update is can already be a problem as no official updates have been available for this phone (a Motorola Droid) for a while and between the provider-installed bloatware that couldn’t be uninstalled and the usual cruft that seems to accumulate on computers over time, the phone was really sluggish, often unresponsive and pretty much permanently complained about running out of memory. So far it appears that updating the OS and only installing a handful of apps that I actually use as opposed to the ones that I supposedly “need” has resulted in a much better user experience.

The whole process was comparatively painless, which I really appreciated. The biggest hurdle was getting the clockworkmod recovery image onto the phone. I ended up rebooting the Mac into Windows and install it via the Windows tools. Other than that, the installation went smoothly and didn’t leave me with a bricked phone so I’m happy with that part.

Why the effort, given my dislike for hacking smartphones? Well, for starters I can squeeze a little more life out of the phone. I’m eligible for an upgrade but thanks to Verizon’s shenanigans, sorry, added hoops (and added expense) required to jump through if you want to keep a grandfathered unlimited data plan, I don’t feel particularly compelled to spend money on a phone, especially if I have to pay full retail for an upgrade. I’m also not that big a fan of Android (I admit to preferring iOS) so I’m currently waiting on how the whole “unlocked iPhone” saga will play out with the iPhone 5. If I have to pay retail for a phone – any phone – I might as well use that as leverage to reduce the overall phone bill.

In the meantime I’ll see how I like the “new” Droid and better get used to occasionally reinstalling the OS on a phone, thus reminding me of the quip that Android truly is the Windows of smartphone OSs.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

A(nother) tool post

I generally don’t post that much about the tools I use as they’re pretty standard fare and most of the time, your success as a programmer depends more on your skills than on your tools. Mastery of your tools will make you a better software engineer, but if you put the tools first, you end up with the cart before the horse.

I guess people have noticed that I use Emacs a lot :) . My use of it is mainly for writing and editing code (and some newsgroup reading at home using Gnus) and I generally use it only for longer coding sessions. As a lot of my work is on Windows, one of the main tools I use is Visual Studio – almost exclusively 2010 right now, although I’ve taken a few peeks at 2012 and have used pretty much every version since VC++ 4. While I tend to use Emacs as soon as I’m editing more than two lines I tend to make the small changes that you get to make while debugging in Visual Studio.

I did actually try SublimeText 2 a little while back as people were raving about it in various podcasts and on blogs. I did like its speed and uncluttered appearance but quickly fell into the “old dog refusing to learn new tricks” routine. OK, this is a slight exaggeration but after a few days I didn’t get the feeling that using it over Emacs did anything to my enjoyment of programming or my productivity. I think part of the problem is that using any editor out of the box versus an editor that one has used over several years and customized   to reflect new things learned about both one’s own tool use and ideas borrowed from co-workers is simply not a fair comparison, but it is similar to a musician trying out a new instrument after getting comfortable with his current instrument over a few years. If you do care about your craft an editor is a central piece of your workflow and once you can use it without having to think about how you accomplish a certain task, it gets harder to change.

Nevertheless, I would recommend that if you are a programmer in search for a better editor than the one your IDE offers and don’t want to invest the substantial amount of time to get comfortable and productive with the editing dinosaurs like Vi/Vim and Emacs, go check out SublimeTex t2. I promise it is worth your while.

Oddly enough my main takeaway from trying out SublimeText 2 was that I – who has been proponent of high-contrast colour schemes for editors like the one used by the old Norton Editor (yellow on blue) – really got into the low-contrast default theme. So much in fact that with Emacs 24′s theme support, I’m now using this version of zenburn for Emacs. The other takeaway was that I really appreciated the fast startup time and having a slightly better editor around than Notepad when it came to all the quick editing tasks one has to accomplish that would either mess up my carefully set up Emacs or require a second instance of Emacs for “scratch editing”. I ended up with Notepad++ for that and it seems to do the job admireably so far.

Another of the tools I discovered on Scott’s Hanselman’s blog is Console2. I much prefer it over the standard Windows command prompt so give it a whirl! I also tried ConEmu as Scott recommended that in a separate post – I’m a little undecided as of yet which one I prefer, both seem to work just fine and are a massive improvement over the original MS command window – if you’re a command line junkie like I am, having one or two tabbed command windows hanging around rather than a plethora of command windows is a massive boon. Try both, see which one you prefer – so far I do like the feel of ConEmu actually being developed (there are frequent new releases available) but Console2 simply seems to work, too. I think it’s just a matter of personal preference.

Speaking of command line tools, I recently had one of these “wow, these guys are still around” moments when I discovered that JPSoft is still offering a replacement command line processor for windows. I used to be a pretty heavy user of both 4Dos and 4NT back in the early nineties when they were distributed as shareware and you had to buy the documentation as a proper dead tree version to acquire a license. Actually I think I still have both manuals in a storage unit somewhere…

Anyway, I have been playing with the latest incarnation of their free command line tool (TCC/LE) and I really like it. Enough so that I’ll probably end up buying the full version. Basically if you are looking for a “DOS prompt on steriods” rather than using Bash via Cygwin or Powershell – which aren’t always that useful, especially if you need compatibility with existing batch files – I would strongly recommend you check it out.

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon