Monday, October 28, 2013

Why I hate newspapers

In keeping with the theme of my previous post, I wanted to talk about why I hate newspapers.

  1. I dislike reading.  If I'm going to read something it's going to be something I find interesting such as a technical document, scientific article, etc.  Not the newspaper.
  2. I hate the smell of newspapers.  I don't know if it's the paper, the ink, or a combination, but newspapers have a distinctive smell and I hate it.
  3. I hate the way newsprint rubs off on your hands.  They use the cheapest form of printing which results in the inks rubbing off as you read it.
  4. I hate the feel of the paper.  Newspapers use the cheapest paper they can find and I don't like the feel of it.  The difference between newspaper and high quality paper is significant.
  5. Newspapers cost money.  Whether it's a one-time fee from a newspaper machine or a regular subscription, you're still paying money for what is available elsewhere for free.
  6. There are far better "electronic" alternatives (more on that later).
  7. It's a huge waste of time, energy, money, and resources.  How many trees go into making newspapers every year?  How much gas is burned delivering it to houses?

To me there is absolutely no redeeming quality to newspapers.  The "content" they provide can be gotten off the Internet for free on sites such as cnn.com, nbcnews.com, local TV stations, etc.  You can get classifieds and jobs off craigslist and monster.com.  Store sales, ads, and coupons can get viewed going to that stores website.  And the best part is, all of this "electronic" content can be easily searched using a computer, something you can't do with newspaper.

It's no secret the newspaper industry is really hurting.  Less than a decade ago the newspaper ads brought in about $17 billion dollars annually in the US.  Today that number is less than $4 billion and dropping.  As an industry you can't sustain losses like that and continue.  Already major newspapers throughout the US have been closing.  The whole industry is in a downward spiral that will not stop in my opinion.  As newspaper revenue drops they have no choice but to reduce the content of newspapers.  But as content decreases, the number of subscribers will decrease also.

I don't think I'm alone in my projections here.  Most younger people won't touch a newspaper, they prefer something electronic.  So newspapers are clinging to the "older generation."  But once they pass on, no one will be left and they will be forced to close.

In my opinion, the newspaper industry missed a golden opportunity here by not looking forward.  A decade ago they should have shifted their focus to an online presence.  The goal is to create online content that people want enough to be willing to pay for an online subscription.  In addition to news, opinions, ads, classifieds, etc. they should have taken advantage of the benefits afforded by the electronic medium.  For example, show a map centered around the readers location and put a "dot" on the map where ever a news event took place.  Then people can see news events that happened near them.  Yes, such a system would require tons of money to develop, but all the newspaper houses throughout the US could have pooled their resources and created such a system.  This would have prevented sites like craigslist from "eating their lunch."  But as it stands, it's too late.  The damage has been done and I don't think they will recover.  I think the industry will die.

Why I hate the Post Office

This might sound a little strange, but I hate the Post Office.  As far as I'm concerned they offer no service I want and I wish I could stop receiving mail completely.

Why do I dislike the Post Office so much you ask?  Simple, most of the mail I get I don't want.  Most of the mail I get is "spam" or junk mail, which no one wants.  This comes in two forms.  The first is mail addressed to me.  Magazines, brochures, ads, etc. from companies I've purchased from.  These aren't so bad because you can usually contact the sending party and request they remove you from their mailing list.  This takes time and it's a hassle, but it can be done.  The second, and most common, is mail that was not addressed to me or anyone.  Basically some company paid the Post Office to drop this mail into everyone's mailbox.  What I hate the most about this mail is there's no way to "opt out."

All of this junk mail, whether addressed to me or not, is such a huge waste.  I get sick when I think about how much time, energy, and resources were wasted to print and deliver this mail just so I can throw it away and fill up the landfill.  I mean, how many trees a year are cut down to send out junk mail and catalogs?

Any information that I want/need doesn't come by mail anymore.  Everything like bills, statements, letters from friends and family, etc. is sent electronically.  Yes, there are times you need to send something physical, and that's what package shipping companies like UPS and FedEx are for.  I don't mind the Post Office when they are delivering a package, but mail needs to stop.  In my opinion the Post Office has made only 2 good decisions in the last two decades.  First is flat-rate boxes.  Shipping a box without having to worry about the size or weight is convenient and nice.  The second is forever stamps.  Until such time as letters are a thing of the past, stamps will continue.  And never having to worry about rate increases is nice.

So when people talk about the Post Office having financial difficulties, closing offices, reducing services, cutting delivery days, etc.  I welcome these.  To me this is good news!  Whatever it takes to force the Post Office to realize their future is in direct competition with UPS and FedEx and not as a letter carrier is a good thing.

You might point out that the USPS is the second largest employer in the US (behind WalMart) and as such their downfall would result in millions of lost jobs.  As far as I'm concerned that's no reason to keep the Post Office around in it's current form.  One hundred years ago you didn't dial anyone's phone number.  Instead you merely picked up the phone and an operator picked up the other end.  You told him/her who you wanted to call and they literally "patched" you to the other person's line.  But with the advent of phone dialing tens of thousands of operators lost their jobs.  Should we still have operators to dial for us given a better way was inverted to call someone?  No.  By the same token, should the Post Office employ millions of people to deliver letters when a better way to communicate has already been invented?  No!

Really, the Post Office is in a downward spiral that will not end for a long time.  As mail volume drops, they have no choice but to increase postage rates.  But as postage rates increase, people will increasingly turn to electronic ways of sending information.  This death-spiral will continue until, as I said, the Post Office is reduced to only delivering packages.  So the sooner the Post Office gets to that goal, the better.

Thursday, September 12, 2013

Access Violation in CPropertySheet::DoModal

One "feature" about MFC that has always annoyed me is when you create a wizard or property sheets, calling CPropertySheet::DoModal results in an access violation.  This problem is discussed in detail in Q158552.  In short, MFC tries to modify the dialog template, but the dialog template is stored in a read-only page.  This results in an exception.  The operating system catches this exception, changes the page to read/write access, and tries again.  So really this is just a nuisance if you're debugging your application because it breaks on the exception every time.

Well, turns out it can be more than a nuisance.  If you're testing with Microsoft Application Verifier enabled, you cannot debug your application further.  AppVerify is designed to catch buffer overruns by using read-only memory pages.  So when CPropertySheet::DoModal attempts to write to a read-only page AppVerify steps in and puts a stop to the show with a "VERIFIER STOP 0000000000000002" error.

So how can you get by this?  You could disable AppVerify, but testing with AppVerify enabled is a good thing.  It helps you catch other bugs that would normally go undetected.  But I found a simple technique that allows you to keep AppVerify enabled.  Use Visual Studio's resource editor to change the font of the wizard pages.  The default font is "MS Shell Dlg."  You can change this to any font, but I recommend "Tahoma" as this is the font the Visual Studio resource editor uses when the dialog is set to "MS Shell Dlg."  This means your dialog units will be the same which makes arranging controls easier.  Other good font options are "MS Sans Serif," "Microsoft Sans Serif," or "Arial."  These are also generic fonts with the same or similar dialog units.

The reason this works is because of what MFC does.  It checks the font of the wizard/property page and if it doesn't match the font of the wizard/property sheet, it makes a copy of the dialog template and changes the font back to the system default.  This new dialog template is read/write so when processed inside CPropertySheet::DoModal it won't cause a problem.  And if you're following along, changing the font of the wizard/property pages will not change your product at all.  Since MFC changes the font back to the default it doesn't matter what font you change it to, the look and feel of your product will not change.

Thursday, August 15, 2013

The Number Sign

In today's short and very random post, I wanted to talk about the number sign (#) - in particular the different names.  This symbol has at least three different names; 1) number sign, 2) hash, and 3) pound sign.  The official name (at least in North America) is "number sign."  In Europe it's called "hash."  What's interesting is most Americans call it the "pound sign" which is most likely because when used in the context of a telephone it's called "pound" or "pound sign."  But what's the origin of this "pound" name?

Let's start off by looking at the typical keyboard layout in North America.

You can see the number sign is located above the '3' key.  Now let's look at the United Kingdom keyboard layout.

If you look at the '3' key you'll see a different symbol.  This symbol (£) is called "pound sterling," or sometimes just "pound."

So the reason why the number sign is often times called the "pound sign" is because on the US keyboard layout the number sign takes the location of the pound sterling symbol.

Hopefully this gives you reason to ponder the next time someone says "pound sign."  That's an inaccurate name that probably dates back more than a century now.

Monday, April 22, 2013

Children's books

Now that we have two little kids in the house we're reading a lot of kids books.  I am absolutely shocked by how many kids books have typographical errors in them.

First off, kids books don't have A) lots of words or B) very long words.  [BTW, when I say "kids" I'm referring to 1 - 2 years old.]  So errors should be very easy to catch.  I'm an engineer and I'll be the first to admit my spelling and grammar are not the best.  So the fact that I'm catching all these errors just means there are most likely more errors that I'm missing.

Secondly, the whole idea behind a kids book is to help teach kids how to read and write.  How can kids be expected to grow up and speak proper English when the authors of their books can't even read or write.

So what are some of these errors you ask?  By far the biggest error is using the word till when they mean 'til. 'Til with an apostrophe is short for until, but so frequently the author uses till, as in "to till the soil."

Probably the second most common mistake is using round instead 'round (again short for around).  So the popular kids song goes, "the wheels on the bus go 'round and 'round."

Both of these errors are similar in that A) it involves contractions and B) both forms are legitimate English words which means you can't rely on a computer spell-check to correct the mistake.

And there are tons of other errors such as improper punctuation.  When listing 3 or more items use commas to separate them (or depending on the situation even semi-colons, but again we're talking about kids books so the list should never be so complicated as to require semi-colors to separate the items).

Most of the books we have were given to us as gifts or hand-me-downs.  There is no way I would ever spend money on a book like this in the store, I don't want to support authors who can't proof read something as simple as a kids book, or be bothered to have someone else check their work.

Wednesday, April 10, 2013

STL String Class

So it's kind of funny, I chose the name for my blog because I'm a software developer, and yet very few posts deal with computer programming.  But today's post is very much about computer programming.

My preferred programming language is C++.  When working in C++ you pretty much need a good string class to help out.  One of my favorite string classes is the MFC class CString.  The downside is it's only available to MFC apps and sometimes you're developing non-MFC apps, or writing for other platforms.  Another common string class is the Standard Template Library (STL) string classes; std::string and std::wstring.  However, I've found the STL string classes to have some major drawbacks.  I have two main problems with these classes.

1)  They implement few useful functions compared to other string classes.  The STL string classes do not offer the ability to A) perform case-insensitive searches and compare, B) format a string like printf, C) lowercase/uppercase a string, or D) tokenize a string using delimiter characters just to name a few.  These are all very common tasks and the STL string class doesn't implement them.

2)  The second problem is a crash bug that shouldn't be.  Take the following code for example
char *sz = NULL;
std::string str(sz);

This code will result in a crash 100% of the time.  If you pass NULL into the constructor of an STL string it will crash.  This shouldn't be.  A string class that accepts pointers should check them for NULL before dereferencing them.

The STL string class has a few benefits.  First, it's pretty much ubiquitous these days.  Every C++ compiler includes a version of the STL library so you can always count on it being there.  Also, whereas it doesn't offer many advanced functions it does offer memory management and the most basic of functions.  So it's better than nothing.

I think what shocks me the most about the STL string classes is how poor they are compared to the rest of the STL.  The STL container classes like vector, list, and queue are extremely well written and I use them a lot.  So I would have expected the string classes to be better than they are.

Even though CString is my preferred class, I actually use a different string class in most of my projects.  Years ago I wrote my own string class, which I've continued to improve over the years.  It is pretty much the best of all the string classes I've come across.  The function names very closely follows that of CString.  I've also profiled the class for performance against both CString and STL.  The STL (because of it's simplicity) is faster than CString.  My class is as fast or faster than the STL.  Plus I've added additional functions I've felt CString was missing such as constructors that perform printf style formats.  So it's the best of both worlds; the speed and performance of the STL string classes, with all of the functions in CString and then some.  I guess the only downside to the class is it calls some Windows APIs and therefore is not cross platform.  But other than that it's a really nice, fast, and stable string class.  I truly wish I could upload this class for everyone to use, but alas I developed it at work which makes it the property of my employer.

Monday, April 8, 2013

Helium

Recently we had a birthday party for our 2 year old.  As with many parties for kids we had Helium-filled balloons.  But part of me feels like this was a horrible waste of a useful resource.  I know, that sounds a little odd to regret buying Helium-filled balloons, but let me explain.

As anyone who's taken chemistry knows, there are only two gases lighter than the average density of air; Hydrogen and Helium.  Because Hydrogen is highly inflammable (think Hindenburg), balloons and dirigibles are now filled with Helium.  But people don't realize Helium is a precious commodity that, depending on how you look at it, is NOT renewable.  When Helium is present in the atmosphere, because it is lighter than air, it rises.  It continually rises higher and higher in the atmosphere until eventually it bleeds off into space.  The same is true of Hydrogen, but Helium (unlike Hydrogen) is chemically inert so it can't react with anything making it heavier and thus keeping it in the atmosphere.  What this means is once Helium becomes airborn, it's only a matter of time until it's gone.  Helium is the second most abundant element in the universe, but it's extremely rare on Earth.  Only 5 parts per million of the atmosphere is Helium, and most of that is in the extreme upper atmosphere where we currently don't have the ability to extract it.

You might be asking yourself, if Helium is so rare in the atmosphere how or where does the Helium we use come from?  It may shock you to learn Helium is extracted from the ground, in the exact same way as natural gas.  There is Helium trapped in layers of rocks underground which is extracted and separated from other gases.  I believe up to 10% of raw natural gas underground is Helium.  If you're wondering how the Helium got in the ground in the first place, it turns out Helium is the by product of radioactive decay of several large elements such as Uranium.  That's why, to some degree, Helium could be considered a "renewable" resource because even though we take Helium out of the ground, there's always elements decaying creating more Helium.  That said, I highly suspect man is extracting Helium and using Helium at a greater rate than it's being created.  And that's why I feel like the Helium-filled balloons were such a waste.  We used Helium strictly for decoration when Helium has so many other uses such as cryogenics, dirigibles, inert gas environments, etc.  So in the future if I need MRI medical scan but the MRI machine isn't operational because there is no Helium to cool the super-conductive magnets, I'm sure going to wish I didn't waste the Helium on balloons.